Avoid duplicate sites when sitename changes, b=136413, r=akkana, sr=hewitt

This commit is contained in:
cmanske%netscape.com 2002-05-01 14:50:23 +00:00
parent 7e84acb02a
commit 33952ad5fe
2 changed files with 16 additions and 12 deletions

View File

@ -29,7 +29,6 @@ var gPublishSiteData;
var gReturnData; var gReturnData;
var gDefaultSiteIndex = -1; var gDefaultSiteIndex = -1;
var gDefaultSiteName; var gDefaultSiteName;
var gPreviousDefaultSite;
var gPreviousDefaultDir; var gPreviousDefaultDir;
var gPreviousTitle; var gPreviousTitle;
var gSettingsChanged = false; var gSettingsChanged = false;
@ -84,7 +83,6 @@ function Startup()
gPublishSiteData = GetPublishSiteData(); gPublishSiteData = GetPublishSiteData();
gDefaultSiteName = GetDefaultPublishSiteName(); gDefaultSiteName = GetDefaultPublishSiteName();
gPreviousDefaultSite = gDefaultSiteName;
var addNewSite = false; var addNewSite = false;
if (gPublishSiteData) if (gPublishSiteData)
@ -116,7 +114,7 @@ function Startup()
{ {
var dirObj = {}; var dirObj = {};
var siteIndex = FindSiteIndexAndDocDir(gPublishSiteData, docUrl, dirObj); var siteIndex = FindSiteIndexAndDocDir(gPublishSiteData, docUrl, dirObj);
// Select this site only if the same as user's intended site, or there wasn't one // Select this site only if the same as user's intended site, or there wasn't one
if (siteIndex != -1 && (gInitialSiteIndex == -1 || siteIndex == gInitialSiteIndex)) if (siteIndex != -1 && (gInitialSiteIndex == -1 || siteIndex == gInitialSiteIndex))
{ {
@ -146,8 +144,7 @@ function Startup()
if (publishData) if (publishData)
{ {
filename = publishData.filename; filename = publishData.filename;
// With new remote sites, Site Name is: host (scheme) gDialog.SiteNameInput.value = publishData.siteName;
gDialog.SiteNameInput.value = GetHost(docUrl) + " (" + GetScheme(docUrl) + ")";
gDialog.PublishUrlInput.value = publishData.publishUrl; gDialog.PublishUrlInput.value = publishData.publishUrl;
gDialog.BrowseUrlInput.value = publishData.browseUrl; gDialog.BrowseUrlInput.value = publishData.browseUrl;
gDialog.UsernameInput.value = publishData.username; gDialog.UsernameInput.value = publishData.username;
@ -162,7 +159,7 @@ function Startup()
} catch (e) {} } catch (e) {}
gDialog.PageTitleInput.value = gPreviousTitle; gDialog.PageTitleInput.value = gPreviousTitle;
gDialog.FilenameInput.value = filename; gDialog.FilenameInput.value = unescape(filename);
if (!addNewSite) if (!addNewSite)
{ {
@ -267,9 +264,6 @@ function SelectSiteList()
AppendStringToMenulist(gDialog.OtherDirList, gPublishSiteData[selectedSiteIndex].dirList[i]); AppendStringToMenulist(gDialog.OtherDirList, gPublishSiteData[selectedSiteIndex].dirList[i]);
} }
} }
gDialog.DocDirList.value = gPublishSiteData[selectedSiteIndex].docDir;
gDialog.OtherDirList.value = gPublishSiteData[selectedSiteIndex].otherDir;
gDialog.DocDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].docDir); gDialog.DocDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].docDir);
gDialog.OtherDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].otherDir); gDialog.OtherDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].otherDir);
publishOtherFiles = gPublishSiteData[selectedSiteIndex].publishOtherFiles; publishOtherFiles = gPublishSiteData[selectedSiteIndex].publishOtherFiles;
@ -463,6 +457,7 @@ function ValidateSettings()
gPublishSiteData[siteIndex].otherDir = ""; gPublishSiteData[siteIndex].otherDir = "";
gPublishSiteData[siteIndex].dirList = [""]; gPublishSiteData[siteIndex].dirList = [""];
gPublishSiteData[siteIndex].publishOtherFiles = true; gPublishSiteData[siteIndex].publishOtherFiles = true;
gPublishSiteData[siteIndex].previousSiteName = siteName;
newSite = true; newSite = true;
} }
gPublishSiteData[siteIndex].siteName = siteName; gPublishSiteData[siteIndex].siteName = siteName;
@ -499,10 +494,17 @@ function ValidateSettings()
{ {
// Update selected item if sitename changed // Update selected item if sitename changed
var selectedItem = gDialog.SiteList.selectedItem; var selectedItem = gDialog.SiteList.selectedItem;
if (selectedItem && selectedItem.getAttribute("label") != siteName) if (selectedItem)
{ {
selectedItem.setAttribute("label", siteName); var oldName = selectedItem.getAttribute("label");
gDialog.SiteList.setAttribute("label", siteName); if (oldName != siteName)
{
selectedItem.setAttribute("label", siteName);
gDialog.SiteList.setAttribute("label", siteName);
gSettingsChanged = true;
if (oldName == gDefaultSiteName)
gDefaultSiteName = siteName;
}
} }
} }
@ -522,6 +524,7 @@ function ValidateSettings()
// Fill return data object // Fill return data object
gReturnData.siteName = siteName; gReturnData.siteName = siteName;
gReturnData.previousSiteName = gPublishSiteData[siteIndex].previousSiteName;
gReturnData.publishUrl = publishUrl; gReturnData.publishUrl = publishUrl;
gReturnData.browseUrl = browseUrl; gReturnData.browseUrl = browseUrl;
gReturnData.username = username; gReturnData.username = username;

View File

@ -288,6 +288,7 @@ function UpdateSettings()
gPublishSiteData[gCurrentSiteIndex].docDir = ""; gPublishSiteData[gCurrentSiteIndex].docDir = "";
gPublishSiteData[gCurrentSiteIndex].otherDir = ""; gPublishSiteData[gCurrentSiteIndex].otherDir = "";
gPublishSiteData[gCurrentSiteIndex].dirList = [""]; gPublishSiteData[gCurrentSiteIndex].dirList = [""];
gPublishSiteData[gCurrentSiteIndex].previousSiteName = newName;
} }
gPublishSiteData[gCurrentSiteIndex].siteName = newName; gPublishSiteData[gCurrentSiteIndex].siteName = newName;