send ajax statement to the library to save current page

This commit is contained in:
Bala Clark 2011-01-06 18:13:29 +01:00
parent 3aa2f5da84
commit f1636dd3a4

View file

@ -67,7 +67,9 @@ function ComicBook(id, srcs, opts) {
// the current page, can pass a default as a url hash
var pointer = (parseInt(location.hash.substring(1),10) - 1) || 0;
// enables the back button
/**
* enables the back button
**/
function checkHash() {
var hash = parseInt(location.hash.substring(1),10) - 1 || 0;
@ -101,6 +103,16 @@ function ComicBook(id, srcs, opts) {
return (x <= canvas.width / 2) ? 'left' : 'right';
}
/**
* Tell the library app where the user is up to
**/
function setLastPage() {
if (!options.data.comicId) { throw 'options.data.comicId is not set.'; }
$.get('/comic/setlastpage', { page: pointer+1, comic: options.data.comicId }, function(error){
console.log(error);
});
}
/**
* Setup the canvas element for use throughout the class.
*
@ -212,6 +224,8 @@ function ComicBook(id, srcs, opts) {
var page = pages[pointer];
var page2 = pages[pointer + 1];
setLastPage();
if (typeof page !== "object") { throw "invalid page type '"+ typeof page +"'"; }
var width = page.width;