mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-11 00:15:14 +00:00
Update app.js, webloader.js
This commit is contained in:
parent
bb996f41a5
commit
4677eba275
48
app.js
48
app.js
|
@ -33,35 +33,34 @@
|
|||
// must define main = function(args) {}, which is called once the module is
|
||||
// loaded.
|
||||
|
||||
var messages = [];
|
||||
var exit = function(status) {
|
||||
if (typeof(WScript) !== "undefined") {
|
||||
WScript.quit(status);
|
||||
}
|
||||
};
|
||||
|
||||
var console = {
|
||||
log: function(msg) {
|
||||
if (typeof(window) !== 'undefined') {
|
||||
if (typeof(window.jQuery) !== 'undefined') {
|
||||
window.jQuery.toast({
|
||||
heading: "Information",
|
||||
text: msg,
|
||||
icon: "info"
|
||||
});
|
||||
} else {
|
||||
messages.push(msg);
|
||||
}
|
||||
} else if (typeof(WScript) !== 'undefined') {
|
||||
__messages: [],
|
||||
__echo: function(msg) {
|
||||
if (typeof(WScript) !== "undefined") {
|
||||
WScript.echo(msg);
|
||||
}
|
||||
this.__messages.push(msg);
|
||||
},
|
||||
error: function(msg, status) {
|
||||
this.log(msg);
|
||||
if (typeof(WScript) !== 'undefined') {
|
||||
WScript.quit(status);
|
||||
}
|
||||
log: function(msg) {
|
||||
this.__echo(msg);
|
||||
},
|
||||
error: function(msg) {
|
||||
var msg = "[ERROR] " + msg;
|
||||
this.__echo(msg);
|
||||
},
|
||||
info: function(msg) {
|
||||
this.log(msg);
|
||||
var msg = "[INFO] " + msg;
|
||||
this.__echo(msg);
|
||||
},
|
||||
warn: function(msg) {
|
||||
this.log(msg);
|
||||
var msg = "[WARN] " + msg;
|
||||
this.__echo(msg);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -174,13 +173,16 @@ function init_window(name, args, w, h) {
|
|||
if (app.main) {
|
||||
var exitstatus = app.main.call(app, args);
|
||||
if (exitstatus > 0) {
|
||||
console.error("error", exitstatus);
|
||||
console.error("error");
|
||||
exit(exitstatus);
|
||||
}
|
||||
} else {
|
||||
console.error("Error, missing main entry point in " + name + ".js", 1);
|
||||
console.error("Error, missing main entry point in " + name + ".js");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error("Error, cannot find " + name + ".js", 1);
|
||||
console.error("Error, cannot find " + name + ".js");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
webloader.js
16
webloader.js
|
@ -7,6 +7,21 @@
|
|||
*/
|
||||
var FILE = require('lib/file');
|
||||
|
||||
// "override console.__echo()";
|
||||
global.console.__echo = function(msg) {
|
||||
if (typeof(window.jQuery) !== "undefined") {
|
||||
window.jQuery.toast({
|
||||
heading: "Information",
|
||||
text: msg,
|
||||
icon: "info"
|
||||
});
|
||||
} else {
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
global.console.__messages.push(msg);
|
||||
};
|
||||
|
||||
// "less than IE 9";
|
||||
window.enableEventListener = function(obj) {};
|
||||
if (!window.addEventListener) {
|
||||
|
@ -227,6 +242,7 @@ return {
|
|||
jQuery.support.cors = true;
|
||||
|
||||
self.addScript("app/assets/js/jquery.toast-1.3.2.min.js", function(el) {
|
||||
var messages = global.console.__messages;
|
||||
if (messages.length > 0) {
|
||||
for (var i in messages) {
|
||||
console.log(messages[i]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user