1 var progress_bar = document.getElementById('progress_bar');
2 var progress_text = document.getElementById('progress_text');
8 return function(text) {
9 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
10 // These replacements are necessary if you render to raw HTML
11 //text = text.replace(/&/g, "&");
12 //text = text.replace(/</g, "<");
13 //text = text.replace(/>/g, ">");
14 //text = text.replace('\n', '<br>', 'g');
18 printErr: function(text) {
19 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
20 if (0) { // XXX disabled for safety typeof dump == 'function') {
21 dump(text + '\n'); // fast, straight to the real console
27 var canvas = document.getElementById('canvas');
29 // As a default initial behavior, pop up an alert when webgl context is lost. To make your
30 // application robust, you may want to override this behavior before shipping!
31 // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
32 canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
36 setStatus: function(text) {
37 var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
40 var perc = parseInt(m[2]) / parseInt(m[4]) * 100;
42 progress_bar.style.width = perc + '%';
43 progress_bar.innerHTML = perc.toFixed(1) + '%';
46 progress_bar.innerHTML = '';
48 progress_text.innerHTML = text;
51 monitorRunDependencies: function(left) {
52 this.totalDependencies = Math.max(this.totalDependencies, left);
53 Module.setStatus('Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')');
56 Module.setStatus('Downloading...');
57 window.onerror = function() {
58 Module.setStatus('Exception thrown, see JavaScript console');
59 Module.setStatus = function(text) {
60 if (text) Module.printErr('[post-exception status] ' + text);