Update toolkit.js

This commit is contained in:
Namhyeon Go 2022-03-03 15:11:39 +09:00 committed by GitHub
parent 7aac52026f
commit 5254f16b3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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