From 7c82c788f9bf98e76445a70d07e7eb865ab05bb6 Mon Sep 17 00:00:00 2001 From: rafalages Date: Mon, 10 Sep 2012 09:32:10 -0300 Subject: [PATCH 1/2] #test commit --- jsRoute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsRoute.js b/jsRoute.js index c2271fc..8e954d8 100644 --- a/jsRoute.js +++ b/jsRoute.js @@ -20,7 +20,7 @@ var route = { }, _check: function() { - if( this.actualURL != document.location.href ) { + if( document.location.href && this.actualURL != document.location.href ) { this.actualURL = document.location.href; this._update(); } From 16fa779a53660c5458154282eb3279574fbd905c Mon Sep 17 00:00:00 2001 From: rafalages Date: Mon, 10 Sep 2012 09:35:00 -0300 Subject: [PATCH 2/2] #some minimal code improvements --- jsRoute.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jsRoute.js b/jsRoute.js index 8e954d8..fb07855 100644 --- a/jsRoute.js +++ b/jsRoute.js @@ -5,7 +5,7 @@ var route = { routes: [], funcs: [], - actualURL: '', + currentHash: '', interval: null, add: function(route, func){ @@ -20,14 +20,14 @@ var route = { }, _check: function() { - if( document.location.href && this.actualURL != document.location.href ) { - this.actualURL = document.location.href; + if( document.location.hash && this.currentHash != document.location.hash) { + this.currentHash = document.location.hash.slice(1); this._update(); } }, _findAndExecute: function(route){ - for(var i=0; i< this.routes.length; i++){ + for( var i = 0, l = this.routes.length; i < l; i++ ){ var re = new RegExp(this.routes[i]); var match = route.match(re); @@ -40,7 +40,7 @@ var route = { }, _update: function(){ - var hash = location.hash.slice(1); + var hash = this.currentHash; this._findAndExecute(hash); },