From 0e440231a3a7f82576fb575d19aec01e3eb8d2b9 Mon Sep 17 00:00:00 2001 From: cat Date: Thu, 2 Jan 2014 12:35:13 +0100 Subject: [PATCH] LSP: back button support --- lsp/main.js | 14 ++++++++++++++ lsp/pages.js | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/lsp/main.js b/lsp/main.js index 776d2176..82cdd0e7 100755 --- a/lsp/main.js +++ b/lsp/main.js @@ -1077,3 +1077,17 @@ $(function(){ }); }); +$(window).on('hashchange', function(e) { + if (ignoreHashChange) { + ignoreHashChange = false; + return; + } + var loc = location.hash.split('&')[1].split('@'); + if (loc[1]) { + showTab(loc[0],loc[1]); + } + else { + showTab(loc[0]); + } + ignoreHashChange = false; +}); \ No newline at end of file diff --git a/lsp/pages.js b/lsp/pages.js index a3da11f7..8e87797d 100755 --- a/lsp/pages.js +++ b/lsp/pages.js @@ -6,6 +6,12 @@ var defaults = { }; function showTab(tabName,streamName) { + + ignoreHashChange = true; + location.hash = location.hash.split('&')[0]+'&'+tabName+(streamName ? '@'+streamName : ''); + + + $('#menu .button').removeClass('current').filter(function(i){ return $(this).text().toLowerCase() == tabName; }).addClass('current'); @@ -45,6 +51,7 @@ function showTab(tabName,streamName) { if (applyInput() === false) { return; } + ignoreHashChange = true; location.hash = settings.credentials.username+'@'+settings.server; $('#user_and_host').text(settings.credentials.username+' @ '+settings.server);