mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04:58 +00:00
Update toolkit.js
This commit is contained in:
parent
7aac52026f
commit
5254f16b3f
|
@ -15,43 +15,62 @@ var ToolkitObject = function() {
|
|||
}
|
||||
};
|
||||
|
||||
this.getInterface = function() {
|
||||
return this.interface;
|
||||
this.checkIsEnabled = function() {
|
||||
return (this.interface != null);
|
||||
};
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
exports.create = function() {
|
||||
return new ToolkitObject();
|
||||
};
|
||||
var instance = new ToolkitObject();
|
||||
|
||||
exports.getInterface = function() {
|
||||
return exports.create().getInterface();
|
||||
};
|
||||
exports.sendClick = instance.sendClick;
|
||||
exports.sendKeys = instance.sendKeys;
|
||||
exports.alert = instance.alert;
|
||||
exports.confirm = instance.confirm;
|
||||
exports.prompt = instance.prompt;
|
||||
|
||||
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);
|
||||
};
|
||||
exports.VERSIONINFO = "WelsonJS Toolkit (toolkit.js) version 0.2";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user