2001-11-15 18:28:24 +03:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 2001 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2002-04-16 18:14:25 +04:00
|
|
|
* Charley Manske (cmanske@netscape.com)
|
|
|
|
* Ryan Cassin (rcassin@supernova.org)
|
2001-11-15 18:28:24 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
var gPublishPanel = 0;
|
|
|
|
var gSettingsPanel = 1;
|
|
|
|
var gCurrentPanel = gPublishPanel;
|
|
|
|
var gPublishSiteData;
|
|
|
|
var gReturnData;
|
|
|
|
var gDefaultSiteIndex = -1;
|
|
|
|
var gDefaultSiteName;
|
|
|
|
var gPreviousDefaultSite;
|
|
|
|
var gPreviousDefaultDir;
|
|
|
|
var gPreviousTitle;
|
|
|
|
var gSettingsChanged = false;
|
2002-02-20 05:17:46 +03:00
|
|
|
var gInitialSiteName;
|
|
|
|
var gInitialSiteIndex = -1;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
|
|
|
// Dialog initialization code
|
|
|
|
function Startup()
|
|
|
|
{
|
2002-02-20 05:17:46 +03:00
|
|
|
window.opener.ok = false;
|
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
if (!InitEditorShell()) return;
|
|
|
|
|
|
|
|
// Element to edit is passed in
|
2002-02-20 05:17:46 +03:00
|
|
|
gInitialSiteName = window.arguments[1];
|
|
|
|
gReturnData = window.arguments[2];
|
|
|
|
if (!gReturnData)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
|
|
|
dump("Publish: Return data object not supplied\n");
|
|
|
|
window.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gDialog.TabPanels = document.getElementById("TabPanels");
|
|
|
|
gDialog.PublishTab = document.getElementById("PublishTab");
|
|
|
|
gDialog.SettingsTab = document.getElementById("SettingsTab");
|
|
|
|
|
|
|
|
// Publish panel
|
|
|
|
gDialog.PageTitleInput = document.getElementById("PageTitleInput");
|
|
|
|
gDialog.FilenameInput = document.getElementById("FilenameInput");
|
|
|
|
gDialog.SiteList = document.getElementById("SiteList");
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.DocDirList = document.getElementById("DocDirList");
|
|
|
|
gDialog.OtherDirCheckbox = document.getElementById("OtherDirCheckbox");
|
2002-03-08 03:37:47 +03:00
|
|
|
gDialog.OtherDirRadiogroup = document.getElementById("OtherDirRadiogroup");
|
|
|
|
gDialog.SameLocationRadio = document.getElementById("SameLocationRadio");
|
|
|
|
gDialog.UseSubdirRadio = document.getElementById("UseSubdirRadio");
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.OtherDirList = document.getElementById("OtherDirList");
|
2001-11-15 18:28:24 +03:00
|
|
|
|
|
|
|
// Settings Panel
|
|
|
|
gDialog.SettingsPanel = document.getElementById("SettingsPanel");
|
|
|
|
gDialog.SiteNameInput = document.getElementById("SiteNameInput");
|
|
|
|
gDialog.PublishUrlInput = document.getElementById("PublishUrlInput");
|
|
|
|
gDialog.BrowseUrlInput = document.getElementById("BrowseUrlInput");
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.UsernameInput = document.getElementById("UsernameInput");
|
|
|
|
gDialog.PasswordInput = document.getElementById("PasswordInput");
|
|
|
|
gDialog.SavePassword = document.getElementById("SavePassword");
|
2001-11-15 18:28:24 +03:00
|
|
|
|
|
|
|
gDialog.PublishButton = document.documentElement.getButton("accept");
|
|
|
|
|
|
|
|
// Change 'Ok' button to 'Publish'
|
|
|
|
gDialog.PublishButton.setAttribute("label", GetString("Publish"));
|
|
|
|
|
|
|
|
gPublishSiteData = GetPublishSiteData();
|
|
|
|
gDefaultSiteName = GetDefaultPublishSiteName();
|
|
|
|
gPreviousDefaultSite = gDefaultSiteName;
|
|
|
|
|
2002-03-08 03:37:47 +03:00
|
|
|
var addNewSite = false;
|
2001-11-15 18:28:24 +03:00
|
|
|
if (gPublishSiteData)
|
2002-03-08 03:37:47 +03:00
|
|
|
{
|
2001-11-15 18:28:24 +03:00
|
|
|
FillSiteList();
|
2002-03-08 03:37:47 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No current site data, start a new item in the Settings panel
|
|
|
|
AddNewSite();
|
|
|
|
addNewSite = true;
|
|
|
|
}
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
var docUrl = GetDocumentUrl();
|
2001-11-15 18:28:24 +03:00
|
|
|
var scheme = GetScheme(docUrl);
|
|
|
|
var filename = "";
|
2002-03-08 03:37:47 +03:00
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
if (scheme)
|
|
|
|
{
|
|
|
|
filename = GetFilename(docUrl);
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
if (scheme != "file")
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-03-14 10:41:32 +03:00
|
|
|
var siteFound = false;
|
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
// Editing a remote URL.
|
|
|
|
// Attempt to find doc URL in Site Data
|
|
|
|
if (gPublishSiteData)
|
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
var dirObj = {};
|
2002-02-20 05:17:46 +03:00
|
|
|
var siteIndex = FindSiteIndexAndDocDir(gPublishSiteData, docUrl, dirObj);
|
|
|
|
|
2002-03-08 03:37:47 +03:00
|
|
|
// Select this site only if the same as user's intended site, or there wasn't one
|
2002-02-20 05:17:46 +03:00
|
|
|
if (siteIndex != -1 && (gInitialSiteIndex == -1 || siteIndex == gInitialSiteIndex))
|
2002-02-15 09:07:40 +03:00
|
|
|
{
|
2002-03-14 10:41:32 +03:00
|
|
|
siteFound = true;
|
|
|
|
|
2002-02-20 05:17:46 +03:00
|
|
|
// Select the site we found
|
|
|
|
gDialog.SiteList.selectedIndex = siteIndex;
|
|
|
|
var docDir = dirObj.value;
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
// Use the directory within site in the editable menulist
|
|
|
|
gPublishSiteData[siteIndex].docDir = docDir;
|
|
|
|
|
|
|
|
//XXX HOW DO WE DECIDE WHAT "OTHER" DIR TO USE?
|
|
|
|
//gPublishSiteData[siteIndex].otherDir = docDir;
|
2002-02-20 05:17:46 +03:00
|
|
|
}
|
2002-03-14 10:41:32 +03:00
|
|
|
}
|
|
|
|
if (!siteFound)
|
|
|
|
{
|
|
|
|
// Not found in site database
|
|
|
|
// Setup for a new site and use data from a remote URL
|
|
|
|
if (!addNewSite)
|
|
|
|
AddNewSite();
|
|
|
|
|
|
|
|
addNewSite = true;
|
|
|
|
|
|
|
|
var publishData = CreatePublishDataFromUrl(docUrl);
|
|
|
|
if (publishData)
|
2002-03-08 03:37:47 +03:00
|
|
|
{
|
2002-03-14 10:41:32 +03:00
|
|
|
filename = publishData.filename;
|
2002-04-16 18:14:25 +04:00
|
|
|
// With new remote sites, Site Name is: host (scheme)
|
|
|
|
gDialog.SiteNameInput.value = GetHost(docUrl) + " (" + GetScheme(docUrl) + ")";
|
2002-03-14 10:41:32 +03:00
|
|
|
gDialog.PublishUrlInput.value = publishData.publishUrl;
|
|
|
|
gDialog.BrowseUrlInput.value = publishData.browseUrl;
|
|
|
|
gDialog.UsernameInput.value = publishData.username;
|
|
|
|
gDialog.PasswordInput.value = publishData.password;
|
|
|
|
gDialog.SavePassword.checked = false;
|
2002-03-08 03:37:47 +03:00
|
|
|
}
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
try {
|
|
|
|
gPreviousTitle = editorShell.GetDocumentTitle();
|
|
|
|
} catch (e) {}
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.PageTitleInput.value = gPreviousTitle;
|
|
|
|
gDialog.FilenameInput.value = filename;
|
|
|
|
|
2002-03-08 03:37:47 +03:00
|
|
|
if (!addNewSite)
|
|
|
|
{
|
|
|
|
// If not adding a site and we haven't selected a site -- use initial or default site
|
|
|
|
if (gDialog.SiteList.selectedIndex == -1)
|
|
|
|
gDialog.SiteList.selectedIndex = (gInitialSiteIndex != -1) ? gInitialSiteIndex : gDefaultSiteIndex;
|
|
|
|
|
|
|
|
// Fill in all the site data for currently-selected site
|
|
|
|
SelectSiteList();
|
|
|
|
SetTextboxFocus(gDialog.PageTitleInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gDialog.SiteList.selectedIndex == -1)
|
|
|
|
{
|
|
|
|
// No selected site -- assume same directory
|
2002-03-14 10:41:32 +03:00
|
|
|
gDialog.OtherDirRadiogroup.selectedItem = gDialog.SameLocationRadio;
|
2002-03-08 03:37:47 +03:00
|
|
|
}
|
2002-03-27 06:52:37 +03:00
|
|
|
else if (gPublishSiteData[gDialog.SiteList.selectedIndex].docDir ==
|
|
|
|
gPublishSiteData[gDialog.SiteList.selectedIndex].otherDir)
|
2002-03-08 03:37:47 +03:00
|
|
|
{
|
|
|
|
// For now, check "same location" if dirs are already set to same directory
|
2002-03-27 06:52:37 +03:00
|
|
|
gDialog.OtherDirRadiogroup.selectedItem = gDialog.SameLocationRadio;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gDialog.OtherDirRadiogroup.selectedItem = gDialog.UseSubdirRadio;
|
2002-03-08 03:37:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
doEnabling();
|
|
|
|
|
|
|
|
SetWindowLocation();
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function FillSiteList()
|
|
|
|
{
|
|
|
|
ClearMenulist(gDialog.SiteList);
|
|
|
|
gDefaultSiteIndex = -1;
|
|
|
|
|
|
|
|
// Fill the site lists
|
|
|
|
var count = gPublishSiteData.length;
|
|
|
|
var i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
var name = gPublishSiteData[i].siteName;
|
2002-04-17 05:13:36 +04:00
|
|
|
var menuitem = AppendStringToMenulist(gDialog.SiteList, name);
|
2002-02-15 09:07:40 +03:00
|
|
|
// Highlight the default site
|
2001-11-15 18:28:24 +03:00
|
|
|
if (name == gDefaultSiteName)
|
|
|
|
{
|
|
|
|
gDefaultSiteIndex = i;
|
|
|
|
if (menuitem)
|
|
|
|
{
|
|
|
|
menuitem.setAttribute("class", "menuitem-highlight-1");
|
|
|
|
menuitem.setAttribute("default", "true");
|
|
|
|
}
|
|
|
|
}
|
2002-02-20 05:17:46 +03:00
|
|
|
// Find initial site location
|
|
|
|
if (name == gInitialSiteName)
|
|
|
|
gInitialSiteIndex = i;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doEnabling()
|
|
|
|
{
|
2002-03-08 03:37:47 +03:00
|
|
|
var disableOther = !gDialog.OtherDirCheckbox.checked;
|
|
|
|
gDialog.SameLocationRadio.disabled = disableOther;
|
|
|
|
gDialog.UseSubdirRadio.disabled = disableOther;
|
|
|
|
gDialog.OtherDirList.disabled = (disableOther || gDialog.SameLocationRadio.selected);
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function SelectSiteList()
|
|
|
|
{
|
|
|
|
var selectedSiteIndex = gDialog.SiteList.selectedIndex;
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
var siteName = "";
|
|
|
|
var publishUrl = "";
|
|
|
|
var browseUrl = "";
|
|
|
|
var username = "";
|
|
|
|
var password = "";
|
|
|
|
var savePassword = false;
|
2002-04-04 18:56:30 +04:00
|
|
|
var publishOtherFiles = true;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
ClearMenulist(gDialog.DocDirList);
|
|
|
|
ClearMenulist(gDialog.OtherDirList);
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
if (gPublishSiteData && selectedSiteIndex != -1)
|
|
|
|
{
|
|
|
|
siteName = gPublishSiteData[selectedSiteIndex].siteName;
|
|
|
|
publishUrl = gPublishSiteData[selectedSiteIndex].publishUrl;
|
|
|
|
browseUrl = gPublishSiteData[selectedSiteIndex].browseUrl;
|
|
|
|
username = gPublishSiteData[selectedSiteIndex].username;
|
|
|
|
savePassword = gPublishSiteData[selectedSiteIndex].savePassword;
|
|
|
|
if (savePassword)
|
|
|
|
password = gPublishSiteData[selectedSiteIndex].password;
|
|
|
|
|
|
|
|
// Fill the directory menulists
|
|
|
|
if (gPublishSiteData[selectedSiteIndex].dirList.length)
|
|
|
|
{
|
|
|
|
for (var i = 0; i < gPublishSiteData[selectedSiteIndex].dirList.length; i++)
|
|
|
|
{
|
|
|
|
AppendStringToMenulist(gDialog.DocDirList, gPublishSiteData[selectedSiteIndex].dirList[i]);
|
|
|
|
AppendStringToMenulist(gDialog.OtherDirList, gPublishSiteData[selectedSiteIndex].dirList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gDialog.DocDirList.value = gPublishSiteData[selectedSiteIndex].docDir;
|
|
|
|
gDialog.OtherDirList.value = gPublishSiteData[selectedSiteIndex].otherDir;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.DocDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].docDir);
|
|
|
|
gDialog.OtherDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].otherDir);
|
2002-04-04 18:56:30 +04:00
|
|
|
publishOtherFiles = gPublishSiteData[selectedSiteIndex].publishOtherFiles;
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
}
|
|
|
|
else
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-03-08 03:37:47 +03:00
|
|
|
gDialog.DocDirList.value = "";
|
|
|
|
gDialog.OtherDirList.value = "";
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
|
|
|
|
gDialog.SiteNameInput.value = siteName;
|
|
|
|
gDialog.PublishUrlInput.value = publishUrl;
|
|
|
|
gDialog.BrowseUrlInput.value = browseUrl;
|
|
|
|
gDialog.UsernameInput.value = username;
|
|
|
|
gDialog.PasswordInput.value = password;
|
|
|
|
gDialog.SavePassword.checked = savePassword;
|
2002-04-04 18:56:30 +04:00
|
|
|
gDialog.OtherDirCheckbox.checked = publishOtherFiles;
|
|
|
|
|
|
|
|
doEnabling();
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function AddNewSite()
|
|
|
|
{
|
|
|
|
// Button in Publish panel allows user
|
|
|
|
// to automatically switch to "Settings" panel
|
|
|
|
// to enter data for new site
|
|
|
|
SwitchPanel(gSettingsPanel);
|
2002-02-15 09:07:40 +03:00
|
|
|
|
|
|
|
gDialog.SiteList.selectedIndex = -1;
|
|
|
|
|
|
|
|
SelectSiteList();
|
|
|
|
|
|
|
|
gSettingsChanged = true;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
|
|
|
SetTextboxFocus(gDialog.SiteNameInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SelectPublishTab()
|
|
|
|
{
|
|
|
|
if (gSettingsChanged)
|
|
|
|
{
|
|
|
|
gCurrentPanel = gPublishPanel;
|
2002-02-15 09:07:40 +03:00
|
|
|
if (!ValidateSettings())
|
2001-11-15 18:28:24 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
gCurrentPanel = gSettingsPanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwitchPanel(gPublishPanel);
|
|
|
|
SetTextboxFocus(gDialog.PageTitleInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SelectSettingsTab()
|
|
|
|
{
|
|
|
|
SwitchPanel(gSettingsPanel);
|
|
|
|
SetTextboxFocus(gDialog.SiteNameInput);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SwitchPanel(panel)
|
|
|
|
{
|
|
|
|
if (gCurrentPanel != panel)
|
|
|
|
{
|
|
|
|
// Set index for starting panel on the <tabpanels> element
|
2001-11-30 03:06:33 +03:00
|
|
|
gDialog.TabPanels.selectedIndex = panel;
|
2001-11-15 18:28:24 +03:00
|
|
|
if (panel == gSettingsPanel)
|
|
|
|
{
|
|
|
|
// Trigger setting of style for the tab widgets
|
2001-11-30 03:06:33 +03:00
|
|
|
gDialog.SettingsTab.selected = "true";
|
|
|
|
gDialog.PublishTab.selected = null;
|
2001-11-15 18:28:24 +03:00
|
|
|
} else {
|
2001-11-30 03:06:33 +03:00
|
|
|
gDialog.PublishTab.selected = "true";
|
|
|
|
gDialog.SettingsTab.selected = null;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
gCurrentPanel = panel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onInputSettings()
|
|
|
|
{
|
|
|
|
// TODO: Save current data during SelectSite and compare here
|
|
|
|
// to detect if real change has occured?
|
|
|
|
gSettingsChanged = true;
|
|
|
|
}
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
function GetPublishUrlInput()
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.PublishUrlInput.value = FormatUrlForPublishing(gDialog.PublishUrlInput.value);
|
|
|
|
return gDialog.PublishUrlInput.value;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
function GetBrowseUrlInput()
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.BrowseUrlInput.value = FormatUrlForPublishing(gDialog.BrowseUrlInput.value);
|
|
|
|
return gDialog.BrowseUrlInput.value;
|
|
|
|
}
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
function GetDocDirInput()
|
|
|
|
{
|
|
|
|
gDialog.DocDirList.value = FormatDirForPublishing(gDialog.DocDirList.value);
|
|
|
|
return gDialog.DocDirList.value;
|
|
|
|
}
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
function GetOtherDirInput()
|
|
|
|
{
|
|
|
|
gDialog.OtherDirList.value = FormatDirForPublishing(gDialog.OtherDirList.value);
|
|
|
|
return gDialog.OtherDirList.value;
|
|
|
|
}
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
function ChooseDir(menulist)
|
|
|
|
{
|
|
|
|
//TODO: For FTP publish destinations, get file listing of just dirs
|
|
|
|
// and build a tree to let user select dir
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
function ValidateSettings()
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
var siteName = TrimString(gDialog.SiteNameInput.value);
|
|
|
|
if (!siteName)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
|
|
|
ShowErrorInPanel(gSettingsPanel, "MissingSiteNameError", gDialog.SiteNameInput);
|
|
|
|
return false;
|
|
|
|
}
|
2002-03-23 01:06:15 +03:00
|
|
|
if (PublishSiteNameExists(siteName, gPublishSiteData, gDialog.SiteList.selectedIndex))
|
|
|
|
{
|
|
|
|
SwitchPanel(gSettingsPanel);
|
|
|
|
ShowInputErrorMessage(GetString("DuplicateSiteNameError").replace(/%name%/, siteName));
|
|
|
|
SetTextboxFocus(gDialog.SiteNameInput);
|
|
|
|
return false;
|
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
|
2002-03-08 03:37:47 +03:00
|
|
|
// Extract username and password while removing them from publishingUrl
|
|
|
|
var urlUserObj = {};
|
|
|
|
var urlPassObj = {};
|
|
|
|
var publishUrl = StripUsernamePassword(gDialog.PublishUrlInput.value, urlUserObj, urlPassObj);
|
|
|
|
if (publishUrl)
|
|
|
|
{
|
|
|
|
publishUrl = FormatUrlForPublishing(publishUrl);
|
|
|
|
gDialog.PublishUrlInput.value = publishUrl;
|
|
|
|
}
|
|
|
|
else
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
|
|
|
ShowErrorInPanel(gSettingsPanel, "MissingPublishUrlError", gDialog.PublishUrlInput);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
var browseUrl = GetBrowseUrlInput();
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
var username = TrimString(gDialog.UsernameInput.value);
|
|
|
|
var savePassword = gDialog.SavePassword.checked;
|
|
|
|
var password = gDialog.PasswordInput.value;
|
2002-04-04 18:56:30 +04:00
|
|
|
var publishOtherFiles = gDialog.OtherDirCheckbox.checked;
|
2002-03-08 03:37:47 +03:00
|
|
|
|
|
|
|
//XXX If there was a username and/or password in the publishUrl
|
|
|
|
// AND in the input field, which do we use?
|
|
|
|
// Let's use those in url only if input is empty
|
|
|
|
if (!username)
|
|
|
|
{
|
|
|
|
username = urlUserObj.value;
|
|
|
|
gDialog.UsernameInput.value = username;
|
|
|
|
gSettingsChanged = true;
|
|
|
|
}
|
|
|
|
if (!password)
|
|
|
|
{
|
|
|
|
password = urlPassObj.value;
|
|
|
|
gDialog.PasswordInput.value = password;
|
|
|
|
gSettingsChanged = true;
|
|
|
|
}
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
// Update or add data for a site
|
|
|
|
var siteIndex = gDialog.SiteList.selectedIndex;
|
|
|
|
var newSite = false;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
if (siteIndex == -1)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
// No site is selected, add a new site at the end
|
|
|
|
if (gPublishSiteData)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
siteIndex = gPublishSiteData.length;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
else
|
|
|
|
{
|
2002-04-04 18:56:30 +04:00
|
|
|
// First time: start entire site array
|
2002-02-15 09:07:40 +03:00
|
|
|
gPublishSiteData = new Array(1);
|
|
|
|
siteIndex = 0;
|
|
|
|
gDefaultSiteIndex = 0;
|
|
|
|
gDefaultSiteName = siteName;
|
|
|
|
}
|
|
|
|
gPublishSiteData[siteIndex] = {};
|
2002-03-08 03:37:47 +03:00
|
|
|
gPublishSiteData[siteIndex].docDir = "";
|
|
|
|
gPublishSiteData[siteIndex].otherDir = "";
|
|
|
|
gPublishSiteData[siteIndex].dirList = [""];
|
2002-04-04 18:56:30 +04:00
|
|
|
gPublishSiteData[siteIndex].publishOtherFiles = true;
|
2002-02-15 09:07:40 +03:00
|
|
|
newSite = true;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
gPublishSiteData[siteIndex].siteName = siteName;
|
|
|
|
gPublishSiteData[siteIndex].publishUrl = publishUrl;
|
|
|
|
gPublishSiteData[siteIndex].browseUrl = browseUrl;
|
|
|
|
gPublishSiteData[siteIndex].username = username;
|
|
|
|
// Don't save password in data that will be saved in prefs
|
|
|
|
gPublishSiteData[siteIndex].password = savePassword ? password : "";
|
|
|
|
gPublishSiteData[siteIndex].savePassword = savePassword;
|
|
|
|
|
2002-04-04 18:56:30 +04:00
|
|
|
if (publishOtherFiles != gPublishSiteData[siteIndex].publishOtherFiles)
|
|
|
|
gSettingsChanged = true;
|
|
|
|
|
|
|
|
gPublishSiteData[siteIndex].publishOtherFiles = publishOtherFiles;
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
gDialog.SiteList.selectedIndex = siteIndex;
|
|
|
|
if (siteIndex == gDefaultSiteIndex)
|
|
|
|
gDefaultSiteName = siteName;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
// Should never be empty, but be sure we have a default site
|
|
|
|
if (!gDefaultSiteName)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
gDefaultSiteName = gPublishSiteData[0].siteName;
|
2001-11-15 18:28:24 +03:00
|
|
|
gDefaultSiteIndex = 0;
|
|
|
|
}
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
// Rebuild the site menulist if we added a new site
|
|
|
|
if (newSite)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
FillSiteList();
|
|
|
|
gDialog.SiteList.selectedIndex = siteIndex;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
2002-02-20 05:17:46 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Update selected item if sitename changed
|
|
|
|
var selectedItem = gDialog.SiteList.selectedItem;
|
2002-04-04 18:56:30 +04:00
|
|
|
if (selectedItem && selectedItem.getAttribute("label") != siteName)
|
2002-02-20 05:17:46 +03:00
|
|
|
{
|
2002-04-17 05:13:36 +04:00
|
|
|
selectedItem.setAttribute("label", siteName);
|
|
|
|
gDialog.SiteList.setAttribute("label", siteName);
|
2002-02-20 05:17:46 +03:00
|
|
|
}
|
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
|
|
|
|
// Get the directory name in site to publish to
|
|
|
|
var docDir = GetDocDirInput();
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
gPublishSiteData[siteIndex].docDir = docDir;
|
|
|
|
|
|
|
|
// And directory for images and other files
|
|
|
|
var otherDir = GetOtherDirInput();
|
2002-03-08 03:37:47 +03:00
|
|
|
if (gDialog.SameLocationRadio.selected)
|
|
|
|
otherDir = docDir;
|
|
|
|
else
|
|
|
|
otherDir = GetOtherDirInput();
|
2002-02-15 09:07:40 +03:00
|
|
|
|
|
|
|
gPublishSiteData[siteIndex].otherDir = otherDir;
|
|
|
|
|
|
|
|
// Fill return data object
|
|
|
|
gReturnData.siteName = siteName;
|
|
|
|
gReturnData.publishUrl = publishUrl;
|
|
|
|
gReturnData.browseUrl = browseUrl;
|
|
|
|
gReturnData.username = username;
|
|
|
|
// Note that we use the password for the next publish action
|
|
|
|
// even if savePassword is false; but we won't save it in PasswordManager database
|
|
|
|
gReturnData.password = password;
|
|
|
|
gReturnData.savePassword = savePassword;
|
|
|
|
gReturnData.docDir = gPublishSiteData[siteIndex].docDir;
|
2002-04-04 18:56:30 +04:00
|
|
|
gReturnData.otherDir = gPublishSiteData[siteIndex].otherDir;
|
|
|
|
gReturnData.publishOtherFiles = publishOtherFiles;
|
2002-02-15 09:07:40 +03:00
|
|
|
gReturnData.dirList = gPublishSiteData[siteIndex].dirList;
|
2001-11-15 18:28:24 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ValidateData()
|
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
if (!ValidateSettings())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var siteIndex = gDialog.SiteList.selectedIndex;
|
|
|
|
if (siteIndex == -1)
|
|
|
|
return false;
|
2001-11-15 18:28:24 +03:00
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
var filename = TrimString(gDialog.FilenameInput.value);
|
|
|
|
if (!filename)
|
2001-11-15 18:28:24 +03:00
|
|
|
{
|
2002-02-15 09:07:40 +03:00
|
|
|
ShowErrorInPanel(gPublishPanel, "MissingPublishFilename", gDialog.FilenameInput);
|
|
|
|
return false;
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
gReturnData.filename = filename;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ShowErrorInPanel(panelId, errorMsgId, widgetWithError)
|
|
|
|
{
|
|
|
|
SwitchPanel(panelId);
|
|
|
|
ShowInputErrorMessage(GetString(errorMsgId));
|
|
|
|
if (widgetWithError)
|
|
|
|
SetTextboxFocus(widgetWithError);
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function doHelpButton()
|
|
|
|
{
|
2002-02-20 05:17:46 +03:00
|
|
|
if (gCurrentPanel == gPublishPanel)
|
2002-04-04 18:56:30 +04:00
|
|
|
openHelp("comp-doc-publish-publishtab");
|
2002-02-20 05:17:46 +03:00
|
|
|
else
|
2002-04-04 18:56:30 +04:00
|
|
|
openHelp("comp-doc-publish-settingstab");
|
2001-11-15 18:28:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAccept()
|
|
|
|
{
|
|
|
|
if (ValidateData())
|
|
|
|
{
|
2002-04-04 18:56:30 +04:00
|
|
|
// DON'T save the docDir and otherDir before trying to publish
|
|
|
|
gReturnData.saveDirs = false;
|
|
|
|
|
2002-02-15 09:07:40 +03:00
|
|
|
// We save new site data to prefs only if we are attempting to publish
|
|
|
|
if (gSettingsChanged)
|
2002-04-04 18:56:30 +04:00
|
|
|
SavePublishDataToPrefs(gReturnData);
|
|
|
|
|
|
|
|
// Set flag to resave data after publishing
|
|
|
|
// so we save docDir and otherDir if we published successfully
|
|
|
|
gReturnData.savePublishData = true;
|
2002-02-15 09:07:40 +03:00
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
var title = TrimString(gDialog.PageTitleInput.value);
|
|
|
|
if (title != gPreviousTitle)
|
2002-03-08 03:37:47 +03:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
editorShell.SetDocumentTitle(title);
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
2002-02-15 09:07:40 +03:00
|
|
|
|
2001-11-15 18:28:24 +03:00
|
|
|
SaveWindowLocation();
|
2002-02-15 09:07:40 +03:00
|
|
|
window.opener.ok = true;
|
2001-11-15 18:28:24 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|