From 81b562233188569b66fc2fb2a7ff952bdae0a4ec Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 28 Jul 2022 01:32:49 -0400 Subject: Sending user options to the server --- scripts/gui/input.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'scripts/gui/input.js') diff --git a/scripts/gui/input.js b/scripts/gui/input.js index da19d95..24450f0 100644 --- a/scripts/gui/input.js +++ b/scripts/gui/input.js @@ -48,6 +48,13 @@ class MakeInput { return el; } + static buttonInput (text) + { + let el = MakeInput.createInput("button", false, false); + el.textContent = text; + return el; + } + static passwordInput (value, placeholder) { let el = MakeInput.createInput("password"); @@ -302,8 +309,10 @@ class Settings extends EventTarget { applyEvents (template) { for(let key in template) { - if(typeof MakeInput[template[key].type+"Input"] != null) - this.settings[key].el.onchange = (function () {this.dispatchEvent(new CustomEvent("change"));}).bind(this); + if (template[key].type == "button") + this.settings[key].el.onclick = (function() {this.dispatchEvent(new CustomEvent("click", {detail: key}))}).bind(this); + else if(typeof MakeInput[template[key].type+"Input"] != null) + this.settings[key].el.onchange = (function () {this.dispatchEvent(new CustomEvent("change", {detail: key}));}).bind(this); } } -- cgit v1.2.3