From fd6b08d73eefcf5f06aa10eae2856d07a2bdd158 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 30 Apr 2012 11:49:27 +0200 Subject: [PATCH] Don't fire create page twice --- couchpotato/static/scripts/couchpotato.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index 8f412eea..451e4346 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -117,15 +117,15 @@ var CouchPotato = new Class({ openPage: function(url) { var self = this; - var current_url = url.replace(/^\/+|\/+$/g, ''); - if(current_url == self.current_url) - return; - self.route.parse(); var page_name = self.route.getPage().capitalize(); var action = self.route.getAction(); var params = self.route.getParams(); + var current_url = self.route.getCurrentUrl(); + if(current_url == self.current_url) + return; + if(self.current_page) self.current_page.hide() @@ -287,8 +287,8 @@ var Route = new Class({ var self = this; var path = History.getPath().replace(Api.getOption('url'), '/').replace(App.getOption('base_url'), '/') - var current = path.replace(/^\/+|\/+$/g, '') - var url = current.split('/') + self.current = path.replace(/^\/+|\/+$/g, '') + var url = self.current.split('/') self.page = (url.length > 0) ? url.shift() : self.defaults.page self.action = (url.length > 0) ? url.shift() : self.defaults.action @@ -324,6 +324,10 @@ var Route = new Class({ return this.params }, + getCurrentUrl: function(){ + return this.current + }, + get: function(param){ return this.params[param] }