Skip to content

Commit

Permalink
Condense code by eliminating some whitespace and using a local variab…
Browse files Browse the repository at this point in the history
…le in place of 'this'.
  • Loading branch information
rwstauner committed Apr 7, 2010
1 parent 9fd12ea commit ba4665d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions dispatcher.js
Expand Up @@ -19,7 +19,8 @@ Auger.Dispatcher._onhashchange = function(e){ // gets detached (avoid unnecessa
// prefix string, regex, or boolean function (allows multiple "apps" on the same page)
Auger.Dispatcher._dispatch_types = [null, 'string', RegExp, Function];
Auger.Dispatcher.dispatch = function(c,f){
var t = this._dispatch_types, d = null;
var a = Auger.Dispatcher; // this
var t = a._dispatch_types, d = null;
if(!f)
d = [0,null,c];
else if(typeof(c) == 'string')
Expand All @@ -28,13 +29,13 @@ Auger.Dispatcher.dispatch = function(c,f){
for(var i=2; i<t.length; ++i)
if(c instanceof t[i])
d = [i,c,f];
if( d )
this._actions.push(d);
if(d)
a._actions.push(d);
else
throw("Unknown argument: " + c);
this._lastHash = this.getHash(); // requires the page to load the initial hash
if( this._actions.length == 1) // only add it the first time since we roll through all the possibilities
this.listen(this._onhashchange);
a._lastHash = a.getHash(); // requires the page to load the initial hash
if(a._actions.length == 1) // only add it the first time since we roll through all the possibilities
a.listen(a._onhashchange);
};
Auger.Dispatcher.getHash = function(){
//var h = location.hash; return h ? h.replace(/^#+/,'') : location.href.replace(/^[^#]*#/,'');
Expand Down

0 comments on commit ba4665d

Please sign in to comment.