mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 20:21:03 +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") {
|
||||
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");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
28
webloader.js
28
webloader.js
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user