diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-07-23 13:18:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-07-23 13:18:20 -0700 |
commit | a389d5daf6446dfd0c703c362b042b19b8d9578f (patch) | |
tree | 4ba27497068cae2909d79edf332faea31ec2a202 | |
parent | 94b682b2272a96e5af7b44c573ebbb7fc6f168b1 (diff) |
add progress to shell.html
-rw-r--r-- | src/shell.html | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/src/shell.html b/src/shell.html index 336f926d..23b3323b 100644 --- a/src/shell.html +++ b/src/shell.html @@ -14,6 +14,7 @@ <body> <hr/> <div class="emscripten" id="status">Downloading...</div> + <progress value="0" max="100" id="progress" hidden=1></progress> <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> <hr/> <div class="emscripten"><input type="button" value="fullscreen" onclick="Module.requestFullScreen()"></div> @@ -46,22 +47,35 @@ } }, canvas: document.getElementById('canvas'), - setStatus: function(text) { - if (Module.setStatus.interval) clearInterval(Module.setStatus.interval); - document.getElementById('status').innerHTML = text; - if (text) { - var counter = 0; - Module.setStatus.interval = setInterval(function() { - counter++; - counter %= 3; - var dots = ' '; - for (var i = 0; i < counter; i++) dots += '.'; - dots += '*'; - for (var i = counter; i < 2; i++) dots += '.'; - document.getElementById('status').innerHTML = text.replace('...', dots); - }, 300); - } - }, + setStatus: function(text) { + if (Module.setStatus.interval) clearInterval(Module.setStatus.interval); + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + var statusElement = document.getElementById('status'); + var progressElement = document.getElementById('progress'); + if (m) { + text = m[1]; + progressElement.value = parseInt(m[2])*100; + progressElement.max = parseInt(m[4])*100; + progressElement.hidden = false; + } else { + progressElement.value = null; + progressElement.max = null; + progressElement.hidden = true; + } + statusElement.innerHTML = text; + if (text) { + var counter = 0; + Module.setStatus.interval = setInterval(function() { + counter++; + counter %= 3; + var dots = ' '; + for (var i = 0; i < counter; i++) dots += '.'; + dots += '*'; + for (var i = counter; i < 2; i++) dots += '.'; + statusElement.innerHTML = text.replace('...', dots); + }, 300); + } + }, totalDependencies: 0, monitorRunDependencies: function(left) { this.totalDependencies = Math.max(this.totalDependencies, left); |