diff options
author | Freeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace> | 2013-03-23 18:37:24 +1300 |
---|---|---|
committer | Freeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace> | 2013-03-29 15:03:37 +1300 |
commit | ef44d7d853f7fa313eda98967e06869fc691f3b7 (patch) | |
tree | 8a3adb90d63ba7fe4c5cd0a6a5e3c2df9030d734 /js/util/progress.js | |
parent | 6b2e5432d1529b63793ea32a20068d441f2dc193 (diff) | |
download | manavis-ef44d7d853f7fa313eda98967e06869fc691f3b7.tar.gz manavis-ef44d7d853f7fa313eda98967e06869fc691f3b7.tar.bz2 manavis-ef44d7d853f7fa313eda98967e06869fc691f3b7.tar.xz manavis-ef44d7d853f7fa313eda98967e06869fc691f3b7.zip |
Load files, parse GAINXP records
Diffstat (limited to 'js/util/progress.js')
-rw-r--r-- | js/util/progress.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/util/progress.js b/js/util/progress.js new file mode 100644 index 0000000..060e6dc --- /dev/null +++ b/js/util/progress.js @@ -0,0 +1,37 @@ +function progress(root) { + var _progress = {}; + var container = document.getElementById(root); + var _percent = '0%'; + var bar = document.querySelector('#' + root + ' .percent'); + _progress.label = function() { + return _percent; + } + /* Updates the progress bar to display a specific percentage. No range checking performed. */ + _progress.setPercent = function(percent) { + _percent = percent; + bar.style.width = _percent; + bar.textContent = _progress.label(); + } + /* Updates the progress bar to display a percentage based on the current proportion of items done. */ + _progress.update = function(current, total) { + var percentLoaded = Math.min(100, Math.round((current / total) * 100)); + _progress.setPercent(percentLoaded + '%'); + }; + /* Resets the progress bar to display nothing done. */ + _progress.reset = function() { + _progress.setPercent('0%'); + } + /* Resets the progress bar to display everything done. */ + _progress.complete = function() { + _progress.setPercent('100%'); + } + /* Shows the progress bar. */ + _progress.show = function() { + container.className += ' loading'; + } + /* Hides the progress bar */ + _progress.hide = function() { + container.className = container.className.replace(/\bloading\b/, ''); + } + return _progress; +} |