From 61ebd0064fa6660667ca42ea54a169b629344034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 5 Oct 2020 02:24:04 +0200 Subject: Location and Property can now be added. --- static/script.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'static') diff --git a/static/script.js b/static/script.js index fa9ef210..f116deaf 100644 --- a/static/script.js +++ b/static/script.js @@ -994,6 +994,29 @@ function bind_properties (el, wide_event=false) { } } + /* Dynamicly add or remove the and elements + from the list. + + TODO generalize this to all fields, /especially/ those which are + dynamicly added. + */ + for (let field of ['location', 'description']) { + get_property(el, field).push( + [el.querySelector('vevent > properties'), + (s, v) => { + let slot = s.querySelector(field); + if (v === '' && slot) { + slot.remove(); + } else { + if (! slot) { + /* finns det verkligen inget bättre sätt... */ + s.innerHTML += `<${field}>`; + } + s.querySelector(`${field} > text`).innerHTML = v; + } + }]); + } + /* set up graphical display changes */ let container = el.closest(".event-container"); if (container === null) { -- cgit v1.2.3