1
0
Fork 0
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:
chok 2014-07-07 22:17:33 +02:00
parent 8829d14186
commit 50dba4dbef

View file

@ -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;
}