2004-04-18 18:21:17 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
2001-09-20 04:02:59 +04:00
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
2004-04-18 18:21:17 +04:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998-1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Charles Manske (cmanske@netscape.com)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-11-13 19:37:58 +03:00
|
|
|
|
2002-10-03 08:05:34 +04:00
|
|
|
var gNewTitle = "";
|
|
|
|
var gAuthor = "";
|
|
|
|
var gDescription = "";
|
|
|
|
var gAuthorElement;
|
|
|
|
var gDescriptionElement;
|
|
|
|
var gInsertNewAuthor = false;
|
|
|
|
var gInsertNewDescription = false;
|
|
|
|
var gTitleWasEdited = false;
|
|
|
|
var gAuthorWasEdited = false;
|
|
|
|
var gDescWasEdited = false;
|
1999-11-13 19:37:58 +03:00
|
|
|
|
|
|
|
//Cancel() is in EdDialogCommon.js
|
|
|
|
// dialog initialization code
|
|
|
|
function Startup()
|
|
|
|
{
|
2002-10-03 08:05:34 +04:00
|
|
|
var editor = GetCurrentEditor();
|
|
|
|
if (!editor)
|
|
|
|
{
|
|
|
|
window.close();
|
1999-11-13 19:37:58 +03:00
|
|
|
return;
|
2002-10-03 08:05:34 +04:00
|
|
|
}
|
1999-11-13 19:37:58 +03:00
|
|
|
|
2001-10-11 00:07:06 +04:00
|
|
|
gDialog.PageLocation = document.getElementById("PageLocation");
|
2002-10-03 08:05:34 +04:00
|
|
|
gDialog.PageModDate = document.getElementById("PageModDate");
|
2001-10-11 00:07:06 +04:00
|
|
|
gDialog.TitleInput = document.getElementById("TitleInput");
|
|
|
|
gDialog.AuthorInput = document.getElementById("AuthorInput");
|
|
|
|
gDialog.DescriptionInput = document.getElementById("DescriptionInput");
|
2000-02-15 18:54:05 +03:00
|
|
|
|
|
|
|
// Default string for new page is set from DTD string in XUL,
|
|
|
|
// so set only if not new doc URL
|
2002-02-15 09:07:40 +03:00
|
|
|
var location = GetDocumentUrl();
|
2000-09-02 02:01:44 +04:00
|
|
|
var lastmodString = GetString("Unknown");
|
2001-08-03 02:00:59 +04:00
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
if (!IsUrlAboutBlank(location))
|
2000-04-29 03:35:36 +04:00
|
|
|
{
|
2002-04-04 18:30:15 +04:00
|
|
|
// NEVER show username and password in clear text
|
|
|
|
gDialog.PageLocation.setAttribute("value", StripPassword(location));
|
2000-06-16 18:22:12 +04:00
|
|
|
|
2000-04-29 03:35:36 +04:00
|
|
|
// Get last-modified file date+time
|
|
|
|
// TODO: Convert this to local time?
|
2002-10-03 08:05:34 +04:00
|
|
|
var lastmod;
|
|
|
|
try {
|
|
|
|
lastmod = editor.document.lastModified; // get string of last modified date
|
|
|
|
} catch (e) {}
|
2001-11-30 02:49:02 +03:00
|
|
|
// Convert modified string to date (0 = unknown date or January 1, 1970 GMT)
|
2002-04-23 03:37:28 +04:00
|
|
|
if(Date.parse(lastmod))
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
const nsScriptableDateFormat_CONTRACTID = "@mozilla.org/intl/scriptabledateformat;1";
|
|
|
|
const nsIScriptableDateFormat = Components.interfaces.nsIScriptableDateFormat;
|
|
|
|
var dateService = Components.classes[nsScriptableDateFormat_CONTRACTID]
|
|
|
|
.getService(nsIScriptableDateFormat);
|
|
|
|
|
|
|
|
var lastModDate = new Date();
|
|
|
|
lastModDate.setTime(Date.parse(lastmod));
|
|
|
|
lastmodString = dateService.FormatDateTime("",
|
|
|
|
dateService.dateFormatLong,
|
|
|
|
dateService.timeFormatSeconds,
|
|
|
|
lastModDate.getFullYear(),
|
|
|
|
lastModDate.getMonth()+1,
|
|
|
|
lastModDate.getDate(),
|
|
|
|
lastModDate.getHours(),
|
|
|
|
lastModDate.getMinutes(),
|
|
|
|
lastModDate.getSeconds());
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
2000-04-29 03:35:36 +04:00
|
|
|
}
|
2002-10-03 08:05:34 +04:00
|
|
|
gDialog.PageModDate.value = lastmodString;
|
2000-02-15 18:54:05 +03:00
|
|
|
|
2002-10-03 08:05:34 +04:00
|
|
|
gAuthorElement = GetMetaElement("author");
|
|
|
|
if (!gAuthorElement)
|
2000-02-03 05:06:10 +03:00
|
|
|
{
|
2002-10-03 08:05:34 +04:00
|
|
|
gAuthorElement = CreateMetaElement("author");
|
|
|
|
if (!gAuthorElement)
|
2001-05-09 09:23:37 +04:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
window.close();
|
2001-05-09 09:23:37 +04:00
|
|
|
return;
|
|
|
|
}
|
2002-10-03 08:05:34 +04:00
|
|
|
gInsertNewAuthor = true;
|
2000-02-03 05:06:10 +03:00
|
|
|
}
|
|
|
|
|
2002-10-03 08:05:34 +04:00
|
|
|
gDescriptionElement = GetMetaElement("description");
|
|
|
|
if (!gDescriptionElement)
|
2000-02-03 05:06:10 +03:00
|
|
|
{
|
2002-10-03 08:05:34 +04:00
|
|
|
gDescriptionElement = CreateMetaElement("description");
|
|
|
|
if (!gDescriptionElement)
|
2000-02-15 18:54:05 +03:00
|
|
|
window.close();
|
2000-02-03 05:06:10 +03:00
|
|
|
|
2002-10-03 08:05:34 +04:00
|
|
|
gInsertNewDescription = true;
|
2000-02-15 18:54:05 +03:00
|
|
|
}
|
2000-04-28 09:59:16 +04:00
|
|
|
|
2000-02-03 05:06:10 +03:00
|
|
|
InitDialog();
|
|
|
|
|
2001-10-11 00:07:06 +04:00
|
|
|
SetTextboxFocus(gDialog.TitleInput);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
|
|
|
|
SetWindowLocation();
|
1999-11-13 19:37:58 +03:00
|
|
|
}
|
|
|
|
|
1999-12-02 01:20:50 +03:00
|
|
|
function InitDialog()
|
|
|
|
{
|
2002-10-03 08:05:34 +04:00
|
|
|
gDialog.TitleInput.value = GetDocumentTitle();
|
|
|
|
|
|
|
|
var gAuthor = TrimString(gAuthorElement.getAttribute("content"));
|
|
|
|
if (!gAuthor)
|
2000-08-11 07:20:47 +04:00
|
|
|
{
|
|
|
|
// Fill in with value from editor prefs
|
|
|
|
var prefs = GetPrefs();
|
|
|
|
if (prefs)
|
2002-10-03 08:05:34 +04:00
|
|
|
gAuthor = prefs.getCharPref("editor.author");
|
2000-08-11 07:20:47 +04:00
|
|
|
}
|
2002-10-03 08:05:34 +04:00
|
|
|
gDialog.AuthorInput.value = gAuthor;
|
|
|
|
gDialog.DescriptionInput.value = gDescriptionElement.getAttribute("content");
|
1999-12-02 01:20:50 +03:00
|
|
|
}
|
|
|
|
|
2001-03-22 03:15:47 +03:00
|
|
|
function TextboxChanged(ID)
|
2000-04-28 09:59:16 +04:00
|
|
|
{
|
|
|
|
switch(ID)
|
|
|
|
{
|
|
|
|
case "TitleInput":
|
2002-10-03 08:05:34 +04:00
|
|
|
gTitleWasEdited = true;
|
2000-04-28 09:59:16 +04:00
|
|
|
break;
|
|
|
|
case "AuthorInput":
|
2002-10-03 08:05:34 +04:00
|
|
|
gAuthorWasEdited = true;
|
2000-04-28 09:59:16 +04:00
|
|
|
break;
|
|
|
|
case "DescriptionInput":
|
2002-10-03 08:05:34 +04:00
|
|
|
gDescWasEdited = true;
|
2000-04-28 09:59:16 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-15 18:54:05 +03:00
|
|
|
function ValidateData()
|
|
|
|
{
|
2002-10-03 08:05:34 +04:00
|
|
|
gNewTitle = TrimString(gDialog.TitleInput.value);
|
|
|
|
gAuthor = TrimString(gDialog.AuthorInput.value);
|
|
|
|
gDescription = TrimString(gDialog.DescriptionInput.value);
|
2000-02-15 18:54:05 +03:00
|
|
|
return true;
|
2000-02-03 05:06:10 +03:00
|
|
|
}
|
|
|
|
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 07:06:54 +03:00
|
|
|
function onAccept()
|
1999-11-13 19:37:58 +03:00
|
|
|
{
|
2000-02-15 18:54:05 +03:00
|
|
|
if (ValidateData())
|
|
|
|
{
|
2002-10-03 08:05:34 +04:00
|
|
|
var editor = GetCurrentEditor();
|
|
|
|
editor.beginTransaction();
|
|
|
|
|
|
|
|
// Set title contents even if string is empty
|
|
|
|
// because TITLE is a required HTML element
|
|
|
|
if (gTitleWasEdited)
|
|
|
|
SetDocumentTitle(gNewTitle);
|
2000-02-15 18:54:05 +03:00
|
|
|
|
2002-10-03 08:05:34 +04:00
|
|
|
if (gAuthorWasEdited)
|
2002-10-15 00:14:40 +04:00
|
|
|
SetMetaElementContent(gAuthorElement, gAuthor, gInsertNewAuthor, false);
|
2002-10-03 08:05:34 +04:00
|
|
|
|
|
|
|
if (gDescWasEdited)
|
2002-10-15 00:14:40 +04:00
|
|
|
SetMetaElementContent(gDescriptionElement, gDescription, gInsertNewDescription, false);
|
2000-02-15 18:54:05 +03:00
|
|
|
|
2002-10-03 08:05:34 +04:00
|
|
|
editor.endTransaction();
|
2001-02-27 00:51:44 +03:00
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
SaveWindowLocation();
|
2000-02-15 18:54:05 +03:00
|
|
|
return true; // do close the window
|
|
|
|
}
|
|
|
|
return false;
|
1999-11-13 19:37:58 +03:00
|
|
|
}
|
2000-02-15 18:54:05 +03:00
|
|
|
|