aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-11 00:14:33 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-11 00:14:33 +0200
commit217578c6731d1661953a628f238858dd742114b5 (patch)
tree31d46512e54eae9f9f7ca29db1619375f9889119
parentJavascript icalendar format of datetime. (diff)
downloadcalp-217578c6731d1661953a628f238858dd742114b5.tar.gz
calp-217578c6731d1661953a628f238858dd742114b5.tar.xz
Switch on type instead of field name...
-rw-r--r--static/script.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/static/script.js b/static/script.js
index 98311931..008e01bb 100644
--- a/static/script.js
+++ b/static/script.js
@@ -346,14 +346,11 @@ window.onload = function () {
lst.push([s, f]);
}
for (let s of el.querySelectorAll(field + " > :not(parameters)")) {
- switch (field) {
- case 'dtstart':
- if (s.tagName === 'date') {
- lst.push([s, (s, v) => s.innerHTML = v.format("%Y-%m-%d")]);
- } else {
- lst.push([s, (s, v) => s.innerHTML = v.format("%Y-%m-%dT%H:%M:%S")]);
- }
- break;
+ switch (s.tagName) {
+ case 'date':
+ lst.push([s, (s, v) => s.innerHTML = v.format("%Y-%m-%d")]); break;
+ case 'date-time':
+ lst.push([s, (s, v) => s.innerHTML = v.format("%Y-%m-%dT%H:%M:%S")]); break;
default:
lst.push([s, (s, v) => s.innerHTML = v]);
}