diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-02 16:38:24 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-02 16:38:24 -0700 |
commit | 62a2e8f81c5dff5b47f064b70b6869f6e4b12996 (patch) | |
tree | e06291d5b22011980e8983507cc0e3ef3ad69c04 /lib/parse/progress.js | |
parent | 6bcc2d8cf24d62ce7a48895cc8ef085f8bc71e4d (diff) | |
download | gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.zip gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.tar.gz gitbook-62a2e8f81c5dff5b47f064b70b6869f6e4b12996.tar.bz2 |
Fix #8: Improve page title
Diffstat (limited to 'lib/parse/progress.js')
-rw-r--r-- | lib/parse/progress.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/parse/progress.js b/lib/parse/progress.js index 73fbbe0..7259e07 100644 --- a/lib/parse/progress.js +++ b/lib/parse/progress.js @@ -2,7 +2,7 @@ var _ = require("lodash"); var calculProgress = function(navigation, current) { var n = _.size(navigation); - var percent = 0, prevPercent = 0; + var percent = 0, prevPercent = 0, currentChapter = null; var done = true; var chapters = _.chain(navigation) @@ -20,6 +20,7 @@ var calculProgress = function(navigation, current) { // Is it done nav.done = done; if (nav.path == current) { + currentChapter = nav; percent = nav.percent; done = false; } else if (done) { @@ -30,11 +31,18 @@ var calculProgress = function(navigation, current) { }) .value(); - return { + // Previous percent prevPercent: prevPercent, + + // Current percent percent: percent, - chapters: chapters + + // List of chapter with progress + chapters: chapters, + + // Current chapter + current: currentChapter }; } |