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-kmacros.xul < prev    next >
Extensible Markup Language  |  2007-04-23  |  4KB  |  144 lines

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
  3. <!DOCTYPE page SYSTEM "chrome://kmprefs/locale/pref-kmacros.dtd">
  4. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
  5. id="prefKMacros" onload="kMacros.init()">
  6.  
  7. <stringbundle id="pref_bundle" src="chrome://kmprefs/locale/pref.properties"/>
  8. <stringbundle id="macro_bundle" src="chrome://kmprefs/locale/kplugins/macros.properties"/>
  9.  
  10. <script type="application/x-javascript" src="chrome://kmprefs/content/pref.js"/>
  11. <script type="application/x-javascript">
  12. <![CDATA[
  13. var kMacros = {
  14.  
  15. _base: null,
  16. _pref: null,
  17. _bndl: null,
  18. _list: null,
  19.  
  20. load: null,
  21. mods: null,
  22. init: function() {
  23.     this.load  = kPlugin.load("macros");
  24.     this.mods  = [];
  25.     this._base = "kmeleon.plugins.macros.";
  26.     this._pref = "load";
  27.     this._list = document.getElementById("modules");
  28.     this._bndl = document.getElementById("macro_bundle");
  29.  
  30.     initCheckbox(this._base+this._pref);
  31.  
  32.     this._getModules(getFolder("CurProcD"),this.mods);
  33.     this._getModules(getFolder("KUserSettings"),this.mods);
  34.     this.mods = this.mods.sort(this._alphabetical);
  35.     for(var j=0,litem,lcell;j<this.mods.length;j++) {
  36.         litem = document.createElement("listitem");
  37.         litem.setAttribute("onclick","kMacros.toggleModule(this)");
  38.  
  39.         lcell = document.createElement("listcell");
  40.         lcell.setAttribute("checked",kMacrosModule.load(this.mods[j]));
  41.         lcell.setAttribute("label",this.mods[j]);
  42.         lcell.setAttribute("type","checkbox");
  43.         litem.appendChild(lcell);
  44.  
  45.         lcell = document.createElement("listcell");
  46.         try {
  47.                 lcell.setAttribute("label",this._bndl.getString(this.mods[j]));
  48.         } catch(e) {
  49.             if(this.mods[j].match(/^lang_[a-z]{2}-[a-z]{2}$/)==null)
  50.                 lcell.setAttribute("label",this._bndl.getString("custom"));
  51.             else
  52.                 lcell.setAttribute("label",this._bndl.getString("lang_xx-yy"));
  53.         }
  54.         litem.appendChild(lcell);
  55.  
  56.         this._list.appendChild(litem);
  57.     }
  58.     this._setControls();
  59. },
  60. toggle: function(prefID) {
  61.     toggleCheckbox(prefID);
  62.     this.load = !this.load;
  63.     this._setControls();
  64. },
  65. toggleModule: function(elem) {
  66.     elem = elem.firstChild;
  67.  
  68.     var prefID = this._base + "modules." + elem.getAttribute("label") + "." + this._pref;
  69.  
  70.     if(elem.disabled) return;
  71.     if(elem.getAttribute("checked")=="true") {
  72.         pref.setBoolPref(prefID,false);
  73.         elem.setAttribute("checked",false);
  74.     } else {
  75.         restoreDefault(prefID);
  76.         elem.setAttribute("checked",true);
  77.     }
  78. },
  79. _alphabetical: function(x,y) {
  80.     return (x.toLowerCase() > y.toLowerCase()) ? 1 : -1;
  81. },
  82. _getModules: function(folderPath,aArray) {
  83.     var folder = Components.classes["@mozilla.org/file/local;1"]
  84.                    .createInstance(nsILocalFile);
  85.  
  86.     folder.initWithPath(folderPath);
  87.     folder.append("macros");
  88.     try {
  89.         var OK = folder.isDirectory();
  90.     } catch(e) {
  91.         return;
  92.     }
  93.     if(OK) {
  94.         var name, file, files = folder.directoryEntries;
  95.         while(files.hasMoreElements()) {
  96.             file = files.getNext();
  97.             if(file instanceof Components.interfaces.nsILocalFile)
  98.                 if(file.isFile()) {
  99.                     name = file.leafName.toLowerCase();
  100.                     if((name!="main.kmm") && (name.substr(name.lastIndexOf("."))==".kmm"))
  101.                         aArray[aArray.length] = name.substr(0,name.lastIndexOf("."));
  102.                 }
  103.         }
  104.     }
  105. },
  106. _loaded: function(moduleName) {
  107.     return (getPrefValue(this._base+"modules."+moduleName+"."+this._pref) != "false");
  108. },
  109. _setControls: function() {
  110.     this._list.disabled = !this.load;
  111.     for(var j=0,c=document.getElementsByTagName("listcell");j<c.length;j+=2)
  112.         c[j].disabled = !this.load;
  113. }
  114.  
  115. };
  116. ]]>
  117. </script>
  118.  
  119. <vbox flex="1" style="overflow:auto">
  120.   <dialogheader title="&kmacros.header;"/>
  121.   <separator class="thin"/>
  122.   <checkbox oncommand="kMacros.toggle(this.id)" id="kmeleon.plugins.macros.load" label="&kmacros.enable;"/>
  123.   <separator class="thin"/>
  124.   <groupbox flex="1">
  125.     <caption label="&kmacros.modules;"/>
  126.     <separator class="thin"/>
  127.     <label value="&kmacros.modules.hint;"/>
  128.     <separator class="thin"/>
  129.     <listbox id="modules" flex="1" seltype="single">
  130.       <listcols>
  131.         <listcol flex="1"/>
  132.         <listcol flex="5"/>
  133.       </listcols>
  134.       <listhead>
  135.         <listheader label="&kmacros.modules.name;"/>
  136.         <listheader label="&kmacros.modules.descr;"/>
  137.       </listhead>
  138.     </listbox>
  139.     <separator class="thin"/>
  140.     <description>&restartNote1;</description>
  141.   </groupbox>
  142. </vbox>
  143.  
  144. </page>