summaryrefslogtreecommitdiff
path: root/www/js/router.js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2016-05-06 21:02:07 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2016-05-06 21:02:07 (GMT)
commit8dd1c416db47a8689fb520db8785d109da6719ff (patch)
treea319d9a7fe0fa16d59cfa9254fba95d28110ac7a /www/js/router.js
parent964822ed420618d8fd75cd0843424ead5d6fb159 (diff)
add subpages to router
Diffstat (limited to 'www/js/router.js')
-rw-r--r--www/js/router.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/www/js/router.js b/www/js/router.js
index 62b9a77..d9d070f 100644
--- a/www/js/router.js
+++ b/www/js/router.js
@@ -69,9 +69,11 @@ Rdxport.Router.prototype.route = function(page, subpage) {
//todo: add errors
});*/
+ var href = ['', ''];
if (!page && !subpage) {
- page = locationHrefValue();
- subpage = '';
+ href = locationHrefValue();
+ page = href[1];
+ subpage = href[2];
}
shows_cleanup();
@@ -90,8 +92,9 @@ Rdxport.Router.prototype.route = function(page, subpage) {
var href = $(this).attr('href').split('/');
self.route(href[1], href[2]);
});
- $(window).on('popstate', function(event) {
- self.route(locationHrefValue(), '');
+ $(window).off('popstate').on('popstate', function(event) {
+ var href = locationHrefValue();
+ self.route(href[1], href[2]);
});
switch (page) {
@@ -115,10 +118,11 @@ Rdxport.Router.prototype.route = function(page, subpage) {
break;
}
- if (locationHrefValue() !== page && page !== 'logout') {
+ href = locationHrefValue();
+ if (href[1] !== page && page !== 'logout' && (!href[2] || href[2] !== subpage)) {
var url = '/' + page + '/';
if (subpage) {
- url +=+ subpage + '/';
+ url += subpage + '/';
}
history.pushState(null, null, url);
}
@@ -149,7 +153,7 @@ Rdxport.Router.prototype.logout = function() {
Rdxport.Router.prototype.shows = function(subpage) {
$('#app-shows').show();
$('#nav-btn-shows').addClass('active');
- shows_init();
+ shows_init(subpage);
};
Rdxport.Router.prototype.jingles = function() {
@@ -161,7 +165,7 @@ Rdxport.Router.prototype.jingles = function() {
Rdxport.Router.prototype.musicpools = function(subpage) {
$('#app-musicpools').show();
$('#nav-btn-musicpools').addClass('active');
- musicpools_init();
+ musicpools_init(subpage);
};
Rdxport.Router.prototype.musicgrid = function() {