This commit is contained in:
Namhyeon Go 2020-11-25 12:16:42 +09:00
parent 50c29aec32
commit 1dd049f015
3 changed files with 39 additions and 19 deletions

11
app.js
View File

@ -42,8 +42,17 @@ var exit = function(status) {
var console = {
_messages: [],
_join: function(args, sep) {
args = args || [];
sep = sep || ' ';
var res = '';
for (var i = args.length - 1; i > -1; i--) {
res = (i ? sep : '') + args[i] + res;
}
return res;
},
_echo: function(args, type) {
msg = (typeof(type) !== "undefined" ? type + ": " : "") + args[0];
msg = (typeof(type) !== "undefined" ? type + ": " : "") + this._join(args);
if (typeof(WScript) !== "undefined") {
WScript.echo(" * " + msg);
}

View File

@ -40,7 +40,7 @@ var readFile = function(FN, charset) {
fsT = null;
return T;
} catch (e) {
console.error("readFile -> " + e.message);
console.error("readFile -> ", e.message);
}
}
};
@ -136,7 +136,7 @@ var FileObject = function() {
this.isDirectory = true;
}
} catch (e) {
console.error("FileObject.exists() -> " + e.message);
console.error("FileObject.exists() -> ", e.message);
}
return this.isExists;
};
@ -150,10 +150,14 @@ var FileObject = function() {
};
this.getDetails = function() {
if (this.isFile) {
return this.interface.GetFile(this.filename);
} else if (this.isDirectory) {
return this.interface.GetFolder(this.filename);
try {
if (this.isFile) {
return this.interface.GetFile(this.filename);
} else if (this.isDirectory) {
return this.interface.GetFolder(this.filename);
}
} catch (e) {
console.error("FileObject.getDetails() -> ", e.message);
}
};
@ -211,7 +215,9 @@ var FileObject = function() {
};
this.mkdir = function() {
return this.interface.CreateFolder(this.filename);
if (this.isDirectory) {
return this.interface.CreateFolder(this.filename);
}
};
this.close = function() {

View File

@ -8,8 +8,8 @@ var OldBrowser = require("lib/oldbrowser");
////////////////////////////////////////////////////////////////////////
// Override global.console._echo()
////////////////////////////////////////////////////////////////////////
global.console._echo = function(msg, type) {
var heading, icon;
global.console._echo = function(args, type) {
var heading, icon, msg = this._join(args);
switch(type) {
case "error":
@ -29,19 +29,24 @@ global.console._echo = function(msg, type) {
default:
heading = "Success";
icon = "success";
return;
}
if (typeof(window.jQuery) !== "undefined") {
window.jQuery.toast({
heading: heading,
text: msg,
icon: icon
});
} else {
window.alert(msg);
try {
if (typeof(window.jQuery.toast) !== "undefined") {
window.jQuery.toast({
heading: heading,
text: msg,
icon: icon
});
} else {
window.alert(msg);
}
} catch (e) {
window.alert(e.message);
}
global.console._messages.push(msg);
this._messages.push(msg);
};
////////////////////////////////////////////////////////////////////////