Clean up whitespace/returns/braces, plus Ben's update to GetFields.

This commit is contained in:
brendan%mozilla.org 1999-11-28 06:37:13 +00:00
Родитель f2a5a70e3a
Коммит 869d5f55c0
5 изменённых файлов: 392 добавлений и 413 удалений

Просмотреть файл

@ -1,4 +1,5 @@
/*
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
@ -19,19 +20,19 @@
*
* Contributor(s):
* Ben Goodger (30/09/99)
*/
*/
// The WIZARD of GORE
// NOTICE! Wanting to add a panel to this wizard? Follow these instructions:
/* 1) Add your panel to the testMap Below. If you're adding your panel after
/* 1) Add your panel to the testMap Below. If you're adding your panel after
the last one, remember to set the "next" property on that element to the
idfier of your panel, and make the "next" property on your panel null.
idfier of your panel, and make the "next" property on your panel null.
This is important because the state of the Next/Back buttons depends on
correct filling of testMap.
2) You must create GetFields and SetFields functions in the JS file
associated with your panel XUL file. This is true even if your panel
contains no fields, only text, as functions in this file will expect to
2) You must create GetFields and SetFields functions in the JS file
associated with your panel XUL file. This is true even if your panel
contains no fields, only text, as functions in this file will expect to
find them. if you do not plan to include data fields, simply include empty
functions
@ -40,18 +41,18 @@
the GetFields function in your panel JS file. However you do this, this
function must return an array with the following format:
[[identifier, value],[identifier,value],...]
where identifier is some string identifier of the element (usually just
where identifier is some string identifier of the element (usually just
the ID attribute), and the value is the value being saved.
Make sure you don't choose an identifier that conflicts with one used
Make sure you don't choose an identifier that conflicts with one used
for any other panel. It is recommended you choose something fairly unique.
4) You are responsible for setting the contents of your panel. You do this
4) You are responsible for setting the contents of your panel. You do this
with the SetFields function, which is called for each element you've saved
when the panel loads. This function can set attributes, use DOM
when the panel loads. This function can set attributes, use DOM
manipulation, whatever you deem necessary to populate the panel.
You can find examples of usage of GetFields and SetFields in
You can find examples of usage of GetFields and SetFields in
newProfile1_2.js
*/
var wizardMap = ["newProfile1_1.xul"];
@ -60,12 +61,12 @@ var wizardHash = new Array;
var firstTime = true;
var profile = Components.classes["component://netscape/profile/manager"].createInstance();
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
// Navigation Set for pages contained in wizard
// Navigation Set for pages contained in wizard
var testMap = {
newProfile1_1: { previous: null, next: "newProfile1_2" },
newProfile1_2: { previous: "newProfile1_1", next: null},
newProfile1_1: { previous: null, next: "newProfile1_2" },
newProfile1_2: { previous: "newProfile1_1", next: null},
}
var pagePrefix = "chrome://profile/content/";
var pagePostfix=".xul";
@ -75,13 +76,13 @@ var currentPageTag;
var profName = "";
var profDir = "";
function wizardPageLoaded(tag)
function wizardPageLoaded(tag)
{
if (firstTime)
Startup();
currentPageTag = tag;
SetButtons();
populatePage();
if (firstTime)
Startup();
currentPageTag = tag;
SetButtons();
populatePage();
}
var backButton = null;
@ -90,90 +91,89 @@ var finishButton = null;
function loadPage(thePage)
{
if (!firstTime)
saveData();
displayPage(thePage);
firstTime = false;
return(true);
if (!firstTime)
saveData();
displayPage(thePage);
firstTime = false;
return(true);
}
function SetButtons()
{
if (!currentPageTag)
if (!currentPageTag)
return;
if (!backButton)
backButton = document.getElementById("back");
if (!nextButton)
nextButton = document.getElementById("next");
if (!backButton)
backButton = document.getElementById("back");
if (!nextButton)
nextButton = document.getElementById("next");
nextTag = testMap[currentPageTag].next;
if (nextTag) {
nextTag = testMap[currentPageTag].next;
if (nextTag) {
var nextLabel = bundle.GetStringFromName("nextButtonLabel");
nextButton.setAttribute("value",nextLabel);
nextButton.setAttribute("onclick","onNext()");
}
else {
}
else {
var finishLabel = bundle.GetStringFromName("finishButtonLabel");
nextButton.setAttribute("value",finishLabel);
nextButton.setAttribute("onclick","onFinish(opener)");
}
}
prevTag = testMap[currentPageTag].previous;
if (prevTag)
backButton.setAttribute("disabled", "false");
else
backButton.setAttribute("disabled", "true");
prevTag = testMap[currentPageTag].previous;
if (prevTag)
backButton.setAttribute("disabled", "false");
else
backButton.setAttribute("disabled", "true");
}
function onNext()
{
//dump("in onnext\n");
if (nextButton.getAttribute("disabled") == "true") {
return;
}
saveData();
var nextPageTag = testMap[currentPageTag].next;
var url = getUrlFromTag(nextPageTag);
displayPage(url);
if (nextButton.getAttribute("disabled") == "true") {
return;
}
saveData();
var nextPageTag = testMap[currentPageTag].next;
var url = getUrlFromTag(nextPageTag);
displayPage(url);
}
function onBack()
{
//dump("in onback\n");
if (backButton.getAttribute("disabled") == "true")
return;
if (backButton.getAttribute("disabled") == "true")
return;
saveData();
previousPageTag = testMap[currentPageTag].previous;
var url = getUrlFromTag(previousPageTag);
displayPage(url);
saveData();
previousPageTag = testMap[currentPageTag].previous;
var url = getUrlFromTag(previousPageTag);
displayPage(url);
}
function displayPage(content)
{
if (content != "")
{
var contentFrame = document.getElementById("content");
if (contentFrame)
contentFrame.setAttribute("src", content);
}
if (content != "") {
var contentFrame = document.getElementById("content");
if (contentFrame)
contentFrame.setAttribute("src", content);
}
}
function populatePage()
{
var contentWindow = window.frames["content"];
var doc = contentWindow.document;
for (var i in wizardHash)
contentWindow.SetFields(i,wizardHash[i]);
}
var contentWindow = window.frames["content"];
var doc = contentWindow.document;
for (var i in wizardHash)
contentWindow.SetFields(i,wizardHash[i]);
}
function saveData()
{
var contentWindow = window.frames["content"];
var contentWindow = window.frames["content"];
var data = contentWindow.GetFields();
if(data != undefined) {
for(var i = 0; i < data.length; i++)
if (data != undefined) {
for (var i = 0; i < data.length; i++)
wizardHash[data[i][0]] = data[i][1];
}
}
@ -185,89 +185,84 @@ function onCancel()
//dump("just close\n");
window.close();
}
else {
else {
//dump("exit\n");
try {
profile.forgetCurrentProfile();
profile.forgetCurrentProfile();
}
catch (ex) {
dump("failed to forget current profile.\n");
dump("failed to forget current profile.\n");
}
ExitApp();
}
}
// utility functions
function getUrlFromTag(title)
function getUrlFromTag(title)
{
return pagePrefix + title + pagePostfix;
return pagePrefix + title + pagePostfix;
}
function Startup()
{
//dump("Doing Startup...\n");
//dump("Doing Startup...\n");
}
function onFinish(opener)
{
// lets check if we're at final stage using null
if(testMap[currentPageTag].next)
if (testMap[currentPageTag].next)
return;
try {
saveData();
proceed = processCreateProfileData();
if (proceed) {
if (opener) {
opener.CreateProfile();
window.close();
}
else {
ExitApp();
}
}
else {
return;
}
}
catch (ex) {
alert("Failed to create a profile.");
return;
}
try {
saveData();
proceed = processCreateProfileData();
if (proceed) {
if (opener) {
opener.CreateProfile();
window.close();
}
else {
ExitApp();
}
}
}
catch (ex) {
alert("Failed to create a profile.");
}
}
function processCreateProfileData()
{
//Process Create Profile Data
var i;
//Process Create Profile Data
var i;
for (i in wizardHash) {
if (i == "ProfileName") {
profName = wizardHash[i];
}
if (i == "ProfileDir") {
profDir = wizardHash[i];
}
for (i in wizardHash) {
if (i == "ProfileName") {
profName = wizardHash[i];
}
try {
//dump("name,dir = " + profName + "," + profDir + "\n");
if (profName == "") {
alert("You need to enter a profile name.");
return false;
}
if (profile.profileExists(profName)) {
alert("That profile name already exists.");
return false;
}
profile.createNewProfile(profName, profDir);
profile.startApprunner(profName);
return true;
}
catch (ex) {
alert("Failed to create a profile.");
return false;
}
return false;
if (i == "ProfileDir") {
profDir = wizardHash[i];
}
}
try {
//dump("name,dir = " + profName + "," + profDir + "\n");
if (profName == "") {
alert("You need to enter a profile name.");
return false;
}
if (profile.profileExists(profName)) {
alert("That profile name already exists.");
return false;
}
profile.createNewProfile(profName, profDir);
profile.startApprunner(profName);
}
catch (ex) {
alert("Failed to create a profile.");
return false;
}
return true;
}
function ExitApp()

Просмотреть файл

@ -1,30 +1,31 @@
/*
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
* Contributor(s):
* Ben Goodger (30/09/99)
*/
// although these functions aren't used on this intro page, they're actually
// essential for the wizard progress. They do nothing and simply exist so that
// they are defined so that the wizard can call them.
// the getting procedure is unique to each page, since each page can different
// types of elements (not necessarily form elements). So each page must provide
// its own GetFields function

Просмотреть файл

@ -1,52 +1,53 @@
/*
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
* Contributor(s):
* Ben Goodger (30/09/99)
*/
// note: offloading this into a separate JS file where it should be.
// also got rid of seemingly useless function "foo". If it is needed, please
// feel free to reimplement ;)
var bundle = srGetStrBundle("chrome://profile/locale/newProfile1_2.properties");
var detect = false;
function InitializeValues()
{
element = document.getElementById("ProfileName");
element.value = parent.profName;
element = document.getElementById("ProfileDir");
element.value = parent.profDir;
element = document.getElementById("ProfileName");
element.value = parent.profName;
element = document.getElementById("ProfileDir");
element.value = parent.profDir;
}
function commit()
{
var element;
element = document.getElementById("ProfileName");
parent.SetValue(element.id, element.value);
parent.profName = element.value;
var element;
element = document.getElementById("ProfileName");
parent.SetValue(element.id, element.value);
parent.profName = element.value;
element = document.getElementById("ProfileDir");
parent.SetValue(element.id, element.value);
parent.profDir = element.value;
element = document.getElementById("ProfileDir");
parent.SetValue(element.id, element.value);
parent.profDir = element.value;
}
// the getting procedure is unique to each page, since each page can different
@ -56,15 +57,7 @@ function GetFields()
{
var profName = document.getElementById("ProfileName").value;
var profDir = document.getElementById("ProfileDir");
var profDirContent;
for(var i = 0; i < profDir.attributes.length; i++)
{
// this is just an awful, bad, terrible hack. I shouldn't have to do this
// to get the value. but all other ways return "undefined".
if(profDir.attributes[i].nodeName == "value")
profDirContent = profDir.attributes[i].nodeValue;
}
var profDirContent = profDir.getAttribute("value");
return [["ProfileName",profName],["ProfileDir",profDirContent]];
}
@ -74,33 +67,31 @@ function SetFields(element,set)
{
element = document.getElementById(element);
//dump("In SetFields(" + element + "," + set + ");\n");
if(element.id == "ProfileDir" && set != "")
if (element.id == "ProfileDir" && set != "")
getProfileDir(set,false);
else if(element.id == "ProfileName")
else if (element.id == "ProfileName")
element.value = set;
}
}
// function createProfileWizard.js::chooseFolder();
// utility function responsible for displaying a folder selection dialog.
function chooseFolder(string)
{
try {
try {
var fileSpec = Components.classes["component://netscape/filespecwithui"].createInstance();
if(fileSpec) {
if (fileSpec) {
fileSpec = fileSpec.QueryInterface(Components.interfaces.nsIFileSpecWithUI);
return fileSpec.chooseDirectory(string);
} else
return false;
}
} catch(e) {
return false;
}
return false;
}
function removeChildren(which)
{
if(which.hasChildNodes()) {
for(var i = 0; i < which.childNodes.length; i++)
{
if (which.hasChildNodes()) {
for (var i = 0; i < which.childNodes.length; i++) {
which.removeChild(which.lastChild);
}
}
@ -110,31 +101,31 @@ function removeChildren(which)
// invoke a folder selection dialog for choosing the directory of profile storage.
function getProfileDir(folder, showPopup)
{
if(showPopup)
if (showPopup)
folder = chooseFolder("Choose Profile Directory");
//dump("folder = " + folder + "\n");
if(folder != undefined && folder ) {
if (folder != undefined && folder ) {
var folderText = document.getElementById("ProfileDir");
oldText = document.getElementById("deffoldername");
removeChildren(oldText);
// covert the file URL to a native file path.
// only need to do this if we called chooseFolder()
// otherwise, it's already a native file path.
// otherwise, it's already a native file path.
// this can happen when the user goes back and next after
// selecting a folder
if (showPopup) {
try {
var spec = Components.classes["component://netscape/filespec"].createInstance();
spec = spec.QueryInterface(Components.interfaces.nsIFileSpec);
spec.URLString = folder;
folder = spec.nativePath;
}
catch (ex) {
dump("failed to convert URL to native path\n");
}
try {
var spec = Components.classes["component://netscape/filespec"].createInstance();
spec = spec.QueryInterface(Components.interfaces.nsIFileSpec);
spec.URLString = folder;
folder = spec.nativePath;
}
catch (ex) {
dump("failed to convert URL to native path\n");
}
}
folderText.setAttribute("value",folder);
if(!detect) {
if (!detect) {
var useDefault = document.createElement("titledbutton");
useDefault.setAttribute("value",bundle.GetStringFromName("useDefaultFolder"));
useDefault.setAttribute("id","useDefaultButton");
@ -155,7 +146,7 @@ function UseDefaultFolder()
var ProfileDir = document.getElementById("ProfileDir");
ProfileDir.setAttribute("value","");
var FolderButtons = document.getElementById("folderbuttons");
if(FolderButtons.childNodes.length > 1)
if (FolderButtons.childNodes.length > 1)
FolderButtons.removeChild(FolderButtons.lastChild);
var span = document.getElementById("deffoldername")
var text = document.createTextNode(bundle.GetStringFromName("defaultString"));
@ -165,5 +156,5 @@ function UseDefaultFolder()
//resize the parent window, because switching to use the default
//may require a window resize.
//comment this out for now, see bug #15825
//parent.sizeToContent();
//parent.sizeToContent();
}

Просмотреть файл

@ -1,4 +1,5 @@
/*
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
@ -17,167 +18,162 @@
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
*/
*/
var selected = null;
var currProfile = "";
var profile = Components.classes["component://netscape/profile/manager"].createInstance();
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
//dump("profile = " + profile + "\n");
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
//dump("profile = " + profile + "\n");
function openCreateProfile()
{
// Need to call CreateNewProfile xuls
window.openDialog('chrome://profile/content/createProfileWizard.xul', 'CPW', 'chrome');
// Need to call CreateNewProfile xuls
window.openDialog('chrome://profile/content/createProfileWizard.xul', 'CPW', 'chrome');
}
function CreateProfile()
{
this.location.href = "chrome://profile/content/profileManager.xul";
this.location.href = "chrome://profile/content/profileManager.xul";
}
function RenameProfile(w)
{
renameButton = document.getElementById("rename");
if (renameButton.getAttribute("disabled") == "true") {
return;
}
if (!selected)
{
alert("Select a profile to rename.");
return;
}
renameButton = document.getElementById("rename");
if (renameButton.getAttribute("disabled") == "true") {
return;
}
if (!selected) {
alert("Select a profile to rename.");
return;
}
var newName = w.document.getElementById("NewName").value;
var oldName = selected.getAttribute("rowName");
var migrate = selected.getAttribute("rowMigrate");
var newName = w.document.getElementById("NewName").value;
var oldName = selected.getAttribute("rowName");
var migrate = selected.getAttribute("rowMigrate");
if (migrate == "true")
{
alert("Migrate this profile before renaming it.");
return;
}
if (migrate == "true") {
alert("Migrate this profile before renaming it.");
return;
}
//dump("RenameProfile : " + oldName + " to " + newName + "\n");
try {
profile.renameProfile(oldName, newName);
}
catch (ex) {
alert("Sorry, failed to rename profile.");
}
//this.location.replace(this.location);
this.location.href = "chrome://profile/content/profileManager.xul";
//dump("RenameProfile : " + oldName + " to " + newName + "\n");
try {
profile.renameProfile(oldName, newName);
}
catch (ex) {
alert("Sorry, failed to rename profile.");
}
//this.location.replace(this.location);
this.location.href = "chrome://profile/content/profileManager.xul";
}
function DeleteProfile(deleteFiles)
{
deleteButton = document.getElementById("delete");
if (deleteButton.getAttribute("disabled") == "true") {
return;
}
if (!selected)
{
alert("Select a profile to delete.");
return;
}
deleteButton = document.getElementById("delete");
if (deleteButton.getAttribute("disabled") == "true") {
return;
}
if (!selected) {
alert("Select a profile to delete.");
return;
}
var migrate = selected.getAttribute("rowMigrate");
var migrate = selected.getAttribute("rowMigrate");
var name = selected.getAttribute("rowName");
//dump("Delete '" + name + "'\n");
try {
profile.deleteProfile(name, deleteFiles);
}
catch (ex) {
alert("Sorry, failed to delete profile.");
}
//this.location.replace(this.location);
//this.location.href = this.location;
this.location.href = "chrome://profile/content/profileManager.xul";
var name = selected.getAttribute("rowName");
//dump("Delete '" + name + "'\n");
try {
profile.deleteProfile(name, deleteFiles);
}
catch (ex) {
alert("Sorry, failed to delete profile.");
}
//this.location.replace(this.location);
//this.location.href = this.location;
this.location.href = "chrome://profile/content/profileManager.xul";
}
function onStart()
{
//dump("************Inside Start Communicator prof\n");
startButton = document.getElementById("start");
if (startButton.getAttribute("disabled") == "true") {
return;
}
if (!selected)
{
alert("Select a profile to start.");
return;
}
//dump("************Inside Start Communicator prof\n");
startButton = document.getElementById("start");
if (startButton.getAttribute("disabled") == "true") {
return;
}
if (!selected) {
alert("Select a profile to start.");
return;
}
var migrate = selected.getAttribute("rowMigrate");
var name = selected.getAttribute("rowName");
var migrate = selected.getAttribute("rowMigrate");
var name = selected.getAttribute("rowName");
if (migrate == "true")
{
// pass true for show progress as modal window
profile.migrateProfile(name, true);
}
if (migrate == "true") {
// pass true for show progress as modal window
profile.migrateProfile(name, true);
}
//dump("************name: "+name+"\n");
try {
profile.startApprunner(name);
ExitApp();
}
catch (ex) {
alert("Failed to start communicator with the " + name + " profile.");
}
//dump("************name: "+name+"\n");
try {
profile.startApprunner(name);
ExitApp();
}
catch (ex) {
alert("Failed to start communicator with the " + name + " profile.");
}
}
function onExit()
{
try {
profile.forgetCurrentProfile();
}
catch (ex) {
//dump("Failed to forget current profile.\n");
}
ExitApp();
try {
profile.forgetCurrentProfile();
}
catch (ex) {
//dump("Failed to forget current profile.\n");
}
ExitApp();
}
function ExitApp()
{
// Need to call this to stop the event loop
var appShell = Components.classes['component://netscape/appshell/appShellService'].getService();
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
appShell.Quit();
// Need to call this to stop the event loop
var appShell = Components.classes['component://netscape/appshell/appShellService'].getService();
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
appShell.Quit();
}
function setButtonsDisabledState(state)
{
startButton = document.getElementById("start");
deleteButton = document.getElementById("delete");
renameButton = document.getElementById("rename");
startButton = document.getElementById("start");
deleteButton = document.getElementById("delete");
renameButton = document.getElementById("rename");
deleteButton.setAttribute("disabled", state);
renameButton.setAttribute("disabled", state);
startButton.setAttribute("disabled", state);
deleteButton.setAttribute("disabled", state);
renameButton.setAttribute("disabled", state);
startButton.setAttribute("disabled", state);
}
function showSelection(node)
{
//dump("************** In showSelection routine!!!!!!!!! \n");
// (see tree's onclick definition)
// Tree events originate in the smallest clickable object which is the cell. The object
// originating the event is available as event.target. We want the cell's row, so we go
// one further and get event.target.parentNode.
selected = node;
var num = node.getAttribute("rowNum");
//dump("num: "+num+"\n");
//dump("************** In showSelection routine!!!!!!!!! \n");
// (see tree's onclick definition)
// Tree events originate in the smallest clickable object which is the cell. The object
// originating the event is available as event.target. We want the cell's row, so we go
// one further and get event.target.parentNode.
selected = node;
var num = node.getAttribute("rowNum");
//dump("num: "+num+"\n");
var name = node.getAttribute("rowName");
//dump("name: "+name+"\n");
var name = node.getAttribute("rowName");
//dump("name: "+name+"\n");
//dump("Selected " + num + " : " + name + "\n");
//dump("Selected " + num + " : " + name + "\n");
// turn on all the buttons that should be on
// when something is selected.
setButtonsDisabledState("false");
// turn on all the buttons that should be on
// when something is selected.
setButtonsDisabledState("false");
}
function addTreeItem(num, name, migrate)
@ -195,10 +191,10 @@ function addTreeItem(num, name, migrate)
// Hack in a differentation for migration
if (migrate) {
var text = document.createTextNode('Migrate');
var text = document.createTextNode('Migrate');
}
else {
var text = document.createTextNode('');
var text = document.createTextNode('');
}
elem.appendChild(text);
@ -215,78 +211,74 @@ function addTreeItem(num, name, migrate)
function loadElements()
{
//dump("****************hacked onload handler adds elements to tree widget\n");
var profileList = "";
//dump("****************hacked onload handler adds elements to tree widget\n");
var profileList = "";
profileList = profile.getProfileList();
profileList = profile.getProfileList();
//dump("Got profile list of '" + profileList + "'\n");
profileList = profileList.split(",");
try {
currProfile = profile.currentProfile;
}
catch (ex) {
if (profileList != "") {
currProfile = profileList;
}
}
//dump("Got profile list of '" + profileList + "'\n");
profileList = profileList.split(",");
try {
currProfile = profile.currentProfile;
}
catch (ex) {
if (profileList != "") {
currProfile = profileList;
}
}
for (var i=0; i < profileList.length; i++)
{
var pvals = profileList[i].split(" - ");
addTreeItem(i, pvals[0], (pvals[1] == "migrate"));
}
for (var i=0; i < profileList.length; i++) {
var pvals = profileList[i].split(" - ");
addTreeItem(i, pvals[0], (pvals[1] == "migrate"));
}
}
function openRename()
{
renameButton = document.getElementById("rename");
if (renameButton.getAttribute("disabled") == "true") {
return;
}
if (!selected) {
alert("Select a profile to rename.");
}
else
{
var migrate = selected.getAttribute("rowMigrate");
if (migrate == "true") {
alert("Migrate the profile before renaming it.");
}
else
var win = window.openDialog('chrome://profile/content/renameProfile.xul', 'Renamer', 'chrome');
}
renameButton = document.getElementById("rename");
if (renameButton.getAttribute("disabled") == "true") {
return;
}
if (!selected) {
alert("Select a profile to rename.");
}
else {
var migrate = selected.getAttribute("rowMigrate");
if (migrate == "true") {
alert("Migrate the profile before renaming it.");
}
else
window.openDialog('chrome://profile/content/renameProfile.xul', 'Renamer', 'chrome');
}
}
function ConfirmDelete()
function ConfirmDelete()
{
deleteButton = document.getElementById("delete");
if (deleteButton.getAttribute("disabled") == "true") {
return;
}
if (!selected)
{
alert("Select a profile to delete.");
return;
}
deleteButton = document.getElementById("delete");
if (deleteButton.getAttribute("disabled") == "true") {
return;
}
if (!selected) {
alert("Select a profile to delete.");
return;
}
var migrate = selected.getAttribute("rowMigrate");
var name = selected.getAttribute("rowName");
var migrate = selected.getAttribute("rowMigrate");
var name = selected.getAttribute("rowName");
if (migrate == "true")
{
alert("Migrate this profile before deleting it.");
return;
}
if (migrate == "true") {
alert("Migrate this profile before deleting it.");
return;
}
var win = window.openDialog('chrome://profile/content/deleteProfile.xul', 'Deleter', 'chrome');
return win;
var win = window.openDialog('chrome://profile/content/deleteProfile.xul', 'Deleter', 'chrome');
return win;
}
function ConfirmMigrateAll()
function ConfirmMigrateAll()
{
var win = window.openDialog('chrome://profile/content/profileManagerMigrateAll.xul', 'MigrateAll', 'chrome');
return win;
var win = window.openDialog('chrome://profile/content/profileManagerMigrateAll.xul', 'MigrateAll', 'chrome');
return win;
}

Просмотреть файл

@ -1,23 +1,24 @@
/*
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
* Contributor(s):
* Ben Goodger (28/10/99)
* Seth Spitzer (28/10/99)
*/
@ -25,8 +26,8 @@
var selected = null;
var currProfile = "";
var profile = Components.classes["component://netscape/profile/manager"].createInstance();
if(profile)
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
if (profile)
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
var bundle = null;
var unset = true;
@ -62,70 +63,69 @@ function AddItem(aChildren,aCells,aIdfier)
// purpose : load profiles into tree
function loadElements()
{
var profileList = "";
profileList = profile.getProfileList();
profileList = profileList.split(",");
var profileList = "";
profileList = profile.getProfileList();
profileList = profileList.split(",");
try {
currProfile = profile.currentProfile;
}
try {
currProfile = profile.currentProfile;
}
catch (ex) {
if (profileList != "")
currProfile = profileList;
}
if (profileList != "")
currProfile = profileList;
}
for (var i = 0; i < profileList.length; i++)
{
var pvals = profileList[i].split(" - ");
// only add profiles that have been migrated
if (pvals[1] != "migrate") {
AddItem("profilekids",pvals[0],pvals[0]);
}
}
for (var i = 0; i < profileList.length; i++) {
var pvals = profileList[i].split(" - ");
// only add profiles that have been migrated
if (pvals[1] != "migrate") {
AddItem("profilekids",pvals[0],pvals[0]);
}
}
}
// function : <profileSelection.js>::onStart();
// purpose : starts mozilla given the selected profile (user choice: "Start Mozilla")
function onStart()
{
startButton = document.getElementById("start");
if (startButton.getAttribute("disabled") == "true")
startButton = document.getElementById("start");
if (startButton.getAttribute("disabled") == "true")
return;
if(!selected)
if (!selected)
return;
var profilename = selected.getAttribute("profile_name");
try {
dump("start with profile: " + profilename + "\n");
profile.startApprunner(profilename);
ExitApp();
}
catch (ex) {
var profilename = selected.getAttribute("profile_name");
try {
dump("start with profile: " + profilename + "\n");
profile.startApprunner(profilename);
ExitApp();
}
catch (ex) {
var stringA = bundle.GetStringFromName(failProfileStartA);
var stringB = bundle.GetStringFromName(failProfileStartB);
alert(stringA + " " + profilename + " " + stringB);
}
alert(stringA + " " + profilename + " " + stringB);
}
}
// function : <profileSelection.js>::onExit();
// purpose : quits startup process (User Choice: "Exit")
function onExit()
{
try {
profile.forgetCurrentProfile();
}
catch (ex) {
dump("Failed to forget current profile.\n");
try {
profile.forgetCurrentProfile();
}
ExitApp();
catch (ex) {
dump("Failed to forget current profile.\n");
}
ExitApp();
}
// function : <profileSelection.js>::ExitApp();
// purpose : halts startup process forcefully
function ExitApp()
{
// Need to call this to stop the event loop
// Need to call this to stop the event loop
var appShell = Components.classes['component://netscape/appshell/appShellService'].getService();
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
appShell.Quit();
@ -135,30 +135,30 @@ function ExitApp()
// purpose : sets the enabling of buttons
function setButtonsDisabledState(state)
{
startButton = document.getElementById("start");
startButton.setAttribute("disabled", state);
startButton = document.getElementById("start");
startButton.setAttribute("disabled", state);
}
// function : <profileSelection.js>::showSelection();
// purpose : selects the profile and enables the start button
function showSelection(node)
{
// (see tree's onclick definition)
// Tree events originate in the smallest clickable object which is the cell. The object
// originating the event is available as event.target.
// We want the item in the
// cell's row, so we got passed event.target.parentNode.parentNode
selected = node;
// (see tree's onclick definition)
// Tree events originate in the smallest clickable object which is the cell. The object
// originating the event is available as event.target.
// We want the item in the
// cell's row, so we got passed event.target.parentNode.parentNode
selected = node;
var tree = document.getElementById("profiles");
if(tree.selectedItems.length > 0)
setButtonsDisabledState("false");
if (tree.selectedItems.length > 0)
setButtonsDisabledState("false");
}
// function : <profileSelection.js>::startWithProfile();
// purpose : starts mozilla with selected profile automatically on dblclick
function startWithProfile(node)
{
selected = node;
selected = node;
onStart();
}
@ -171,8 +171,8 @@ function foo()
{
var welcome = document.getElementById("welcometo");
var mozilla = document.getElementById("mozilla");
if(welcome.hasChildNodes() && mozilla.hasChildNodes()) {
if(unset) {
if (welcome.hasChildNodes() && mozilla.hasChildNodes()) {
if (unset) {
oldA = welcome.lastChild.nodeValue;
oldB = mozilla.lastChild.nodeValue;
welcome.removeChild(welcome.lastChild)