From 0eff9776fa119fddea9bb65168632627b82163be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 20 Nov 2020 22:08:23 +0100 Subject: Start looking into generalized input-list. --- static/input_list.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'static/input_list.js') diff --git a/static/input_list.js b/static/input_list.js index b15162d6..79e223c3 100644 --- a/static/input_list.js +++ b/static/input_list.js @@ -73,5 +73,26 @@ function init_input_list() { transferListeners(oldUnit, unit); lst.unit = unit; + + if (lst.dataset.bindby) { + lst.get_value = lst.dataset.bindby; + } else if (lst.dataset.joinby) { + lst.get_value = get_value(lst.dataset.joinby); + } + } else { + lst.get_value = get_get_value(); + } } } + +/* -------------------------------------------------- */ + +/* different function forms since we want to capture one self */ +const get_get_value(join=',') => function () { + return [...self.querySelectorAll('input')] + .map(x => x.value) + .filter(x => x != '') + .join(join); +} + +/* -------------------------------------------------- */ -- cgit v1.2.3