From fd72079c5163f9881872d70b64aafde03b8b2385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 12 Aug 2020 15:57:55 +0200 Subject: Add option for default calendar. --- static/script.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'static/script.js') diff --git a/static/script.js b/static/script.js index 40d8a6d1..ab882d6a 100644 --- a/static/script.js +++ b/static/script.js @@ -522,12 +522,19 @@ function place_in_edit_mode (event) { let calendar_dropdown = document.getElementById('calendar-dropdown-template').firstChild.cloneNode(true); let [_, calclass] = popup.classList.find(/^CAL_/); - for (let [i, option] of calendar_dropdown.childNodes.entries()) { - if (option.value === calclass.substr(4)) { - calendar_dropdown.selectedIndex = i; - break; - } - } + label: { + for (let [i, option] of calendar_dropdown.childNodes.entries()) { + if (option.value === calclass.substr(4)) { + calendar_dropdown.selectedIndex = i; + break label; + } + } + /* no match, try find default calendar */ + let t; + if ((t = calendar_dropdown.querySelector("[selected]"))) { + event.properties.calendar = t.value; + } + } /* Instant change while user is stepping through would be -- cgit v1.2.3