mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-08 12:46:05 +00:00
Update app.js
This commit is contained in:
parent
60e23ddad2
commit
a671fcb756
39
app.js
39
app.js
|
@ -32,25 +32,24 @@
|
||||||
// The appname argument causes <appname>.js to be loaded. The interface returned
|
// The appname argument causes <appname>.js to be loaded. The interface returned
|
||||||
// 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 messages = [];
|
||||||
|
|
||||||
var console = {
|
var console = {
|
||||||
log: function(msg, status) {
|
log: function(msg, status) {
|
||||||
if(typeof(window) !== 'undefined') {
|
if (typeof(window) !== 'undefined') {
|
||||||
if(typeof(window.jQuery) !== 'undefined') {
|
if (typeof(window.jQuery) !== 'undefined') {
|
||||||
window.jQuery.toast({
|
window.jQuery.toast({
|
||||||
heading: "Information",
|
heading: "Information",
|
||||||
text: msg,
|
text: msg,
|
||||||
icon: "info"
|
icon: "info"
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
messages.push(msg);
|
messages.push(msg);
|
||||||
}
|
}
|
||||||
} else if(typeof(WScript) !== 'undefined') {
|
} else if (typeof(WScript) !== 'undefined') {
|
||||||
WScript.echo(msg);
|
WScript.echo(msg);
|
||||||
WScript.quit(status);
|
WScript.quit(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,26 +115,28 @@ function init_console() {
|
||||||
function init_window(name, args, w, h) {
|
function init_window(name, args, w, h) {
|
||||||
var app = require(name);
|
var app = require(name);
|
||||||
|
|
||||||
// set default size of window
|
// "set default size of window";
|
||||||
if(typeof(w) !== "undefined" && typeof(h) !== "undefined") {
|
if (typeof(w) !== "undefined" && typeof(h) !== "undefined") {
|
||||||
window.resizeTo(w, h);
|
window.resizeTo(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load app
|
// "load app";
|
||||||
if (app) {
|
if (app) {
|
||||||
if (app.main) {
|
if (app.main) {
|
||||||
app.main.call(app, args);
|
var exitstatus = app.main.call(app, args);
|
||||||
return true;
|
if (exitstatus > 0) {
|
||||||
|
console.log("exit code: " + exitstatus);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
console.log("Error, missing main entry point in " + name + ".js", 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
console.log("Error, cannot find " + name + ".js", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
if(typeof(window) == 'undefined') {
|
if (typeof(window) === "undefined") {
|
||||||
init_console();
|
init_console();
|
||||||
} else {
|
} else {
|
||||||
console.log("welcome");
|
console.log("welcome");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user