зеркало из https://github.com/mozilla/pjs.git
comment out the dumps.
in the new profile xul, disable the buttons when they should be and ignore clicks if the buttons are disabled.
This commit is contained in:
Родитель
483bbf56be
Коммит
71a803fb46
|
@ -4,8 +4,8 @@ var wizardHash = new Array;
|
|||
var firstTime = true;
|
||||
|
||||
var testMap = {
|
||||
content1_1: { next: "content1_2" },
|
||||
content1_2: { previous: "content1_1" },
|
||||
content1_1: { previous: null, next: "content1_2" },
|
||||
content1_2: { previous: "content1_1" , next: null},
|
||||
}
|
||||
|
||||
var pagePrefix="test-";
|
||||
|
@ -20,18 +20,21 @@ var profDir = "";
|
|||
var isProfileData = false;
|
||||
|
||||
function wizardPageLoaded(tag) {
|
||||
dump("**********wizardPageLoaded\n");
|
||||
//dump("**********wizardPageLoaded\n");
|
||||
|
||||
if (firstTime) {
|
||||
Startup();
|
||||
}
|
||||
|
||||
currentPageTag = tag;
|
||||
dump("currentPageTag: "+currentPageTag+"\n");
|
||||
|
||||
currentPageTag = tag;
|
||||
//dump("currentPageTag: "+currentPageTag+"\n");
|
||||
SetButtons();
|
||||
populatePage();
|
||||
}
|
||||
|
||||
var backButton = null;
|
||||
var nextButton = null;
|
||||
var finishButton = null;
|
||||
|
||||
function loadPage(thePage)
|
||||
{
|
||||
|
@ -39,19 +42,57 @@ function loadPage(thePage)
|
|||
saveData();
|
||||
}
|
||||
|
||||
dump("**********loadPage\n");
|
||||
dump("thePage: "+thePage+"\n");
|
||||
//dump("**********loadPage\n");
|
||||
//dump("thePage: "+thePage+"\n");
|
||||
displayPage(thePage);
|
||||
|
||||
firstTime = false;
|
||||
return(true);
|
||||
}
|
||||
|
||||
function SetButtons()
|
||||
{
|
||||
if (!currentPageTag) return;
|
||||
|
||||
if (!backButton) {
|
||||
backButton = document.getElementById("back");
|
||||
}
|
||||
if (!nextButton) {
|
||||
nextButton = document.getElementById("next");
|
||||
}
|
||||
if (!finishButton) {
|
||||
finishButton = document.getElementById("finish");
|
||||
}
|
||||
|
||||
//dump("currentPageTag == " + currentPageTag + "\n");
|
||||
nextTag = testMap[currentPageTag].next;
|
||||
//dump("nextTag == " + nextTag + "\n");
|
||||
if (nextTag) {
|
||||
nextButton.setAttribute("disabled", false);
|
||||
finishButton.setAttribute("disabled", true);
|
||||
}
|
||||
else {
|
||||
nextButton.setAttribute("disabled", true);
|
||||
finishButton.setAttribute("disabled", false);
|
||||
}
|
||||
|
||||
prevTag = testMap[currentPageTag].previous;
|
||||
//dump("prevTag == " + prevTag + "\n");
|
||||
if (prevTag) {
|
||||
backButton.setAttribute("disabled", false);
|
||||
}
|
||||
else {
|
||||
backButton.setAttribute("disabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
function onNext()
|
||||
{
|
||||
dump("***********onNext\n");
|
||||
if (nextButton.getAttribute("disabled") == "true") {
|
||||
return;
|
||||
}
|
||||
|
||||
//dump("***********onNext\n");
|
||||
|
||||
if (currentPageTag == "content1_1") {
|
||||
isProfileData = true;
|
||||
|
@ -67,7 +108,9 @@ function onNext()
|
|||
|
||||
function onBack()
|
||||
{
|
||||
dump("***********onBack\n");
|
||||
if (backButton.getAttribute("disabled") == "true") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPageTag != "content1_1") {
|
||||
saveData();
|
||||
|
@ -79,7 +122,7 @@ function onBack()
|
|||
|
||||
function displayPage(content)
|
||||
{
|
||||
dump("********INSIDE DISPLAYPAGE\n\n");
|
||||
//dump("********INSIDE DISPLAYPAGE\n\n");
|
||||
|
||||
if (content != "")
|
||||
{
|
||||
|
@ -94,47 +137,47 @@ function displayPage(content)
|
|||
|
||||
function populatePage()
|
||||
{
|
||||
dump("************initializePage\n");
|
||||
//dump("************initializePage\n");
|
||||
var contentWindow = window.frames["content"];
|
||||
var doc = contentWindow.document;
|
||||
|
||||
for (var i in wizardHash) {
|
||||
var formElement=doc.getElementById(i);
|
||||
dump("formElement: "+formElement+"\n");
|
||||
//dump("formElement: "+formElement+"\n");
|
||||
|
||||
if (formElement) {
|
||||
formElement.value = wizardHash[i];
|
||||
dump("wizardHash["+"i]: "+wizardHash[i]+"\n");
|
||||
//dump("wizardHash["+"i]: "+wizardHash[i]+"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveData()
|
||||
{
|
||||
dump("************ SAVE DATA\n");
|
||||
//dump("************ SAVE DATA\n");
|
||||
|
||||
var contentWindow = window.frames["content"];
|
||||
var doc = contentWindow.document;
|
||||
|
||||
var inputs = doc.getElementsByTagName("FORM")[0].elements;
|
||||
|
||||
dump("There are " + inputs.length + " input tags\n");
|
||||
//dump("There are " + inputs.length + " input tags\n");
|
||||
for (var i=0 ; i<inputs.length; i++) {
|
||||
dump("Saving: ");
|
||||
dump("ID=" + inputs[i].id + " Value=" + inputs[i].value + "..");
|
||||
//dump("Saving: ");
|
||||
//dump("ID=" + inputs[i].id + " Value=" + inputs[i].value + "..");
|
||||
wizardHash[inputs[i].id] = inputs[i].value;
|
||||
}
|
||||
dump("done.\n");
|
||||
//dump("done.\n");
|
||||
}
|
||||
|
||||
function onCancel()
|
||||
{
|
||||
dump("************** ON CANCEL\n");
|
||||
//dump("************** ON CANCEL\n");
|
||||
saveData();
|
||||
var i;
|
||||
for (i in wizardHash) {
|
||||
dump("element: "+i+"\n");
|
||||
dump("value: "+wizardHash[i]+"\n");
|
||||
//dump("element: "+i+"\n");
|
||||
//dump("value: "+wizardHash[i]+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,13 +190,16 @@ function getUrlFromTag(title)
|
|||
|
||||
function Startup()
|
||||
{
|
||||
dump("Doing Startup...\n");
|
||||
//dump("Doing Startup...\n");
|
||||
}
|
||||
|
||||
function Finish(opener)
|
||||
{
|
||||
|
||||
dump("******FINISH ROUTINE\n");
|
||||
if (finishButton.getAttribute("disabled") == "true") {
|
||||
return;
|
||||
}
|
||||
|
||||
//dump("******FINISH ROUTINE\n");
|
||||
|
||||
if (isProfileData) {
|
||||
saveData();
|
||||
|
@ -173,14 +219,14 @@ function processCreateProfileData()
|
|||
{
|
||||
//Process Create Profile Data
|
||||
|
||||
dump("******processCreateProfileData ROUTINE\n");
|
||||
//dump("******processCreateProfileData ROUTINE\n");
|
||||
|
||||
var i;
|
||||
var data = "";
|
||||
|
||||
for (i in wizardHash) {
|
||||
dump("element: "+i+"\n");
|
||||
dump("value: "+wizardHash[i]+"\n");
|
||||
//dump("element: "+i+"\n");
|
||||
//dump("value: "+wizardHash[i]+"\n");
|
||||
|
||||
if (i == "ProfileName") {
|
||||
profName = wizardHash[i];
|
||||
|
@ -193,14 +239,19 @@ function processCreateProfileData()
|
|||
}
|
||||
}
|
||||
|
||||
dump("data: "+data+"\n");
|
||||
//dump("data: "+data+"\n");
|
||||
var profile = Components.classes["component://netscape/profile/manager"].createInstance();
|
||||
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
|
||||
dump("profile = " + profile + "\n");
|
||||
|
||||
dump("********DATA: "+data+"\n\n");
|
||||
profile.createNewProfile(data);
|
||||
profile.startCommunicator(profName);
|
||||
//dump("profile = " + profile + "\n");
|
||||
//dump("********DATA: "+data+"\n\n");
|
||||
try {
|
||||
profile.createNewProfile(data);
|
||||
profile.startCommunicator(profName);
|
||||
}
|
||||
catch (ex) {
|
||||
//dump("failed to create & start\n");
|
||||
return;
|
||||
}
|
||||
ExitApp();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
|
||||
<?xml-stylesheet href="cpw.css" type="text/css"?>
|
||||
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://profile/locale/en-US/cpw.dtd" >
|
||||
|
||||
<window title="&window.title.label;" style="width: 100%; height: 100%" align="vertical"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="loadPage('test-content1_1.xul')"
|
||||
width="500" height="400">
|
||||
|
||||
<html:script src="cpw.js" />
|
||||
|
||||
<tabcontrol align="vertical">
|
||||
<tabbox align="horizontal">
|
||||
<tab onclick="loadPage('test-content1_1.xul');">&newprofile.title;</tab>
|
||||
</tabbox>
|
||||
|
||||
<tabpanel />
|
||||
</tabcontrol>
|
||||
|
||||
<html:iframe src="about:blank" flex="100%" name="content" id="content" scrolling="auto"/>
|
||||
|
||||
<box align="horizontal">
|
||||
<titledbutton id="back" value="&back.label;" onclick="onBack()" align="left" style="margin-top: 1em;"/>
|
||||
<titledbutton id="next" value="&next.label;" onclick="onNext()" align="left" style="margin-top: 1em;"/>
|
||||
<titledbutton id="cancel" value="&cancel.label;" onclick="cancelApp()" align="left" style=" margin-top: 1em;"/>
|
||||
<titledbutton id="finish" value="&finish.label;" onclick="Finish(opener)" align="left" style=" margin-top: 1em;"/>
|
||||
|
||||
</box>
|
||||
|
||||
|
||||
</window>
|
|
@ -1,210 +0,0 @@
|
|||
var selected = null;
|
||||
var currProfile = "";
|
||||
var profile = Components.classes["component://netscape/profile/manager"].createInstance();
|
||||
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
|
||||
dump("profile = " + profile + "\n");
|
||||
|
||||
function openCreateProfile()
|
||||
{
|
||||
// Need to call CreateNewProfile xuls
|
||||
var win = window.openDialog('cpw.xul', 'CPW', 'chrome');
|
||||
return win;
|
||||
}
|
||||
|
||||
function CreateProfile()
|
||||
{
|
||||
this.location.href = "resource:/res/profile/pm.xul";
|
||||
}
|
||||
|
||||
function RenameProfile(w)
|
||||
{
|
||||
if (!selected)
|
||||
{
|
||||
dump("Select a profile to rename.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var newName = w.document.getElementById("NewName").value;
|
||||
var oldName = selected.getAttribute("rowName");
|
||||
var migrate = selected.getAttribute("rowMigrate");
|
||||
|
||||
if (migrate == "true")
|
||||
{
|
||||
dump("Migrate this profile before renaming it.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//dump("RenameProfile : " + oldName + " to " + newName + "\n");
|
||||
profile.RenameProfile(oldName, newName);
|
||||
//this.location.replace(this.location);
|
||||
this.location.href = "resource:/res/profile/pm.xul";
|
||||
}
|
||||
|
||||
function DeleteProfile(deleteFilesFlag)
|
||||
{
|
||||
if (!selected)
|
||||
{
|
||||
dump("Select a profile to delete.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var migrate = selected.getAttribute("rowMigrate");
|
||||
|
||||
var name = selected.getAttribute("rowName");
|
||||
//dump("Delete '" + name + "'\n");
|
||||
profile.DeleteProfile(name, deleteFilesFlag);
|
||||
//this.location.replace(this.location);
|
||||
//this.location.href = this.location;
|
||||
this.location.href = "resource:/res/profile/pm.xul";
|
||||
}
|
||||
|
||||
function StartCommunicator()
|
||||
{
|
||||
dump("************Inside Start Communicator prof\n");
|
||||
if (!selected)
|
||||
{
|
||||
dump("Select a profile to migrate.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var migrate = selected.getAttribute("rowMigrate");
|
||||
var name = selected.getAttribute("rowName");
|
||||
|
||||
if (migrate == "true")
|
||||
{
|
||||
profile.migrateProfile(name);
|
||||
}
|
||||
|
||||
dump("************name: "+name+"\n");
|
||||
profile.startCommunicator(name);
|
||||
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();
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
var name = node.getAttribute("rowName");
|
||||
dump("name: "+name+"\n");
|
||||
|
||||
//dump("Selected " + num + " : " + name + "\n");
|
||||
}
|
||||
|
||||
function addTreeItem(num, name, migrate)
|
||||
{
|
||||
dump("Adding element " + num + " : " + name + "\n");
|
||||
var body = document.getElementById("theTreeBody");
|
||||
|
||||
var newitem = document.createElement('treeitem');
|
||||
var newrow = document.createElement('treerow');
|
||||
newrow.setAttribute("rowNum", num);
|
||||
newrow.setAttribute("rowName", name);
|
||||
newrow.setAttribute("rowMigrate", migrate);
|
||||
|
||||
var elem = document.createElement('treecell');
|
||||
|
||||
// Hack in a differentation for migration
|
||||
if (migrate)
|
||||
var text = document.createTextNode('Migrate');
|
||||
else
|
||||
var text = document.createTextNode('');
|
||||
|
||||
elem.appendChild(text);
|
||||
newrow.appendChild(elem);
|
||||
|
||||
var elem = document.createElement('treecell');
|
||||
var text = document.createTextNode(name);
|
||||
elem.appendChild(text);
|
||||
newrow.appendChild(elem);
|
||||
|
||||
newitem.appendChild(newrow);
|
||||
body.appendChild(newitem);
|
||||
}
|
||||
|
||||
function loadElements()
|
||||
{
|
||||
dump("****************hacked onload handler adds elements to tree widget\n");
|
||||
var profileList = "";
|
||||
|
||||
profileList = profile.getProfileList();
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
function openRename()
|
||||
{
|
||||
if (!selected)
|
||||
dump("Select a profile to rename.\n");
|
||||
else
|
||||
{
|
||||
var migrate = selected.getAttribute("rowMigrate");
|
||||
if (migrate == "true")
|
||||
dump("Migrate the profile before renaming it.\n");
|
||||
else
|
||||
var win = window.openDialog('pmrename.xul', 'Renamer', 'chrome');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ConfirmDelete()
|
||||
{
|
||||
if (!selected)
|
||||
{
|
||||
dump("Select a profile to delete.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var migrate = selected.getAttribute("rowMigrate");
|
||||
var name = selected.getAttribute("rowName");
|
||||
|
||||
if (migrate == "true")
|
||||
{
|
||||
dump("Migrate this profile before deleting it.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var win = window.openDialog('pmDelete.xul', 'Deleter', 'chrome');
|
||||
return win;
|
||||
}
|
||||
|
||||
|
||||
function ConfirmMigrateAll()
|
||||
{
|
||||
var win = window.openDialog('pmMigrateAll.xul', 'MigrateAll', 'chrome');
|
||||
return win;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------- begin Hack for OnLoad handling
|
||||
setTimeout('loadElements()', 0);
|
||||
// -------------------------------------------- end Hack for OnLoad handling
|
Загрузка…
Ссылка в новой задаче