This commit is contained in:
Namhyeon Go 2020-11-04 16:41:56 +09:00
parent 1bc26285a2
commit 5b72133388
2 changed files with 17 additions and 14 deletions

16
app.js
View File

@ -40,34 +40,34 @@ var exit = function(status) {
}; };
var console = { var console = {
__messages: [], _messages: [],
__echo: function(msg) { _echo: function(msg) {
if (typeof(WScript) !== "undefined") { if (typeof(WScript) !== "undefined") {
WScript.echo(msg); WScript.echo(msg);
} else if (typeof(window) !== "undefined") { } else if (typeof(window) !== "undefined") {
window.alert(msg); window.alert(msg);
} }
this.__messages.push(msg); this._messages.push(msg);
}, },
log: function(msg) { log: function(msg) {
this.__echo(msg); this._echo(msg);
}, },
error: function(msg) { error: function(msg) {
var msg = "[ERROR] " + msg; var msg = "[ERROR] " + msg;
this.__echo(msg); this._echo(msg);
}, },
info: function(msg) { info: function(msg) {
var msg = "[INFO] " + msg; var msg = "[INFO] " + msg;
this.__echo(msg); this._echo(msg);
}, },
warn: function(msg) { warn: function(msg) {
var msg = "[WARN] " + msg; var msg = "[WARN] " + msg;
this.__echo(msg); this._echo(msg);
}, },
debug: function(msg) { debug: function(msg) {
var msg = "[DEBUG] " + msg; var msg = "[DEBUG] " + msg;
this.__echo(msg); this._echo(msg);
} }
}; };

View File

@ -5,9 +5,9 @@ var FILE = require("lib/file");
var OldBrowser = require("lib/oldbrowser"); var OldBrowser = require("lib/oldbrowser");
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Override global.console.__echo() // Override global.console._echo()
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
global.console.__echo = function(msg) { global.console._echo = function(msg) {
if (typeof(window.jQuery) !== "undefined") { if (typeof(window.jQuery) !== "undefined") {
window.jQuery.toast({ window.jQuery.toast({
heading: "Information", heading: "Information",
@ -15,10 +15,10 @@ global.console.__echo = function(msg) {
icon: "info" icon: "info"
}); });
} else { } else {
alert(msg); window.alert(msg);
} }
global.console.__messages.push(msg); global.console._messages.push(msg);
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -78,8 +78,9 @@ exports.main = function(args) {
jQuery.support.cors = true; jQuery.support.cors = true;
OldBrowser.addScript("app/assets/js/jquery.toast-1.3.2.min.js", function(el) { OldBrowser.addScript("app/assets/js/jquery.toast-1.3.2.min.js", function(el) {
var messages = global.console.__messages; var messages = global.console._messages;
if (messages.length > 0) { if (messages.length > 0) {
// print messages
for (var i in messages) { for (var i in messages) {
console.log(messages[i]); console.log(messages[i]);
} }
@ -95,10 +96,12 @@ exports.main = function(args) {
}); });
}); });
// hook drag and drop // hook drag event
document.body.ondragstart = function() { document.body.ondragstart = function() {
return false; return false;
}; };
// hook drop event
document.body.ondrop = function() { document.body.ondrop = function() {
return false; return false;
}; };