summaryrefslogtreecommitdiffstats
path: root/lib/parse/progress.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-02 16:38:24 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-02 16:38:24 -0700
commit62a2e8f81c5dff5b47f064b70b6869f6e4b12996 (patch)
treee06291d5b22011980e8983507cc0e3ef3ad69c04 /lib/parse/progress.js
parent6bcc2d8cf24d62ce7a48895cc8ef085f8bc71e4d (diff)
downloadgitbook-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.js14
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
};
}