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

Added online toggle

This commit is contained in:
Fred Chasen 2013-01-23 11:28:09 -08:00
parent 868b057e02
commit 65fbc6d034
33 changed files with 110 additions and 1804 deletions

View file

@ -200,20 +200,26 @@ FP.Chapter.prototype.replaceLinks = function(callback){
items = Array.prototype.slice.call(links),
count = items.length;
items.forEach(function(link){
var path,
href = link.getAttribute("href"),
src = link.getAttribute("src"),
full = href ? this.book.basePath + href : this.book.basePath + src;
FP.storage.get(full, function(url){
if(href) link.setAttribute("href", url);
if(src) link.setAttribute("src", url);
count--;
if(count <= 0 && callback) callback();
});
}.bind(this));
if(FP.storage.getStorageType() == "filesystem") {
//-- filesystem api links are relative, so no need to fix
if(callback) callback();
return false;
}
items.forEach(function(link){
var path,
href = link.getAttribute("href"),
src = link.getAttribute("src"),
full = href ? this.book.basePath + href : this.book.basePath + src;
FP.storage.get(full, function(url){
if(href) link.setAttribute("href", url);
if(src) link.setAttribute("src", url);
count--;
if(count <= 0 && callback) callback();
});
}.bind(this));
}