fix console toast

This commit is contained in:
Namhyeon Go 2020-11-04 18:32:25 +09:00
parent 2f57d4860f
commit 512b8e845f
2 changed files with 32 additions and 16 deletions

20
app.js
View File

@ -36,38 +36,32 @@ var exit = function(status) {
if (typeof(WScript) !== "undefined") {
WScript.quit(status);
}
console.warn("Exit caused by: " + status);
console.warn("Exit caused: " + status);
};
var console = {
_messages: [],
_echo: function(msg) {
_echo: function(msg, type) {
msg = (typeof(type) !== "undefined" ? type + ": " : "") + msg;
if (typeof(WScript) !== "undefined") {
WScript.echo(msg);
} else if (typeof(window) !== "undefined") {
//window.alert(msg);
}
this._messages.push(msg);
},
log: function(msg) {
this._echo(msg);
},
error: function(msg) {
var msg = "[ERROR] " + msg;
this._echo(msg);
this._echo(msg, "error");
},
info: function(msg) {
var msg = "[INFO] " + msg;
this._echo(msg);
this._echo(msg, "info");
},
warn: function(msg) {
var msg = "[WARN] " + msg;
this._echo(msg);
this._echo(msg, "warn");
},
debug: function(msg) {
var msg = "[DEBUG] " + msg;
this._echo(msg);
this._echo(msg, "debug");
}
};

View File

@ -7,12 +7,34 @@ var OldBrowser = require("lib/oldbrowser");
////////////////////////////////////////////////////////////////////////
// Override global.console._echo()
////////////////////////////////////////////////////////////////////////
global.console._echo = function(msg) {
global.console._echo = function(msg, type) {
var heading, icon;
switch(type) {
case "error":
heading = "Error";
icon = "error";
break;
case "warning":
heading = "Warning";
icon = "warning";
break;
case "info":
heading = "Information";
icon = "info";
default:
heading = "Message";
icon = "success";
}
if (typeof(window.jQuery) !== "undefined") {
window.jQuery.toast({
heading: "Information",
heading: heading,
text: msg,
icon: "info"
icon: icon
});
} else {
window.alert(msg);