From b4f333ca810c739ff382ba8519a8d07a6a9de416 Mon Sep 17 00:00:00 2001 From: andris9 Date: Mon, 13 Jun 2011 13:11:29 +0300 Subject: [PATCH] Fixed TOC level bug + linked id values --- epub.js | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) 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