From 96f530746a6fbd51e63f8a20127a8b3975bdc739 Mon Sep 17 00:00:00 2001 From: lubiana Date: Wed, 28 Aug 2024 18:50:11 +0200 Subject: [PATCH] javascript --- index.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/index.html b/index.html index df537b3..c7556d2 100644 --- a/index.html +++ b/index.html @@ -187,6 +187,33 @@ haram.setUp() document.getElementById('edit').addEventListener('click', () => { if (haram.editMode === true) { + haram.harams = []; + document.querySelectorAll('tr').forEach((trNode) => { + const labelNode = trNode.querySelector('input[type="text"]') + if (labelNode == null) { + return + } + const pointsNode = trNode.querySelector('input[type="number"]') + if (pointsNode == null) { + return + } + + if (pointsNode.value < 1) { + return + } + if (labelNode.value === '') { + return + } + const newHaram = { + points: pointsNode.value, + label: labelNode.value, + } + + if (haram.harams.some((item) => item.label == newHaram.label)) { + return + } + haram.harams.push(newHaram) + }) haram.setUp() const jsonString = JSON.stringify(haram.harams) const encoded = btoa(jsonString) @@ -198,6 +225,7 @@ return } haram.edit() + }) \ No newline at end of file