mirror of
https://github.com/flynx/PortableMag.git
synced 2025-12-23 12:01:48 +00:00
code cleanup and minor bugs squashed...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4895fed07b
commit
99989e6a6c
62
index.html
62
index.html
@ -378,7 +378,6 @@ function setCurrentPage(n, W){
|
||||
var W = W == null ? cur.width() : W
|
||||
mag.css({left: -n*W})
|
||||
|
||||
window.location.hash = n
|
||||
// XXX should this be here???
|
||||
saveState()
|
||||
|
||||
@ -448,19 +447,50 @@ function prevArticle(){
|
||||
|
||||
|
||||
|
||||
// XXX
|
||||
function loadState(){
|
||||
setCurrentPage(parseInt($.jStorage.get('current_page'), 0))
|
||||
/*********************************************************************/
|
||||
// XXX make these magazine-specific...
|
||||
// URL state managers...
|
||||
function loadURLState(){
|
||||
if(window.location.hash == ''){
|
||||
return 0
|
||||
}
|
||||
var n = parseInt(window.location.hash.split('#')[1])
|
||||
if(n != null){
|
||||
return n
|
||||
} else {
|
||||
alert('textual anchors not yet supported...')
|
||||
return
|
||||
}
|
||||
}
|
||||
function saveURLState(){
|
||||
window.location.hash = getPageNumber()
|
||||
}
|
||||
|
||||
// XXX
|
||||
function saveState(){
|
||||
// XXX make this magazine-specific...
|
||||
// local storage state managers...
|
||||
function loadStorageState(){
|
||||
return parseInt($.jStorage.get('current_page'), 0)
|
||||
}
|
||||
function saveStorageState(){
|
||||
$.jStorage.set('current_page', getPageNumber())
|
||||
}
|
||||
|
||||
// generic state managers...
|
||||
function loadState(){
|
||||
var n = loadURLState()
|
||||
if(n != null){
|
||||
setCurrentPage(n)
|
||||
} else {
|
||||
setCurrentPage(loadStorageState())
|
||||
}
|
||||
}
|
||||
function saveState(){
|
||||
saveURLState()
|
||||
saveStorageState()
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
// XXX create magazine...
|
||||
function createMagazine(){
|
||||
}
|
||||
@ -485,13 +515,7 @@ $(document).ready(function(){
|
||||
fitNPages(PAGES_VISIBLE)
|
||||
})
|
||||
.bind('hashchange', function(){
|
||||
// XXX this is the same as the init code below...
|
||||
var n = parseInt(window.location.hash.split('#')[1])
|
||||
if(n != null){
|
||||
setCurrentPage(n)
|
||||
} else {
|
||||
alert('textual anchors not yet supported...')
|
||||
}
|
||||
setCurrentPage(loadURLState())
|
||||
})
|
||||
|
||||
$('.viewer')
|
||||
@ -519,16 +543,7 @@ $(document).ready(function(){
|
||||
$('.button.next-article').swipe({click: nextArticle})
|
||||
$('.button.prev-article').swipe({click: prevArticle})
|
||||
|
||||
if(window.location.hash == ''){
|
||||
loadState()
|
||||
} else {
|
||||
var n = parseInt(window.location.hash.split('#')[1])
|
||||
if(n != null){
|
||||
setCurrentPage(n)
|
||||
} else {
|
||||
alert('textual anchors not yet supported...')
|
||||
}
|
||||
}
|
||||
|
||||
togglePageView('on')
|
||||
|
||||
@ -540,7 +555,6 @@ $(document).ready(function(){
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user