Update toolkit.js

This commit is contained in:
Namhyeon Go 2022-02-14 15:43:14 +09:00 committed by GitHub
parent 914742a03e
commit 5f18e774fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,12 +10,34 @@ var ToolkitObject = function() {
this.interface = CreateObject("WelsonJS.Toolkit"); this.interface = CreateObject("WelsonJS.Toolkit");
return this; return this;
} catch (e) { } catch (e) {
console.error("ToolkitObject.create() ->", e.message); console.warn("WelsonJS.Toolkit is disabled");
} }
}; };
this.getInterface = function() { this.sendClick = function(wName, x, y, retry) {
return this.interface; var i = 0;
while (i < retry) {
this.interface.SendClick(wName, x, y);
i++;
}
};
this.sendKeys = function(wName, s) {
return this.interface.SendKeys(wName, s);
};
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html
this.alert = function(message) {
return this.interface.Alert(message);
};
this.confirm = function(message) {
return this.interface.Confirm(message);
};
this.prompt = function(message, _default) {
return this.interface.Prompt(message, _default);
}; };
this.create(); this.create();
@ -23,36 +45,9 @@ var ToolkitObject = function() {
var Toolkit = new ToolkitObject(); var Toolkit = new ToolkitObject();
exports.create = function() { exports.create = Toolkit.create();
return new ToolkitObject(); exports.sendClick = Toolkit.sendClick;
}; exports.sendKeys = Toolkit.sendKeys;
exports.alert = Toolkit.alert;
exports.getInterface = function() { exports.confirm = Toolkit.confirm;
return Toolkit.getInterface(); exports.prompt = Toolkit.prompt;
};
exports.sendClick = function(wName, x, y, repeat) {
var i = 0;
while (i < repeat) {
Toolkit.getInterface().SendClick(wName, x, y);
i++;
}
};
exports.sendKeys = function(wName, s) {
return Toolkit.getInterface().SendKeys(wName, s);
};
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html
exports.alert = function(message) {
return Toolkit.getInterface().Alert(message);
};
exports.confirm = function(message) {
return Toolkit.getInterface().Confirm(message);
};
exports.prompt = function(message, _default) {
return Toolkit.getInterface().Prompt(message, _default);
};