diff --git a/epub.js b/epub.js index 248d57f..ef9cf67 100644 --- a/epub.js +++ b/epub.js @@ -413,9 +413,14 @@ EPub.prototype.parseSpine = function(spine){ * Parses ncx file for table of contents (title, html file) **/ EPub.prototype.parseTOC = function(){ - var path = this.spine.toc.href.split("/"); + var path = this.spine.toc.href.split("/"), id_list = {}, keys; path.pop(); + keys = Object.keys(this.manifest); + for(var i=0, len = keys.length; i Array + * EPub#walkNavMap(branch, path, id_list,[, level]) -> Array * - branch (Array | Object): NCX NavPoint object * - path (Array): Base path + * - id_list (Object): map of file paths and id values * - level (Number): deepness * * Walks the NavMap object through all levels and finds elements * for TOC **/ -EPub.prototype.walkNavMap = function(branch, path, level){ - level || level || 0; +EPub.prototype.walkNavMap = function(branch, path, id_list, level){ + level = level || 0; + + // don't go too far if(level>7)return []; - var output = [], element; + var output = [], element, id, title, order, href; if(!Array.isArray(branch)){ branch = [branch]; @@ -463,20 +471,38 @@ EPub.prototype.walkNavMap = function(branch, path, level){ for(var i=0, len = branch.length; i