Update app.js

This commit is contained in:
Namhyeon Go 2020-07-04 21:49:30 +09:00 committed by GitHub
parent 60e23ddad2
commit a671fcb756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

39
app.js
View File

@ -32,25 +32,24 @@
// The appname argument causes <appname>.js to be loaded. The interface returned
// must define main = function(args) {}, which is called once the module is
// loaded.
var messages = [];
var console = {
log: function(msg, status) {
if(typeof(window) !== 'undefined') {
if(typeof(window.jQuery) !== 'undefined') {
log: function(msg, status) {
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);
WScript.quit(status);
}
} else {
messages.push(msg);
}
} else if (typeof(WScript) !== 'undefined') {
WScript.echo(msg);
WScript.quit(status);
}
}
};
@ -116,26 +115,28 @@ function init_console() {
function init_window(name, args, w, h) {
var app = require(name);
// set default size of window
if(typeof(w) !== "undefined" && typeof(h) !== "undefined") {
// "set default size of window";
if (typeof(w) !== "undefined" && typeof(h) !== "undefined") {
window.resizeTo(w, h);
}
// load app
// "load app";
if (app) {
if (app.main) {
app.main.call(app, args);
return true;
var exitstatus = app.main.call(app, args);
if (exitstatus > 0) {
console.log("exit code: " + exitstatus);
}
} else {
return false;
console.log("Error, missing main entry point in " + name + ".js", 1);
}
} else {
return false;
console.log("Error, cannot find " + name + ".js", 1);
}
}
function main() {
if(typeof(window) == 'undefined') {
if (typeof(window) === "undefined") {
init_console();
} else {
console.log("welcome");