Changeset 699

Show
Ignore:
Timestamp:
03/28/08 05:10:23 (8 months ago)
Author:
ma..@jesperkristensen.dk
Message:

simplify observing a single script

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/manage-ui2/src/chrome/chromeFiles/content/config.js

    r695 r699  
    1414 
    1515Config.prototype = { 
    16   addObserver: function(observer, script) { 
    17     var observers = script ? script._observers : this._observers; 
    18     observers.push(observer); 
    19   }, 
    20  
    21   removeObserver: function(observer, script) { 
    22     var observers = script ? script._observers : this._observers; 
    23     var index = observers.indexOf(observer); 
     16  addObserver: function(observer) { 
     17    this._observers.push(observer); 
     18  }, 
     19 
     20  removeObserver: function(observer) { 
     21    var index = this._observers.indexOf(observer); 
    2422    if (index == -1) throw new Error("Observer not found"); 
    25     observers.splice(index, 1); 
     23    this._observers.splice(index, 1); 
    2624  }, 
    2725 
     
    399397 
    400398Script.prototype = { 
     399  addObserver: Config.prototype.addObserver, 
     400  removeObserver: Config.prototype.removeObserver, 
     401 
    401402  matchesURL: function(url) { 
    402403    function test(page) { 
  • branches/manage-ui2/src/chrome/chromeFiles/content/pages-overlay.js

    r695 r699  
    1818    excludesBox.populate(script, "excludes", script.excludes); 
    1919    this.script = script; 
    20     GM_getConfig().addObserver(this, this.script); 
     20    this.script.addObserver(this); 
    2121  }; 
    2222 
    2323  this.clear = function() { 
    2424    if (this.script == null) return; 
    25     GM_getConfig().removeObserver(this, this.script); 
     25    this.script.removeObserver(this); 
    2626    includesBox.clear(); 
    2727    excludesBox.clear();