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.
*/
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 { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' }[a];
}) + '\n';
},
print: function(message) {
var log = document.getElementById('log');
log.innerHTML += Array.prototype.slice.call(arguments).join(' ')
.replace(/[\"&<>]/g, function (a) {
return { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' }[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 { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' }[a];
}) + '\n';
};
Module.print = function(message) {
var log = document.getElementById('log');
log.innerHTML += Array.prototype.slice.call(arguments).join(' ')
.replace(/[\"&<>]/g, function (a) {
return { '"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;' }[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';
}
};

Loading…
Cancel
Save