options.xul
Summary
An "options" dialog for the Mozile Extension.
Version: 0.7
Author: James A. Overton
<?xml version="1.0" encoding="UTF-8"?>
<!--
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozile/content/core/interface.css" type="text/css"?>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
id="MozilePreferences"
class="mozileInterface"
orient="vertical"
title="Mozile Preferences"
buttons="accept"
flex="1"
onload="this.moveToAlertPosition(); this.sizeToContent(); mozileOptionsInit()"
width="360px">
<script type="application/x-javascript">
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var mozilePrefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch(null);
var mozileEnhancementList = "getClipboard;setClipboard";
var mozileEnhancementCode = [
"this.setSharedData('clipboard', mozile.getModule('CopyCutPaste').getClipboard())",
"mozile.getModule('CopyCutPaste').setClipboard(this.getSharedData('clipboard')); this.setSharedData('clipboard', '')"
];
function mozileOptionsInit() {
var caretAlwaysOn = mozilePrefs.getBoolPref("mozile.caretAlwaysOn");
if(caretAlwaysOn != null) document.getElementById("mozile.caretAlwaysOn").checked = caretAlwaysOn;
var debugLevel = mozilePrefs.getCharPref("mozile.debugLevel");
if(debugLevel != null) document.getElementById("mozile.debugLevel").value = debugLevel;
var neverWarn = mozilePrefs.getBoolPref("mozile.neverWarn");
if(neverWarn != null) document.getElementById("mozile.neverWarn").checked = neverWarn;
mozileSetList("mozile.enhancementList");
mozileSetList("mozile.trustedSites");
mozileSetList("mozile.autoEnhanceSites");
}
function mozileDefaultList(pref) {
var value;
switch(pref) {
case "mozile.enhancementList":
value = mozileEnhancementList;
break;
case "mozile.enhancementCode":
for(var i=0; i < mozileEnhancementCode.length; i++) {
mozileEnhancementCode[i] = escape(mozileEnhancementCode[i]);
}
value = mozileEnhancementCode.join(";");
break
default:
break;
}
mozilePrefs.setCharPref(pref,value);
document.getElementById(pref).value = "";
}
function mozileSetList(pref) {
var prefArray = mozilePrefs.getCharPref(pref).split(";");
var listbox = document.getElementById(pref);
while(listbox.childNodes.length) {
listbox.removeChild(listbox.firstChild);
}
var listitem;
for(var p=0; p < prefArray.length; p++) {
listitem = document.createElement("listitem");
listitem.setAttribute("label", prefArray[p]);
listitem.setAttribute("value", prefArray[p]);
listbox.appendChild(listitem);
}
}
function mozileSetPref(element) {
var pref = element.id;
var value;
switch(element.localName) {
case "checkbox":
value = element.checked;
mozilePrefs.setBoolPref(pref, value);
break;
default:
value = element.value;
mozilePrefs.setCharPref(pref, value);
break;
}
return true;
}
function mozileShowCode(list, code) {
var entries = mozilePrefs.getCharPref(list).split(";");
for(var p=0; p < entries.length; p++) {
if(entries[p] == document.getElementById(list).value) break;
}
if(entries[p] != document.getElementById(list).value) return;
var codeBlocks = mozilePrefs.getCharPref(code).split(";");
document.getElementById(code).value = unescape(codeBlocks[p]);
}
function mozileSaveCode(list, code) {
var entries = mozilePrefs.getCharPref(list).split(";");
for(var p=0; p < entries.length; p++) {
if(entries[p] == document.getElementById(list).value) break;
}
if(entries[p] != document.getElementById(list).value) return;
var codeBlocks = mozilePrefs.getCharPref(code).split(";");
codeBlocks[p] = escape(document.getElementById(code).value);
mozilePrefs.setCharPref(code, codeBlocks.join(";"));
}
function mozileAddCode(list, code, msg) {
if(!mozileAddItem(list, msg)) return;
var codeBlocks = mozilePrefs.getCharPref(code).split(";");
codeBlocks.push("");
mozilePrefs.setCharPref(code, codeBlocks.join(";"));
document.getElementById(code).value = "";
}
function mozileRemoveCode(list, code) {
var entries = mozilePrefs.getCharPref(list).split(";");
for(var p=0; p < entries.length; p++) {
if(entries[p] == document.getElementById(list).value) break;
}
if(entries[p] != document.getElementById(list).value) return;
var codeBlocks = mozilePrefs.getCharPref(code).split(";");
codeBlocks[p] = undefined;
mozilePrefs.setCharPref(code, codeBlocks.join(";"));
document.getElementById(code).value = "";
mozileRemoveItem(list);
}
function mozileAddItem(pref, msg) {
var add = prompt(msg);
if(!add) return false;
var stripWS = /^(\s+)(.*?)(\s+)$/;
var result = stripWS.exec(add);
if(result && result[2]) add = result[2];
var listbox = document.getElementById(pref);
var listitem = document.createElement("listitem");
listitem.setAttribute("label", add);
listitem.setAttribute("value", add);
listbox.appendChild(listitem);
mozileSetListPref(pref);
return true;
}
function mozileRemoveItem(pref) {
var listbox = document.getElementById(pref);
var remove = new Array();
for(var c=0; c < listbox.childNodes.length; c++) {
if(listbox.childNodes[c].selected) remove.push(listbox.childNodes[c]);
}
while(remove.length) {
listbox.removeChild(remove.shift());
}
mozileSetListPref(pref);
}
function mozileClearList(pref) {
var listbox = document.getElementById(pref);
while(listbox.childNodes.length) {
listbox.removeChild(listbox.firstChild);
}
mozileSetListPref(pref);
}
function mozileSetListPref(pref) {
var listbox = document.getElementById(pref);
var values = new Array();
for(var c=0; c < listbox.childNodes.length; c++) {
if(listbox.childNodes[c].value) values.push(listbox.childNodes[c].value);
}
mozilePrefs.setCharPref(pref, values.join(";"));
}
</script>
<hbox class="header">
<label value="Mozile Preferences" />
</hbox>
<tabbox>
<tabs>
<tab label="Basic" selected="true"/>
<tab label="Enhancement"/>
<tab label="Sites"/>
</tabs>
<tabpanels height="350px">
<!-- Basic Preferences -->
<tabpanel orient="vertical">
<groupbox>
<description>Mozile makes use of an editing caret (a cursor) when editing documents. When not editing, Mozile turns the editing caret off. Check the box below to ensure the editing caret is always on.</description>
<checkbox id="mozile.caretAlwaysOn" label="Always show the editing caret (cursor)." checked="false" oncommand="mozileSetPref(this); mozilePrefs.setBoolPref('accessibility.browsewithcaret', this.checked);"/>
</groupbox>
<groupbox>
<!-- <description>Use the settings below to control Mozile's debugging behaviour.</description> -->
<label control="mozileDebugLevelMenulist" value="Set Mozile's debugging level:"/>
<menulist id="mozile.debugLevel" value="0" oncommand="mozileSetPref(this)">
<menupopup>
<menuitem label="Debugging Disabled" value="0"/>
<menuitem label="Critical Messages" value="1"/>
<menuitem label="Serious Messages" value="2"/>
<menuitem label="Significant Messages" value="3"/>
<menuitem label="All Messages" value="4"/>
</menupopup>
</menulist>
</groupbox>
<groupbox>
<description>Mozile can enhance editors to allow functions such as access to the system clipboard and saving to local files. You should only enhance sites that you trust. Mozile will warn you before enhancing unless you disable the warning.</description>
<checkbox id="mozile.neverWarn" label="Do not show warnings." checked="false" oncommand="mozileSetPref(this)"/>
</groupbox>
</tabpanel>
<!-- Advanced Preferences -->
<tabpanel orient="vertical">
<description>These settings allow you to control how the Mozile Extension installed in your browser can enhance the Mozile editors which are used in pages on the World Wide Web.</description>
<!-- list of enhanced modules -->
<groupbox>
<label value="Enhancements:"/>
<hbox>
<listbox id="mozile.enhancementList" seltype="single" style="height: 60pt" flex="1" onselect="mozileShowCode('mozile.enhancementList', 'mozile.enhancementCode')">
</listbox>
<vbox pack="end">
<button label="Add" oncommand="mozileAddCode('mozile.enhancementList','mozile.enhancementCode','Name of enhancement:')"/>
<button label="Remove" oncommand="mozileRemoveCode('mozile.enhancementList','mozile.enhancementCode')"/>
<button label="Default" oncommand="mozileDefaultList('mozile.enhancementList');mozileSetList('mozile.enhancementList');mozileDefaultList('mozile.enhancementCode')"/>
</vbox>
</hbox>
<textbox id="mozile.enhancementCode" flex="1" multiline="true" rows="6" oninput="mozileSaveCode('mozile.enhancementList', 'mozile.enhancementCode')"/>
</groupbox>
</tabpanel>
<tabpanel orient="vertical">
<description>These settings allow you to control which sites Mozile always trusts to enhance, and which it will enhance as soon as they are made editable.</description>
<!-- List of allowed sites -->
<groupbox>
<label value="Always trust these sites:"/>
<hbox>
<listbox id="mozile.trustedSites" seltype="multiple" style="height: 60pt" flex="1">
</listbox>
<vbox pack="end">
<button label="Add" oncommand="mozileAddItem('mozile.trustedSites', 'Name of the site to add (e.g. mozile.mozdev.org):')"/>
<button label="Remove" oncommand="mozileRemoveItem('mozile.trustedSites')"/>
<button label="Clear" oncommand="mozileClearList('mozile.trustedSites')"/>
</vbox>
</hbox>
</groupbox>
<!-- List of forbidden sites -->
<groupbox>
<label value="Automatically enhance when editing these sites:"/>
<hbox>
<listbox id="mozile.autoEnhanceSites" seltype="multiple" style="height: 60pt" flex="1">
</listbox>
<vbox pack="end">
<button label="Add" oncommand="mozileAddItem('mozile.autoEnhanceSites', 'Name of the site to add (e.g. mozile.mozdev.org):')"/>
<button label="Remove" oncommand="mozileRemoveItem('mozile.autoEnhanceSites')"/>
<button label="Clear" oncommand="mozileClearList('mozile.autoEnhanceSites')"/>
</vbox>
</hbox>
</groupbox>
</tabpanel>
</tabpanels>
</tabbox>
</dialog>
Documentation generated by
JSDoc on Thu Feb 16 20:20:37 2006