mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 00:21:40 +00:00
added support for browser history...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f56d6c44c0
commit
67ee054587
18
index.html
18
index.html
@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>pWiki</title>
|
||||||
|
</head>
|
||||||
<style>
|
<style>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -23,9 +26,18 @@ var reload = () => {
|
|||||||
// XXX save...
|
// XXX save...
|
||||||
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
||||||
localStorage['wiki-location'] = Wiki.location
|
localStorage['wiki-location'] = Wiki.location
|
||||||
|
|
||||||
|
$('title').text(Wiki.location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX add history support...
|
||||||
var go = (path) => {
|
var go = (path) => {
|
||||||
|
history.pushState({
|
||||||
|
wikipath: path
|
||||||
|
},
|
||||||
|
Wiki.title,
|
||||||
|
window.location)
|
||||||
|
|
||||||
Wiki.location = path
|
Wiki.location = path
|
||||||
reload()
|
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...
|
// load stored data...
|
||||||
Wiki.__wiki_data = localStorage['wiki-data'] ?
|
Wiki.__wiki_data = localStorage['wiki-data'] ?
|
||||||
JSON.parse(localStorage['wiki-data'])
|
JSON.parse(localStorage['wiki-data'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user