diff --git a/src/Magnum/Platform/WindowlessEmscriptenApplication.js b/src/Magnum/Platform/WindowlessEmscriptenApplication.js index 9ef86a063..d7c239f01 100644 --- a/src/Magnum/Platform/WindowlessEmscriptenApplication.js +++ b/src/Magnum/Platform/WindowlessEmscriptenApplication.js @@ -23,59 +23,59 @@ DEALINGS IN THE SOFTWARE. */ -var Module = { - preRun: [], - postRun: [], - - arguments: [], - - doNotCaptureKeyboard: true, - - printErr: function(message) { - var log = document.getElementById('log'); - log.innerHTML += Array.prototype.slice.call(arguments).join(' ') - .replace(/[\"&<>]/g, function (a) { - return { '"': '"', '&': '&', '<': '<', '>': '>' }[a]; - }) + '\n'; - }, - - print: function(message) { - var log = document.getElementById('log'); - log.innerHTML += Array.prototype.slice.call(arguments).join(' ') - .replace(/[\"&<>]/g, function (a) { - return { '"': '"', '&': '&', '<': '<', '>': '>' }[a]; - }) + '\n'; - }, - - /* onAbort not handled here, as the output is printed directly on the page */ - - canvas: document.getElementById('canvas'), - status: document.getElementById('status'), - statusDescription: document.getElementById('status-description'), - log: document.getElementById('log'), - - setStatus: function(message) { - if(Module.status) Module.status.innerHTML = message; - }, - - setStatusDescription: function(message) { - if(Module.statusDescription) - Module.statusDescription.innerHTML = message; - }, - - totalDependencies: 0, - - monitorRunDependencies: function(left) { - this.totalDependencies = Math.max(this.totalDependencies, left); - - if(left) { - Module.setStatus('Downloading...'); - Module.setStatusDescription((this.totalDependencies - left) + ' / ' + this.totalDependencies); - } else { - Module.setStatus('Download complete'); - Module.setStatusDescription(''); - Module.log.style.display = 'block'; - } +var Module = typeof Module !== "undefined" ? Module : {}; + +Module.preRun = []; +Module.postRun = []; + +Module.arguments = []; + +Module.doNotCaptureKeyboard = true; + +Module.printErr = function(message) { + var log = document.getElementById('log'); + log.innerHTML += Array.prototype.slice.call(arguments).join(' ') + .replace(/[\"&<>]/g, function (a) { + return { '"': '"', '&': '&', '<': '<', '>': '>' }[a]; + }) + '\n'; +}; + +Module.print = function(message) { + var log = document.getElementById('log'); + log.innerHTML += Array.prototype.slice.call(arguments).join(' ') + .replace(/[\"&<>]/g, function (a) { + return { '"': '"', '&': '&', '<': '<', '>': '>' }[a]; + }) + '\n'; +}; + +/* onAbort not handled here, as the output is printed directly on the page */ + +Module.canvas = document.getElementById('canvas'); +Module.status = document.getElementById('status'); +Module.statusDescription = document.getElementById('status-description'); +Module.log = document.getElementById('log'); + +Module.setStatus = function(message) { + if(Module.status) Module.status.innerHTML = message; +}; + +Module.setStatusDescription = function(message) { + if(Module.statusDescription) + Module.statusDescription.innerHTML = message; +}; + +Module.totalDependencies = 0; + +Module.monitorRunDependencies = function(left) { + this.totalDependencies = Math.max(this.totalDependencies, left); + + if(left) { + Module.setStatus('Downloading...'); + Module.setStatusDescription((this.totalDependencies - left) + ' / ' + this.totalDependencies); + } else { + Module.setStatus('Download complete'); + Module.setStatusDescription(''); + Module.log.style.display = 'block'; } };