mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-12 00:45:14 +00:00
Update app.js, webloader.js
This commit is contained in:
parent
bb996f41a5
commit
4677eba275
54
app.js
54
app.js
|
@ -33,35 +33,34 @@
|
||||||
// must define main = function(args) {}, which is called once the module is
|
// must define main = function(args) {}, which is called once the module is
|
||||||
// loaded.
|
// loaded.
|
||||||
|
|
||||||
var messages = [];
|
var exit = function(status) {
|
||||||
|
if (typeof(WScript) !== "undefined") {
|
||||||
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') {
|
|
||||||
WScript.echo(msg);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(msg, status) {
|
|
||||||
this.log(msg);
|
|
||||||
if (typeof(WScript) !== 'undefined') {
|
|
||||||
WScript.quit(status);
|
WScript.quit(status);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var console = {
|
||||||
|
__messages: [],
|
||||||
|
__echo: function(msg) {
|
||||||
|
if (typeof(WScript) !== "undefined") {
|
||||||
|
WScript.echo(msg);
|
||||||
|
}
|
||||||
|
this.__messages.push(msg);
|
||||||
|
},
|
||||||
|
log: function(msg) {
|
||||||
|
this.__echo(msg);
|
||||||
|
},
|
||||||
|
error: function(msg) {
|
||||||
|
var msg = "[ERROR] " + msg;
|
||||||
|
this.__echo(msg);
|
||||||
},
|
},
|
||||||
info: function(msg) {
|
info: function(msg) {
|
||||||
this.log(msg);
|
var msg = "[INFO] " + msg;
|
||||||
|
this.__echo(msg);
|
||||||
},
|
},
|
||||||
warn: function(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) {
|
if (app.main) {
|
||||||
var exitstatus = app.main.call(app, args);
|
var exitstatus = app.main.call(app, args);
|
||||||
if (exitstatus > 0) {
|
if (exitstatus > 0) {
|
||||||
console.error("error", exitstatus);
|
console.error("error");
|
||||||
|
exit(exitstatus);
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} 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');
|
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";
|
// "less than IE 9";
|
||||||
window.enableEventListener = function(obj) {};
|
window.enableEventListener = function(obj) {};
|
||||||
if (!window.addEventListener) {
|
if (!window.addEventListener) {
|
||||||
|
@ -227,6 +242,7 @@ return {
|
||||||
jQuery.support.cors = true;
|
jQuery.support.cors = true;
|
||||||
|
|
||||||
self.addScript("app/assets/js/jquery.toast-1.3.2.min.js", function(el) {
|
self.addScript("app/assets/js/jquery.toast-1.3.2.min.js", function(el) {
|
||||||
|
var messages = global.console.__messages;
|
||||||
if (messages.length > 0) {
|
if (messages.length > 0) {
|
||||||
for (var i in messages) {
|
for (var i in messages) {
|
||||||
console.log(messages[i]);
|
console.log(messages[i]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user