diff --git a/public/javascripts/settings/config.js b/public/javascripts/settings/config.js index 8f3fa50..9528242 100644 --- a/public/javascripts/settings/config.js +++ b/public/javascripts/settings/config.js @@ -24,10 +24,12 @@ socket.on("getType", data => { save.innerText = "Save"; save.addEventListener("click", ev => { ev.stopPropagation(); - let data = {}; - for (const e of new FormData(form)) - data[e[0]] = e[1]; - socket.emit("setTypeConfig", {type: type.type, configuration: data}) + if (form.reportValidity()) { + let data = {}; + for (const e of new FormData(form)) + data[e[0]] = e[1]; + socket.emit("setTypeConfig", {type: type.type, configuration: data}) + } }); formRow.insertAdjacentElement("beforeend", save); diff --git a/public/javascripts/settings/decks.js b/public/javascripts/settings/decks.js index 3d9ceb6..da46d71 100644 --- a/public/javascripts/settings/decks.js +++ b/public/javascripts/settings/decks.js @@ -160,22 +160,23 @@ deckSelect.addEventListener("change", ev => { document.getElementById("save").addEventListener("click", ev => { ev.stopPropagation(); + if (form.reportValidity()) { + let data = {}; + for (const e of new FormData(form)) + data[e[0]] = e[1]; - let data = {}; - for (const e of new FormData(form)) - data[e[0]] = e[1]; + if (!slot.data) + slot.data = {}; - if (!slot.data) - slot.data = {}; + for (const k of ["text", "type", "image"]) { + slot.data[k] = data[k]; + delete data[k]; + } - for (const k of ["text", "type", "image"]) { - slot.data[k] = data[k]; - delete data[k]; + slot.data.options = data; + + socket.emit("setSlot", {name: slot.name, data: slot.data, position: slot.position}); } - - slot.data.options = data; - - socket.emit("setSlot", {name: slot.name, data: slot.data, position: slot.position}); }); document.getElementById("delete").addEventListener("click", ev => {