1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

added queue for loading and offline storage of parsed info

This commit is contained in:
Fred Chasen 2013-01-16 12:20:36 -08:00
parent ca3e2c24c2
commit d90fd14ad2
12 changed files with 10017 additions and 47 deletions

View file

@ -9,24 +9,34 @@ FP.Chapter = function(book){
this.chapterPos = 1;
this.leftPos = 0;
this.loadFromStorage();
this.load();
return this;
}
FP.Chapter.prototype.loadFromStorage = function(){
var path = this.path,
file = FP.storage.get(path, this.postLoad.bind(this));
FP.Chapter.prototype.load = function(){
var path = this.path;
if(this.book.online){
this.setIframeSrc(path);
}else{
this.loadFromStorage(path);
}
}
FP.Chapter.prototype.postLoad = function(file){
FP.Chapter.prototype.loadFromStorage = function(path){
var file = FP.storage.get(path, this.setIframeSrc.bind(this));
}
FP.Chapter.prototype.setIframeSrc = function(url){
var that = this;
//-- Not sure if this is the best time to do this, but hide current text
if(this.bodyEl) this.bodyEl.style.visibility = "hidden";
this.iframe.src = file;
this.iframe.src = url;
this.iframe.onload = function() {
//that.bodyEl = that.iframe.contentDocument.documentElement.getElementsByTagName('body')[0];