diff --git a/lib/std.js b/lib/std.js index f986e3e..33b5b12 100644 --- a/lib/std.js +++ b/lib/std.js @@ -255,16 +255,49 @@ function alert(message) { if (typeof window !== "undefined") { window.alert(message); } else { - CreateObject("WScript.Shell").Popup(message); + try { + CreateObject("WScript.Shell").Popup(message, 0, "WelsonJS", 0); + } catch (e) { + console.error(e.message); + } } } function confirm(message) { + var result; + if (typeof window !== "undefined") { - return window.confirm(message); + result = window.confirm(message); } else { - CreateObject("WScript.Shell").Popup(message); + try { + result = (CreateObject("WScript.Shell").Popup(message, 0, "WelsonJS", 4) == 6); + } catch (e) { + console.error(e.message); + result = false; + } } + + return result; +} + +function prompt(message, _default) { + var result; + + if (typeof window !== "undefined") { + result = window.prompt(message); + } else { + try { + result = CreateObject("WelsonJS.Toolkit").Prompt(message); + } catch (e) { + console.error(e.message); + if (typeof _default !== "undefined") { + result = _default; + console.warn("Use default value:", _default); + } + } + } + + return result; } function parseEnv(s) { @@ -551,8 +584,9 @@ exports.Storage = StdStorage; exports.alert = alert; exports.confirm = confirm; +exports.prompt = prompt; -exports.VERSIONINFO = "WelsonJS Standard Library (std.js) version 0.8.12"; +exports.VERSIONINFO = "WelsonJS Standard Library (std.js) version 0.8.13"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;