diff --git a/scripts/interface.js b/scripts/interface.js index 442109c..0b89b62 100644 --- a/scripts/interface.js +++ b/scripts/interface.js @@ -111,7 +111,7 @@ class FormElement extends InterfaceElement { break; case "button": this.handle = document.createElement("button"); - this.handle.innerHTML = label; + this.handle.appendChild(document.createTextNode(label)); label = ""; dataType = "none" break; @@ -125,7 +125,7 @@ class FormElement extends InterfaceElement { if (label !== "") { this.label = document.createElement("label"); - this.label.innerHTML = label; + this.label.appendChild(document.createTextNode(label)); } this.dataType = dataType; @@ -230,11 +230,11 @@ class FormElement extends InterfaceElement { let box = document.createElement("div"); box.classList.add(type); box.classList.add("alert"); - box.innerHTML = message; + box.appendChild(document.createTextNode(message)); if (title !== "") { let titleTag = document.createElement("strong"); - titleTag.innerHTML = title; + titleTag.appendChild(document.createTextNode(title)); box.prepend(titleTag); } diff --git a/scripts/testpage.js b/scripts/testpage.js index cb1e59c..6beb3a8 100644 --- a/scripts/testpage.js +++ b/scripts/testpage.js @@ -40,6 +40,13 @@ let out = new FormElement({ form: form }); +let button = new FormElement({ + id: "button", + type: "button", + label: "Do things", + form: form +}); + let outAdvanced = new FormElement({ id: "output-advanced", type: "output", @@ -47,3 +54,6 @@ let outAdvanced = new FormElement({ advanced: true, form: form }); + +inp.alertBox("alert-info", "Pater noster qui es in caelo sanctificetur nomen tuum adveniat regnum tuum."); +button.handle.addEventListener("click", form.clearAlerts);