mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 13:41:05 +00:00
fix console toast
This commit is contained in:
parent
2f57d4860f
commit
512b8e845f
20
app.js
20
app.js
|
@ -36,38 +36,32 @@ var exit = function(status) {
|
||||||
if (typeof(WScript) !== "undefined") {
|
if (typeof(WScript) !== "undefined") {
|
||||||
WScript.quit(status);
|
WScript.quit(status);
|
||||||
}
|
}
|
||||||
console.warn("Exit caused by: " + status);
|
console.warn("Exit caused: " + status);
|
||||||
};
|
};
|
||||||
|
|
||||||
var console = {
|
var console = {
|
||||||
_messages: [],
|
_messages: [],
|
||||||
_echo: function(msg) {
|
_echo: function(msg, type) {
|
||||||
|
msg = (typeof(type) !== "undefined" ? type + ": " : "") + msg;
|
||||||
if (typeof(WScript) !== "undefined") {
|
if (typeof(WScript) !== "undefined") {
|
||||||
WScript.echo(msg);
|
WScript.echo(msg);
|
||||||
} else if (typeof(window) !== "undefined") {
|
|
||||||
//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;
|
this._echo(msg, "error");
|
||||||
this._echo(msg);
|
|
||||||
},
|
},
|
||||||
info: function(msg) {
|
info: function(msg) {
|
||||||
var msg = "[INFO] " + msg;
|
this._echo(msg, "info");
|
||||||
this._echo(msg);
|
|
||||||
},
|
},
|
||||||
warn: function(msg) {
|
warn: function(msg) {
|
||||||
var msg = "[WARN] " + msg;
|
this._echo(msg, "warn");
|
||||||
this._echo(msg);
|
|
||||||
},
|
},
|
||||||
debug: function(msg) {
|
debug: function(msg) {
|
||||||
var msg = "[DEBUG] " + msg;
|
this._echo(msg, "debug");
|
||||||
this._echo(msg);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
28
webloader.js
28
webloader.js
|
@ -7,12 +7,34 @@ var OldBrowser = require("lib/oldbrowser");
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Override global.console._echo()
|
// 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") {
|
if (typeof(window.jQuery) !== "undefined") {
|
||||||
window.jQuery.toast({
|
window.jQuery.toast({
|
||||||
heading: "Information",
|
heading: heading,
|
||||||
text: msg,
|
text: msg,
|
||||||
icon: "info"
|
icon: icon
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
window.alert(msg);
|
window.alert(msg);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user