CCK only - not built Rewrite prefs interface so it is more userfriendly. git-svn-id: svn://10.0.0.236/trunk@195261 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
c1ceeaea2f
commit
bab76f68b3
@ -52,6 +52,8 @@ INSTALL_EXTENSION_ID = cckwizard@extensions.mozilla.org
|
||||
XPI_PKGNAME = cckwizard-$(MOZ_APP_VERSION)
|
||||
endif
|
||||
|
||||
EXTRA_COMPONENTS=../prefAutoCompleteService.js
|
||||
|
||||
ALL_LOCALES = \
|
||||
en-US \
|
||||
$(NULL)
|
||||
|
||||
@ -5,7 +5,7 @@ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<em:id>cckwizard@extensions.mozilla.org</em:id>
|
||||
<em:name>CCK Wizard</em:name>
|
||||
<em:version>0.9.6</em:version>
|
||||
<em:version>0.9.7</em:version>
|
||||
<em:description>XUL Wizard to create CCK Packages</em:description>
|
||||
<em:creator>Michael Kaply</em:creator>
|
||||
<em:homepageURL>http://www.mozilla.org/projects/cck/firefox</em:homepageURL>
|
||||
@ -15,7 +15,7 @@ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>1.5</em:minVersion>
|
||||
<em:maxVersion>1.6.*</em:maxVersion>
|
||||
<em:maxVersion>3.*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
|
||||
@ -146,7 +146,6 @@
|
||||
<!ENTITY customizePrefs.label "Customize Preferences">
|
||||
<!ENTITY customizePrefs.description "Use the buttons below to add default preferences.">
|
||||
<!ENTITY prefs.label "Preferences">
|
||||
<!ENTITY prefs.description "Note these preferences are stored exactly as written, so put quotes around string preferences.">
|
||||
|
||||
<!ENTITY prefName.label "Preference Name:">
|
||||
<!ENTITY prefValue.label "Value: ">
|
||||
|
||||
@ -3,3 +3,6 @@ deleteConfirm=Are you sure you want to delete this configuration?
|
||||
outputLocation=Firefox CCK Wizard is completed. XPI is available at:\n
|
||||
cancelConfirm=Do you want to save your changes?
|
||||
zipError=Unable to create JAR or XPI file. Please ensure that a command line version of ZIP is in your path or that you have specified a path to ZIP.
|
||||
intError=The value must be an integer
|
||||
lockError=You cannot set this value here, you can only lock it.
|
||||
prefExistsError=This preference already exists in the list.
|
||||
|
||||
@ -37,8 +37,9 @@ var currentconfigname;
|
||||
var currentconfigpath;
|
||||
var configarray = new Array();
|
||||
|
||||
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
||||
var gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
.getService(nsIPrefBranch);
|
||||
|
||||
var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
@ -341,10 +342,20 @@ function OnPrefLoad()
|
||||
{
|
||||
listbox = this.opener.document.getElementById('prefList');
|
||||
if (window.name == 'editpref') {
|
||||
window.title = listbox.selectedItem.cck['type'];
|
||||
if (listbox.selectedItem.cck['type'] == "integer") {
|
||||
document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_INT;
|
||||
}
|
||||
document.getElementById('prefname').value = listbox.selectedItem.label;
|
||||
document.getElementById('prefvalue').value = listbox.selectedItem.value;
|
||||
document.getElementById('prefname').disabled = true;
|
||||
if (listbox.selectedItem.cck['lock'] == "true")
|
||||
document.getElementById('lockPref').checked = true;
|
||||
if (listbox.selectedItem.cck['type'] == "boolean") {
|
||||
document.getElementById('prefvalue').hidden = true;
|
||||
document.getElementById('prefvalueboolean').hidden = false;
|
||||
document.getElementById('prefvalueboolean').value = listbox.selectedItem.value;
|
||||
}
|
||||
}
|
||||
prefCheckOKButton();
|
||||
|
||||
@ -359,23 +370,102 @@ function prefCheckOKButton()
|
||||
}
|
||||
}
|
||||
|
||||
function prefSetPrefValue()
|
||||
{
|
||||
var prefname = document.getElementById('prefname').value;
|
||||
try {
|
||||
var preftype = gPrefBranch.getPrefType(prefname);
|
||||
switch (preftype) {
|
||||
case nsIPrefBranch.PREF_STRING:
|
||||
document.getElementById('prefvalue').value = gPrefBranch.getCharPref(prefname);
|
||||
document.getElementById('prefvalue').hidden = false;
|
||||
document.getElementById('prefvalueboolean').hidden = true;
|
||||
document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_STRING;
|
||||
break;
|
||||
case nsIPrefBranch.PREF_INT:
|
||||
document.getElementById('prefvalue').value = gPrefBranch.getIntPref(prefname);
|
||||
document.getElementById('prefvalue').hidden = false;
|
||||
document.getElementById('prefvalueboolean').hidden = true;
|
||||
document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_INT;
|
||||
break;
|
||||
case nsIPrefBranch.PREF_BOOL:
|
||||
document.getElementById('prefvalue').value = gPrefBranch.getBoolPref(prefname);
|
||||
document.getElementById('prefvalue').hidden = true;
|
||||
document.getElementById('prefvalueboolean').hidden = false;
|
||||
document.getElementById('prefvalueboolean').value = gPrefBranch.getBoolPref(prefname);
|
||||
document.getElementById('prefvalue').preftype = nsIPrefBranch.PREF_BOOL;
|
||||
break;
|
||||
default:
|
||||
document.getElementById('prefvalue').hidden = false;
|
||||
document.getElementById('prefvalueboolean').hidden = true;
|
||||
break;
|
||||
}
|
||||
} catch (ex) {
|
||||
document.getElementById('prefvalue').hidden = false;
|
||||
document.getElementById('prefvalueboolean').hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function OnPrefOK()
|
||||
{
|
||||
var bundle = this.opener.document.getElementById("bundle_cckwizard");
|
||||
|
||||
listbox = this.opener.document.getElementById("prefList");
|
||||
for (var i=0; i < listbox.getRowCount(); i++) {
|
||||
if (document.getElementById('prefvalue').value == listbox.getItemAtIndex(i).value) {
|
||||
gPromptService.alert(window, bundle.getString("windowTitle"),
|
||||
bundle.getString("prefExistsError"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (((document.getElementById('prefname').value == "browser.startup.homepage") || (document.getElementById('prefname').value == "browser.throbber.url")) &&
|
||||
(document.getElementById('prefvalue').value.length > 0)) {
|
||||
gPromptService.alert(window, "",
|
||||
"You cannot set this value here, you can only lock it.");
|
||||
gPromptService.alert(window, bundle.getString("windowTitle"),
|
||||
bundle.getString("lockError"));
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = document.getElementById('prefvalue').value;
|
||||
|
||||
if (document.getElementById('prefvalue').preftype == nsIPrefBranch.PREF_INT) {
|
||||
if (parseInt(value) != value) {
|
||||
gPromptService.alert(window, bundle.getString("windowTitle"),
|
||||
bundle.getString("intError"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
listbox = this.opener.document.getElementById('prefList');
|
||||
var listitem;
|
||||
if (window.name == 'newpref') {
|
||||
listitem = listbox.appendItem(document.getElementById('prefname').value, document.getElementById('prefvalue').value);
|
||||
var preftype;
|
||||
if ((value.toLowerCase() == "true") || (value.toLowerCase() == "false")) {
|
||||
preftype = "boolean";
|
||||
} else if (parseInt(value) == value) {
|
||||
preftype = "integer";
|
||||
} else {
|
||||
preftype = "string";
|
||||
if (value.charAt(0) == '"')
|
||||
value = value.substring(1,value.length);
|
||||
if (value.charAt(value.length-1) == '"')
|
||||
if (value.charAt(value.length-2) != '\\')
|
||||
value = value.substring(0,value.length-1);
|
||||
}
|
||||
listitem = listbox.appendItem(document.getElementById('prefname').value, value);
|
||||
listitem.cck['type'] = preftype;
|
||||
} else {
|
||||
listitem = listbox.selectedItem;
|
||||
listitem.label = document.getElementById('prefname').value;
|
||||
listitem.value = document.getElementById('prefvalue').value;
|
||||
value = document.getElementById('prefvalue').value;
|
||||
if (value.charAt(0) == '"')
|
||||
value = value.substring(1,value.length);
|
||||
if (value.charAt(value.length-1) == '"')
|
||||
if (value.charAt(value.length-2) != '\\')
|
||||
value = value.substring(0,value.length-1);
|
||||
listitem.value = value;
|
||||
}
|
||||
if (document.getElementById('lockPref').checked) {
|
||||
listitem.cck['lock'] = "true";
|
||||
@ -1470,13 +1560,15 @@ function CCKWriteDefaultJS(destdir)
|
||||
listbox = document.getElementById("prefList");
|
||||
for (var i=0; i < listbox.getRowCount(); i++) {
|
||||
listitem = listbox.getItemAtIndex(i);
|
||||
var listitemvalue = listitem.value;
|
||||
/* allow for locking prefs without setting value */
|
||||
if (listitem.value.length) {
|
||||
if ((listitemvalue == "FALSE") || (listitemvalue == "TRUE")) {
|
||||
listitemvalue = listitemvalue.toLowerCase()
|
||||
var line;
|
||||
/* If it is a string, put quotes around it */
|
||||
if (listitem.cck['type'] == "string") {
|
||||
line = 'pref("' + listitem.label + '", ' + '"' + listitem.value + '"' + ');\n';
|
||||
} else {
|
||||
line = 'pref("' + listitem.label + '", ' + listitem.value + ');\n';
|
||||
}
|
||||
var line = 'pref("' + listitem.label + '", ' + listitemvalue + ');\n';
|
||||
fos.write(line, line.length);
|
||||
}
|
||||
}
|
||||
@ -1804,6 +1896,10 @@ function CCKWriteConfigFile(destdir)
|
||||
var line = "PreferenceValue" + (j+1) + "=" + listitem.value + "\n";
|
||||
fos.write(line, line.length);
|
||||
}
|
||||
if (listitem.cck['type'].length > 0) {
|
||||
var line = "PreferenceType" + (j+1) + "=" + listitem.cck['type'] + "\n";
|
||||
fos.write(line, line.length);
|
||||
}
|
||||
if (listitem.cck['lock'].length > 0) {
|
||||
var line = "PreferenceLock" + (j+1) + "=" + listitem.cck['lock'] + "\n";
|
||||
fos.write(line, line.length);
|
||||
@ -1967,6 +2063,26 @@ function CCKReadConfigFile(srcdir)
|
||||
|
||||
var i = 1;
|
||||
while( prefname = configarray['PreferenceName' + i]) {
|
||||
/* Old config file - figure out pref type */
|
||||
if (!(configarray['PreferenceType' + i])) {
|
||||
/* We're going to use this a lot */
|
||||
value = configarray['PreferenceValue' + i];
|
||||
if ((value.toLowerCase() == "true") || (value.toLowerCase() == "false")) {
|
||||
configarray['PreferenceType' + i] = "boolean";
|
||||
value = value.toLowerCase();
|
||||
} else if (parseInt(value) == value) {
|
||||
configarray['PreferenceType' + i] = "integer";
|
||||
} else {
|
||||
/* Remove opening and closing quotes if they exist */
|
||||
configarray['PreferenceType' + i] = "string";
|
||||
if (value.charAt(0) == '"')
|
||||
value = value.substring(1,value.length);
|
||||
if (value.charAt(value.length-1) == '"')
|
||||
if (value.charAt(value.length-2) != '\\')
|
||||
value = value.substring(0,value.length-1);
|
||||
}
|
||||
configarray['PreferenceValue' + i] = value;
|
||||
}
|
||||
if (configarray['PreferenceValue' + i])
|
||||
listitem = listbox.appendItem(prefname, configarray['PreferenceValue' + i]);
|
||||
else
|
||||
@ -1976,6 +2092,7 @@ function CCKReadConfigFile(srcdir)
|
||||
} else {
|
||||
listitem.cck['lock'] = "";
|
||||
}
|
||||
listitem.cck['type'] = configarray['PreferenceType' + i];
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
@ -54,11 +54,16 @@
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://global/content/dialogOverlay.js" />
|
||||
<vbox>
|
||||
<label>&prefs.description;</label>
|
||||
<label control="prefname">&prefName.label;</label>
|
||||
<textbox flex="1" id="prefname" onchange="prefCheckOKButton();" onkeyup="prefCheckOKButton();"/>
|
||||
<textbox flex="1" id="prefname" onchange="prefCheckOKButton();prefSetPrefValue();" onkeyup="prefCheckOKButton();prefSetPrefValue();" type="autocomplete" autocompletesearch="prefs" ontextentered="prefSetPrefValue();"/>
|
||||
<label control="prefvalue">&prefValue.label;</label>
|
||||
<textbox flex="1" id="prefvalue" onchange="prefCheckOKButton();" onkeyup="prefCheckOKButton();"/>
|
||||
<menulist flex="1" id="prefvalueboolean" hidden="true" oncommand="document.getElementById('prefvalue').value = this.value;">
|
||||
<menupopup>
|
||||
<menuitem label="true" value="true"/>
|
||||
<menuitem label="false" value="false"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<checkbox id="lockPref" label="Lock Preference"/>
|
||||
</vbox>
|
||||
</dialog>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user