diff --git a/lib/toolkit.js b/lib/toolkit.js index ba88c28..0b29a69 100644 --- a/lib/toolkit.js +++ b/lib/toolkit.js @@ -15,62 +15,43 @@ var ToolkitObject = function() { } }; - this.checkIsEnabled = function() { - return (this.interface != null); + this.getInterface = function() { + return this.interface; }; - this.sendClick = function(wName, x, y, retry) { - if (!this.checkIsEnabled()) - return; - - var i = 0; - while (i < retry) { - this.interface.SendClick(wName, x, y); - i++; - } - }; - - this.sendKey = function(wName, s) { - if (!this.checkIsEnabled()) - return; - - return this.interface.SendKeys(wName, s); - }; - - // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html - - this.alert = function(message) { - if (!this.checkIsEnabled()) - return; - - return this.interface.Alert(message); - }; - - this.confirm = function(message) { - if (!this.checkIsEnabled()) - return; - - return this.interface.Confirm(message); - }; - - this.prompt = function(message, _default) { - if (!this.checkIsEnabled()) - return; - - return this.interface.Prompt(message, _default); - }; - this.create(); }; -var instance = new ToolkitObject(); +exports.create = function() { + return new ToolkitObject(); +}; -exports.sendClick = instance.sendClick; -exports.sendKeys = instance.sendKeys; -exports.alert = instance.alert; -exports.confirm = instance.confirm; -exports.prompt = instance.prompt; +exports.getInterface = function() { + return exports.create().getInterface(); +}; -exports.VERSIONINFO = "WelsonJS Toolkit (toolkit.js) version 0.2"; -exports.global = global; -exports.require = global.require; +exports.sendClick = function(wName, x, y, retry) { + var i = 0; + while (i < retry) { + exports.getInterface().SendClick(wName, x, y); + i++; + } +}; + +exports.sendKeys = function(wName, s) { + return exports.getInterface().SendKeys(wName, s); +}; + +// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html + +exports.alert = function(message) { + return exports.getInterface().Alert(message); +}; + +exports.confirm = function(message) { + return exports.getInterface().Confirm(message); +}; + +exports.prompt = function(message, _default) { + return exports.getInterface().Prompt(message, _default); +};