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 = { var console = {
_messages: [], _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) { _echo: function(args, type) {
msg = (typeof(type) !== "undefined" ? type + ": " : "") + args[0]; msg = (typeof(type) !== "undefined" ? type + ": " : "") + this._join(args);
if (typeof(WScript) !== "undefined") { if (typeof(WScript) !== "undefined") {
WScript.echo(" * " + msg); WScript.echo(" * " + msg);
} }

View File

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

View File

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