From 67ee054587875bdd13a2419b8852fee35446ce7f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 7 Jul 2016 05:27:03 +0300 Subject: [PATCH] added support for browser history... Signed-off-by: Alex A. Naanou --- index.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/index.html b/index.html index 56a1229..5740cea 100755 --- a/index.html +++ b/index.html @@ -1,5 +1,8 @@ + +pWiki + @@ -23,9 +26,18 @@ var reload = () => { // XXX save... localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data) localStorage['wiki-location'] = Wiki.location + + $('title').text(Wiki.location) } +// XXX add history support... var go = (path) => { + history.pushState({ + wikipath: path + }, + Wiki.title, + window.location) + Wiki.location = path reload() } @@ -49,6 +61,12 @@ var activateWikiWords = text => $(() => { + $(window).on('popstate', function(evt){ + event.state + && event.state.wikipath + && go(event.state.wikipath) + }) + // load stored data... Wiki.__wiki_data = localStorage['wiki-data'] ? JSON.parse(localStorage['wiki-data'])