home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / firefox / noscript-1.1.3.9-fxflmz.xpi / chrome / noscript.jar / content / noscript / noscript.js < prev    next >
Encoding:
Text File  |  2006-01-26  |  1.5 KB  |  60 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"].getService().wrappedJSObject;
  13.        break;
  14.       } catch(ex) {
  15.         dump(ex.message);
  16.         window.navigator.plugins.refresh();
  17.       }
  18.     }
  19.     if(s!=null) s.init();
  20.     return this._service=s;
  21.   }
  22. ,
  23.   _strings: null,
  24.   get strings() {
  25.     return this._strings?this._strings
  26.       :this._strings=document.getElementById(this.chromeName+"-strings");  
  27.   }
  28. ,
  29.   _stringsFB: null,
  30.   get stringsFB() {
  31.     return this._stringsFB?this._stringsFB
  32.       :this._stringsFB=document.getElementById(this.chromeName+"-stringsFB");  
  33.   }
  34. ,
  35.   _stringFrom: function(bundle,key,parms) {
  36.     try {
  37.       return parms?bundle.getFormattedString(key,parms):bundle.getString(key);
  38.     } catch(ex) {
  39.       return null;
  40.     }
  41.   }
  42. ,
  43.   getString: function(key,parms) {
  44.     var s=this._stringFrom(this.strings,key,parms);
  45.     return s?s:this._stringFrom(this.stringsFB,key,parms);
  46.   }
  47. ,
  48.   openOptionsDialog: function() {
  49.     window.open(this.chromeBase+this.chromeName+"Options.xul",this.chromeName+"Options",
  50.           "chrome,dialog,centerscreen,alwaysRaised");  
  51.   }
  52. ,
  53.   openAboutDialog: function() {
  54.     window.open(this.chromeBase+"about.xul",this.chromeName+"About",
  55.       "chrome,dialog,centerscreen");
  56.   }
  57. };
  58.  
  59. var noscriptUtil=new NoscriptUtil();
  60.