home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 March / PCWMAR06.iso / Software / FromTheMag / Noscript / noscript-1.1.3.5-fx+mz.xpi / chrome / noscript.jar / content / noscript / noscript.js < prev    next >
Encoding:
Text File  |  2005-12-08  |  1.6 KB  |  61 lines

  1. function NoscriptUtil() {}
  2.  
  3. NoscriptUtil.prototype={
  4.   chromeBase: "chrome://noscript/content/",
  5.   chromeName: "noscript",
  6.   _service: null, 
  7.   get service() {
  8.     if(this._service) return this._service;
  9.     var s=null;
  10.     for(var attempt=1; attempt<=2;attempt++) {
  11.       try {
  12.        s=Components.classes["@maone.net/noscript-service;1"
  13.           ].getService(Components.interfaces.nsISupports).wrappedJSObject;
  14.        break;
  15.       } catch(ex) {
  16.         dump(ex.message);
  17.         window.navigator.plugins.refresh();
  18.       }
  19.     }
  20.     if(s!=null) s.init();
  21.     return this._service=s;
  22.   }
  23. ,
  24.   _strings: null,
  25.   get strings() {
  26.     return this._strings?this._strings
  27.       :this._strings=document.getElementById(this.chromeName+"-strings");  
  28.   }
  29. ,
  30.   _stringsFB: null,
  31.   get stringsFB() {
  32.     return this._stringsFB?this._stringsFB
  33.       :this._stringsFB=document.getElementById(this.chromeName+"-stringsFB");  
  34.   }
  35. ,
  36.   _stringFrom: function(bundle,key,parms) {
  37.     try {
  38.       return parms?bundle.getFormattedString(key,parms):bundle.getString(key);
  39.     } catch(ex) {
  40.       return null;
  41.     }
  42.   }
  43. ,
  44.   getString: function(key,parms) {
  45.     var s=this._stringFrom(this.strings,key,parms);
  46.     return s?s:this._stringFrom(this.stringsFB,key,parms);
  47.   }
  48. ,
  49.   openOptionsDialog: function() {
  50.     window.open(this.chromeBase+this.chromeName+"Options.xul",this.chromeName+"Options",
  51.           "chrome,dialog,centerscreen,alwaysRaised");  
  52.   }
  53. ,
  54.   openAboutDialog: function() {
  55.     window.open(this.chromeBase+"about.xul",this.chromeName+"About",
  56.       "chrome,dialog,centerscreen");
  57.   }
  58. };
  59.  
  60. var noscriptUtil=new NoscriptUtil();
  61.