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:
parent
868b057e02
commit
65fbc6d034
33 changed files with 110 additions and 1804 deletions
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue