diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-03-31 22:27:25 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-03-31 22:27:25 -0700 |
commit | 8edd5e4b3bcef7c84bf0b557a80e3e93e8f47e23 (patch) | |
tree | 4b461eb0fd079105c6e30843ea913765b3a53950 /assets/javascript/progress.js | |
parent | 642a338cb062f39628407c136892fe5f328366f9 (diff) | |
download | gitbook-8edd5e4b3bcef7c84bf0b557a80e3e93e8f47e23.zip gitbook-8edd5e4b3bcef7c84bf0b557a80e3e93e8f47e23.tar.gz gitbook-8edd5e4b3bcef7c84bf0b557a80e3e93e8f47e23.tar.bz2 |
Signal and mark progress
Diffstat (limited to 'assets/javascript/progress.js')
-rw-r--r-- | assets/javascript/progress.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/assets/javascript/progress.js b/assets/javascript/progress.js deleted file mode 100644 index bf4b54d..0000000 --- a/assets/javascript/progress.js +++ /dev/null @@ -1,61 +0,0 @@ -define([ - "lodash", - "jQuery", - "utils/storage" -], function(_, $, storage) { - // Get current level - var getCurrentLevel = function() { - return $(".book").data("level"); - }; - - // Return all levels - var getLevels = function() { - var levels = $(".book-summary li[data-level]"); - return _.map(levels, function(level) { - return $(level).data("level").toString(); - }); - }; - - // Return a map chapter -> number (timestamp) - var getProgress = function() { - // Current level - var progress = storage.get("progress", {}); - - // Levels - var levels = getLevels(); - - _.each(levels, function(level) { - progress[level] = progress[level] || 0; - }); - - return progress; - }; - - // Change value of progress for a level - var markProgress = function(level, state) { - if (state == null) state = true; - - var progress = getProgress(); - progress[level] = state? Date.now() : 0; - - storage.set("progress", progress); - }; - - // Show progress - var showProgress = function() { - var progress = getProgress(); - var $summary = $(".book-summary"); - - _.each(progress, function(value, level) { - $summary.find("li[data-level='"+level+"']").toggleClass("done", value > 0); - }); - }; - - return { - 'current': getCurrentLevel, - 'levels': getLevels, - 'get': getProgress, - 'mark': markProgress, - 'show': showProgress - }; -});
\ No newline at end of file |