diff options
Diffstat (limited to 'static/js/router.js')
-rw-r--r-- | static/js/router.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/static/js/router.js b/static/js/router.js index 028eef6..dbdc9df 100644 --- a/static/js/router.js +++ b/static/js/router.js @@ -2,14 +2,14 @@ var router = function(routes){ this.routes = routes; - this.current_id = id_from_hash(window.location.hash); + this.current_id = ""; this.tab_elements = {}; this.initial_load(); //This initial 'fake' call allows to initialize contents //and link values - this.url_changed_callback(this.current_id); + this.url_changed_callback(id_from_hash(window.location.hash)); //Adds the callback along with the context of the instance var current_context = this; @@ -56,14 +56,16 @@ router.prototype.initial_load = function() { router.prototype.url_changed_callback = function(){ var id = id_from_hash(window.location.hash); - //Update contents each time the URL changes - this.swap_contents(id); - - this.current_id = id; + if (id != this.current_id){ + //Update contents each time the URL changes + this.swap_contents(id); + + this.current_id = id; + } } -router.prototype.swap_contents = function(id){ - this.tab_elements[this.current_id].style = "display: none;"; +router.prototype.swap_contents = function(id){ + if (this.current_id != "") this.tab_elements[this.current_id].style = "display: none;"; this.tab_elements[id].style = "display: block;"; } |