Update toolkit.js

This commit is contained in:
Namhyeon Go 2022-03-03 16:16:08 +09:00 committed by GitHub
parent 5254f16b3f
commit 1050cd66a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,62 +15,43 @@ var ToolkitObject = function() {
} }
}; };
this.checkIsEnabled = function() { this.getInterface = function() {
return (this.interface != null); 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(); this.create();
}; };
var instance = new ToolkitObject(); exports.create = function() {
return new ToolkitObject();
};
exports.sendClick = instance.sendClick; exports.getInterface = function() {
exports.sendKeys = instance.sendKeys; return exports.create().getInterface();
exports.alert = instance.alert; };
exports.confirm = instance.confirm;
exports.prompt = instance.prompt;
exports.VERSIONINFO = "WelsonJS Toolkit (toolkit.js) version 0.2"; exports.sendClick = function(wName, x, y, retry) {
exports.global = global; var i = 0;
exports.require = global.require; 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);
};