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