From 28c560c4c11f51b2dfffc77a286ad03057e4a13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 23 Oct 2020 00:14:17 +0200 Subject: Work on generalizing multi-input lists. --- static/script.js | 68 ++++++++++++++++++++++++++++++++++++++++++------------- static/style.scss | 5 ++++ 2 files changed, 57 insertions(+), 16 deletions(-) (limited to 'static') diff --git a/static/script.js b/static/script.js index 34ccdb2a..42f61da7 100644 --- a/static/script.js +++ b/static/script.js @@ -490,10 +490,19 @@ window.onload = function () { serializer.serializeToString(xml); */ + for (let lst of document.getElementsByClassName('input-list')) { + let unit = lst.querySelector('.final.unit').cloneNode(true); + lst.unit = unit; + for (let el of lst.getElementsByTagName('input')) { + el.addEventListener('input', update_inline_list); + } + } + /* for (let el of document.querySelectorAll(".input-list input")) { el.oninput = update_inline_list; } + */ for (let el of document.getElementsByClassName("newfield")) { @@ -619,7 +628,7 @@ window.onload = function () { } } - name.oninput = function () { + name.addEventListener('input', function () { let types = valid_input_types[this.value.toUpperCase()]; type_selector.disabled = false; if (types) { @@ -640,7 +649,7 @@ window.onload = function () { } update_value_field(el); - } + }); type_selector.onchange = function () { update_value_field(el); } @@ -783,9 +792,9 @@ function bind_properties (el, wide_event=false) { /* edit tab */ for (let e of popup.querySelectorAll(".edit-tab .bind")) { let p = get_property(el, e.dataset.property); - e.oninput = function () { + e.addEventListener('input', function () { el.properties[e.dataset.property] = this.value; - } + }); let f; switch (e.tagName) { case 'input': @@ -961,26 +970,53 @@ function bind_properties (el, wide_event=false) { } +/* + TODO document 'input-list'. -function advance_final(li) { - li.classList.remove("final"); - let new_li = makeElement ('input', { - className: 'final', - size: 2, - oninput: li.oninput, - }); - li.closest(".input-list").appendChild(new_li); + ∀ children('.input-list') => 'unit' ∈ classList(child) + +
+
+
+
+ +*/ + + +function advance_final(input_list) { + let new_unit = input_list.unit.cloneNode(true); + new_unit.classList.add('final'); + + for (let i of new_unit.getElementsByTagName('input')) { + /* TODO eventual other listeners? */ + /* TODO