mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
[toc] only first level navpoint
This commit is contained in:
parent
8829d14186
commit
50dba4dbef
1 changed files with 7 additions and 9 deletions
|
@ -332,15 +332,14 @@ EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){
|
|||
|
||||
function getTOC(parent){
|
||||
var list = [],
|
||||
nodes = parent.querySelectorAll("navPoint"),
|
||||
items = Array.prototype.slice.call(nodes).reverse(),
|
||||
length = items.length,
|
||||
iter = length,
|
||||
node;
|
||||
snapshot = tocXml.evaluate("*[local-name()='navPoint']", parent, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null),
|
||||
length = snapshot.snapshotLength;
|
||||
|
||||
if(length === 0) return [];
|
||||
|
||||
items.forEach(function(item){
|
||||
for ( var i=length-1 ; i >= 0; i-- ) {
|
||||
var item = snapshot.snapshotItem(i);
|
||||
|
||||
var id = item.getAttribute('id') || false,
|
||||
content = item.querySelector("content"),
|
||||
src = content.getAttribute('src'),
|
||||
|
@ -362,8 +361,7 @@ EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){
|
|||
id = 'epubjs-autogen-toc-id-' + (idCounter++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
list.unshift({
|
||||
"id": id,
|
||||
"href": src,
|
||||
|
@ -374,7 +372,7 @@ EPUBJS.Parser.prototype.toc = function(tocXml, spineIndexByURL, bookSpine){
|
|||
"cfi" : cfi
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue