summaryrefslogtreecommitdiff
path: root/www/js/apps.js
diff options
context:
space:
mode:
authorPeterTheOne <petertheone@gmail.com>2015-07-31 19:29:15 (GMT)
committerPeterTheOne <petertheone@gmail.com>2015-07-31 19:29:15 (GMT)
commit9bcb5485f8a47358463e2d3fc4bf45c567163d7a (patch)
treee37eafa44fe8172455ce3bb777424287511fb275 /www/js/apps.js
parent2aedff65649b4601d5998696fac2ccf33ff1ba9b (diff)
use history.pushState to switch apps
Diffstat (limited to 'www/js/apps.js')
-rw-r--r--www/js/apps.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/www/js/apps.js b/www/js/apps.js
index 8f30ef0..af5cd6d 100644
--- a/www/js/apps.js
+++ b/www/js/apps.js
@@ -31,6 +31,8 @@ function apps_select(app) {
$('#app-musicpools').show();
$('#nav-btn-musicpools').addClass('active');
+
+ apps_current = app;
musicpools_init();
break;
case "jingles":
@@ -42,6 +44,7 @@ function apps_select(app) {
$('#app-jingles').show();
$('#nav-btn-jingles').addClass('active');
+ apps_current = app;
jingles_init();
break;
default:
@@ -53,17 +56,26 @@ function apps_select(app) {
$('#app-shows').show();
$('#nav-btn-shows').addClass('active');
- apps_current = 'shows';
+ apps_current = app = 'shows';
shows_init();
- }
- sessionStorage.setItem("apps_current", app);
+ }
+ if (locationHashValue() !== app) {
+ history.pushState(null, null, '/#' + app + '/');
+ }
}
function apps_init() {
- apps_current = sessionStorage.getItem("apps_current");
+ apps_current = locationHashValue();
+
if(auth_token && auth_username) {
apps_select(apps_current);
}
+
+ $(window).on('popstate', function(event) {
+ if(auth_token && auth_username) {
+ apps_select(locationHashValue());
+ }
+ });
}
function apps_cleanup() {
@@ -71,6 +83,8 @@ function apps_cleanup() {
jingles_cleanup();
musicpools_cleanup();
+ $(window).off('popstate');
+
sessionStorage.removeItem("apps_current");
delete apps_current;
}