home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 September
/
PCWorld_2008-09_cd.bin
/
komunikace
/
kmeleon
/
K-Meleon1.1.3en-US.exe
/
chrome
/
embed.jar
/
kmprefs
/
content
/
pref-webfind.xul
< prev
next >
Wrap
Extensible Markup Language
|
2007-04-23
|
16KB
|
437 lines
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
<!DOCTYPE page SYSTEM "chrome://kmprefs/locale/pref-webfind.dtd">
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="prefWebfind" onunload="Search.exit()">
<stringbundle id="pref_bundle" src="chrome://kmprefs/locale/pref.properties"/>
<stringbundle id="xml_bundle" src="chrome://kmprefs/locale/kmprefs/xml.properties"/>
<script type="application/x-javascript" src="chrome://kmprefs/content/pref.js"/>
<script type="application/x-javascript" src="chrome://kmprefs/content/kmprefs/xml.js"/>
<script type="application/x-javascript" src="chrome://kmprefs/content/kplugins/jsbridge.js"/>
<script type="application/x-javascript">
<![CDATA[
var menu;
CFGtoXML.init("search");
var Engines = new XML("file:///"+getFile(getFolder("KUserSettings"),"search.xml").path);
var JSB = new JSBridge();
function init(e) {
menu = document.createElement("menupopup");
for(var j=0,engines=Engines.data.getElementsByTagName("engine"),item;j<engines.length;j++) {
item = document.createElement("menuitem");
item.setAttribute("value",engines[j].getAttribute("url"));
item.setAttribute("label",engines[j].getAttribute("caption"));
menu.appendChild(item);
}
URLBar.init();
if(kPlugin.load("macros") && kMacrosModule.load("search")) {
if(JSB.load) {
document.getElementById("JSBridgeOff").style.display = "none";
document.getElementById("JSBridgeOn").style.display = "block";
}
} else {
var elem = document.getElementsByTagName("tab");
elem[1].parentNode.removeChild(elem[1]);
elem[1].parentNode.removeChild(elem[1]);
elem = document.getElementsByTagName("tabpanel");
elem[1].parentNode.removeChild(elem[1]);
elem[1].parentNode.removeChild(elem[1]);
}
}
var URLBar = {
init: function() {
for(var j=0,box=document.getElementsByTagName("checkbox");j<box.length;j++) initCheckbox(box[j].id);
document.getElementById("browser.urlbar.autoFill").disabled = !document.getElementById("browser.urlbar.autocomplete.enabled").checked;
try {
for(var box=document.getElementsByTagName("textbox"),j=box.length-1;j>-1;j--)
initTextbox(box[j].id,false);
} catch(e) {}
if(!kPlugin.load("macros") || !kMacrosModule.load("domcomplete")) {
var elem = document.getElementById("domComplete");
elem.parentNode.removeChild(elem);
}
this.initKeyword();
this.initKeywordMenu();
},
initKeyword: function() {
var val = document.getElementById("keyword.enabled").checked;
document.getElementById("browser.fixup.alternate.enabled").disabled = val;
document.getElementById("browser.fixup.alternate.prefix").disabled = val;
document.getElementById("browser.fixup.alternate.suffix").disabled = val;
},
initKeywordMenu: function() {
var elem = document.getElementById("keyword.URL");
if(elem.hasChildNodes()) elem.removeChild(elem.firstChild);
elem.appendChild(menu.cloneNode(true));
initMenulist("keyword.URL","",false);
}
};
var Search = {
_base: "kmeleon.plugins.macros.search.",
_dflt: "kmeleon.general.searchEngine",
_elem: ["engine","meta"],
_menu: ["_Search_Engines_Configurable","_Search_Engines_Metasearch"],
_cmnd: ["Search_Engine","Search_Metasearch"],
_labl: ["","&Metasearch"],
done: [false,false],
init: function(n) {
if(!this.done[n]) {
var j = 0;
var prefID = this._base + this._elem[n] + j + ".url";
var box = document.getElementById(this._elem[n]),
val = getPrefValue(prefID);
pref.setIntPref(this._base+this._elem[n]+".max",0);
while(box.hasChildNodes()) box.removeChild(box.firstChild);
while(val != null) {
if(val) {
this._addMenu(n,prefID);
initMenulist(prefID,"",false);
}
j++;
prefID = this._base + this._elem[n] + j + ".url";
val = getPrefValue(prefID);
}
this.done[n] = true;
}
},
exit: function() {
for(var j=0;j<this._elem.length;j++) restoreDefault(this._base+this._elem[j]+".max");
Engines.save(getFile(getFolder("KUserSettings"),"search.xml"),["caption","url"]);
},
add: function(n) {
this._addMenu(n,this._base+this._elem[n]+document.getElementById(this._elem[n]).getElementsByTagName("menulist").length+".url");
},
_addMenu: function(n,elemID) {
var elem = document.createElement("menulist"),
prnt = document.getElementById(this._elem[n]);
elem.id = elemID;
elem.setAttribute("flex",1); // omitting this slows rendering!
elem.setAttribute("oncommand","Search.setEngine("+n+",this)");
elem.appendChild(menu.cloneNode(true));
prnt.appendChild(elem);
prnt.lastChild.firstChild.insertBefore(document.createElement("menuseparator"),prnt.lastChild.firstChild.firstChild);
elem = document.createElement("menuitem");
elem.setAttribute("value","");
elem.setAttribute("label",document.getElementById("pref_bundle").getString("remove_entry"));
prnt.lastChild.firstChild.insertBefore(elem,prnt.lastChild.firstChild.firstChild);
prnt.lastChild.selectedIndex = 0;
pref.setIntPref(this._base+this._elem[n]+".max",pref.getIntPref(this._base+this._elem[n]+".max")+1);
},
setEngine: function(n,elem) {
var val = elem.value,
lbl = (val) ? elem.selectedItem.label : "";
if(!n) {
this._delMenu();
this._setDefault(elem,val,lbl);
setCharPref(elem.id.substr(0,elem.id.lastIndexOf("."))+".name",lbl);
}
setCharPref(elem.id,val);
if(!val) {
this._sanitize(this._elem[n]);
this.done[n] = false;
this.init(n);
}
this._setMenu(n);
},
_setDefault: function(elem,value,label) {
if(getPrefValue(elem.id)==getPrefValue(this._dflt))
if(value) {
setCharPref(this._dflt,value);
setCharPref(this._dflt+"Name",label);
} else pref.setBoolPref(this._base+"locked",false)
},
_delMenu: function() {
for(var j=0;j<pref.getIntPref(this._base+this._elem[0]+".max");j++)
JSB.setmenu(this._menu[0],"macro","",this._cmnd[0]+"("+j+")","");
},
_setMenu: function(n) {
var max = pref.getIntPref(this._base+this._elem[n]+".max");
if(n)
JSB.setmenu(this._menu[n],"macro",this._labl[n],(max)?this._cmnd[n]:"","");
else for(var j=0;j<max;j++)
JSB.setmenu(this._menu[n],"macro",getPrefValue(this._base+this._elem[0]+j+".name"),this._cmnd[n]+"("+j+")","");
// JSB.rebuildmenu(this._menu[n]);
},
_sanitize: function(prefPart) {
var max = pref.getIntPref(this._base+prefPart+".max");
for(var j=0;j<max;j++)
if(getPrefValue(this._base+prefPart+j+".url")=="") {
for(var i=j+1;i<max;i++) {
setCharPref(this._base+prefPart+(i-1)+".url",getPrefValue(this._base+prefPart+i+".url"));
if(prefPart=="engine") setCharPref(this._base+prefPart+(i-1)+".name",getPrefValue(this._base+prefPart+i+".name"));
}
setCharPref(this._base+prefPart+(max-1)+".url","");
if(prefPart=="engine") setCharPref(this._base+prefPart+(max-1)+".name","");
}
for(var j=0,url;j<max;j++) {
url = this._base+prefPart+j+".url";
if(getPrefValue(url)) continue;
restoreDefault(url);
if(getPrefValue(url)==null) {
if(prefPart=="engine") restoreDefault(this._base+prefPart+j+".name");
} else
setCharPref(url,"");
}
}
};
var Database = {
_add: false,
_ndx: false,
_cap: null,
_url: null,
done: false,
tree: null,
init: function() {
if(!this.done) {
this.done = true;
this.tree = document.getElementById("database");
while(this.tree.hasChildNodes()) this.tree.removeChild(this.tree.firstChild);
for(var j=0,engines=Engines.data.getElementsByTagName("engine"),titem,tcell;j<engines.length;j++) {
titem = document.createElement("treeitem");
titem.appendChild(document.createElement("treerow"));
tcell = document.createElement("treecell");
tcell.setAttribute("label",engines[j].getAttribute("caption"));
titem.firstChild.appendChild(tcell);
tcell = document.createElement("treecell");
tcell.setAttribute("label",engines[j].getAttribute("url"));
titem.firstChild.appendChild(tcell);
this.tree.appendChild(titem);
}
}
},
del: function() {
this._ndx = this.tree.parentNode.currentIndex;
if(this._ndx>-1) {
this.tree.removeChild(this.tree.childNodes[this._ndx]);
if(Engines.del("engine",this._ndx)) this._refresh();
}
},
add: function() {
this._ndx = -1;
this._add = true;
this._cap = null;
this._url = null;
window.openDialog("chrome://kmprefs/content/kmprefs/dlg-webfind.xul","engnAdd" ,"chrome,modal=yes,resizable=no",this);
},
edit: function() {
this._ndx = this.tree.parentNode.currentIndex;
this._add = false;
this._cap = this.tree.childNodes[this._ndx].firstChild.firstChild.getAttribute("label");
this._url = this.tree.childNodes[this._ndx].firstChild.firstChild.nextSibling.getAttribute("label");
window.openDialog("chrome://kmprefs/content/kmprefs/dlg-webfind.xul","engnEdit","chrome,modal=yes,resizable=no",this);
},
select: function() {
var ndx = this.tree.parentNode.currentIndex;
document.getElementById("edit").setAttribute("disabled",(ndx==-1));
document.getElementById("delete").setAttribute("disabled",(ndx==-1));
},
set: function(caption,url) {
if((this._cap != caption) || (this._url != url)) {
Engines.set("engine",this._ndx,["caption","url"],[caption,url],0);
this._refresh();
this.done = false;
this.init();
}
},
_refresh: function() {
init(false);
for(var j=0;j<Search.done.length;j++) Search.done[j] = false;
}
};
]]>
</script>
<keyset>
<key id="addKey" keycode="VK_INSERT" oncommand="Database.add()"/>
<key id="delKey" keycode="VK_DELETE" oncommand="Database.del()"/>
</keyset>
<vbox flex="1" style="overflow:auto">
<dialogheader title="&webfind.header;"/>
<separator class="thin"/>
<tabcontrol flex="1">
<tabbox flex="1">
<tabs>
<tab label="&webfind.urlbar;"/>
<tab label="&webfind.websearch;" oncommand="Search.init(0)"/>
<tab label="&webfind.metasearch;" oncommand="Search.init(1)"/>
<tab label="&webfind.database;" oncommand="Database.init()"/>
</tabs>
<tabpanels flex="1">
<tabpanel flex="1" orient="vertical" style="overflow:auto">
<!-- URL Bar -->
<groupbox>
<caption label="&autocomplete.label;"/>
<checkbox oncommand="toggleCheckbox(this.id);this.nextSibling.disabled=!this.checked" id="browser.urlbar.autocomplete.enabled" label="&autocomplete.enable;"/>
<checkbox oncommand="toggleCheckbox(this.id)" id="browser.urlbar.autoFill" label="&autofill.enable;" style="margin-left:2em"/>
</groupbox>
<groupbox id="domComplete">
<caption label="&domCompletion.label;"/>
<separator class="thin"/>
<grid>
<columns>
<column style="padding-right:1em"/>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&whenPressing;"/>
<label value="&domCompletion.prefix;"/>
<label value="&domCompletion.suffix;"/>
</row>
<row>
<separator class="thin"/>
</row>
<row align="center">
<label value="&domCompletion.key0;"/>
<textbox id="kmeleon.plugins.macros.domComplete0.prefix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
<textbox id="kmeleon.plugins.macros.domComplete0.suffix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
</row>
<row align="center">
<label value="&domCompletion.key1;"/>
<textbox id="kmeleon.plugins.macros.domComplete1.prefix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
<textbox id="kmeleon.plugins.macros.domComplete1.suffix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
</row>
<row align="center">
<label value="&domCompletion.key2;"/>
<textbox id="kmeleon.plugins.macros.domComplete2.prefix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
<textbox id="kmeleon.plugins.macros.domComplete2.suffix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
</row>
</rows>
</grid>
<separator class="thin"/>
<description>¯osNote;</description>
</groupbox>
<groupbox>
<caption label="&fixupAlt.label;"/>
<checkbox oncommand="toggleCheckbox(this.id)" id="browser.fixup.alternate.enabled" label="&fixupAlt.enable;"/>
<separator class="thin"/>
<grid>
<columns>
<column style="padding-right:1em"/>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows>
<row align="center">
<label value="&domCompletion.key2;" style="visibility:hidden"/>
<label value="&domCompletion.prefix;"/>
<label value="&domCompletion.suffix;"/>
</row>
<row>
<separator class="thin"/>
</row>
<row align="center">
<label value="&domCompletion.key2;" style="visibility:hidden"/>
<textbox id="browser.fixup.alternate.prefix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
<textbox id="browser.fixup.alternate.suffix" flex="1" class="uri-element" oninput="setCharPref(this.id,this.value)"/>
</row>
</rows>
</grid>
<separator class="thin"/>
</groupbox>
<groupbox>
<caption label="&keyword.label;"/>
<checkbox oncommand="toggleCheckbox(this.id);URLBar.initKeyword()" id="keyword.enabled" label="&keyword.enable;"/>
<vbox id="keyword">
<separator class="thin"/>
<hbox align="center">
<label value="&domCompletion.key2;" style="visibility:hidden;padding-right:1em"/>
<label value="&keyword.engine;"/>
<menulist id="keyword.URL" oncommand="setCharPref(this.id,this.value)" flex="1"/>
</hbox>
</vbox>
</groupbox>
<!-- URL Bar -->
</tabpanel>
<tabpanel flex="1" orient="vertical">
<!-- Web Search -->
<separator class="thin"/>
<description>&websearch.descr;</description>
<separator class="thin"/>
<vbox id="engine" flex="1" style="overflow:auto"/>
<vbox flex="1000"/>
<separator class="thin"/>
<hbox>
<button label="&webfind.addEntry;" oncommand="Search.add(0);"/>
<hbox flex="1"/>
</hbox>
<separator class="thin"/>
<description id="JSBridgeOn" style="display:none">¯osNote;</description>
<description id="JSBridgeOff">&websearch.note;</description>
<!-- Web Search -->
</tabpanel>
<tabpanel flex="1" orient="vertical">
<!-- Metasearch -->
<separator class="thin"/>
<description>&meta.descr;</description>
<separator class="thin"/>
<vbox id="meta" flex="1" style="overflow:auto"/>
<vbox flex="1000"/>
<separator class="thin"/>
<hbox>
<button label="&webfind.addEntry;" oncommand="Search.add(1);"/>
<hbox flex="1"/>
</hbox>
<separator class="thin"/>
<description>¯osNote;</description>
<!-- Metasearch -->
</tabpanel>
<tabpanel flex="1" orient="vertical" style="overflow:auto">
<!-- Database -->
<separator class="thin"/>
<description>&database.descr;</description>
<separator class="thin"/>
<tree flex="1" seltype="single" hidecolumnpicker="true" onselect="Database.select()">
<treecols>
<treecol label="&database.caption;" flex="1"/>
<splitter class="tree-splitter"/>
<treecol label="&database.url;" flex="2"/>
</treecols>
<treechildren id="database"/>
</tree>
<separator class="thin"/>
<hbox>
<button label="&add;" oncommand="Database.add()" key="addKey"/>
<button id="edit" label="&edit;" oncommand="Database.edit()" disabled="true"/>
<button id="delete" label="&delete;" oncommand="Database.del()" key="delKey" disabled="true"/>
<hbox flex="1"/>
</hbox>
<!-- Database -->
</tabpanel>
</tabpanels>
</tabbox>
</tabcontrol>
</vbox>
</page>