Browse Source

EmscriptenApplication: use existing Module object in WindowlessEmscriptenApplication.js as well

pull/480/head
Pablo Escobar 6 years ago
parent
commit
b636fdbe0e
  1. 106
      src/Magnum/Platform/WindowlessEmscriptenApplication.js

106
src/Magnum/Platform/WindowlessEmscriptenApplication.js

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

Loading…
Cancel
Save