aboutsummaryrefslogtreecommitdiff
path: root/static/jcal.js
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-01-12 20:27:52 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-01-12 20:27:52 +0100
commitfed572ad28939060ac4d039001639e40240a5d3a (patch)
tree05df09822687b04887ec9537871b1471fc623b4e /static/jcal.js
parentMinor commentns. (diff)
downloadcalp-fed572ad28939060ac4d039001639e40240a5d3a.tar.gz
calp-fed572ad28939060ac4d039001639e40240a5d3a.tar.xz
jcal_to_xcal now works.
Diffstat (limited to '')
-rw-r--r--static/jcal.js41
1 files changed, 27 insertions, 14 deletions
diff --git a/static/jcal.js b/static/jcal.js
index ebf80cbd..38aeaae9 100644
--- a/static/jcal.js
+++ b/static/jcal.js
@@ -54,23 +54,36 @@ function jcal_property_to_xcal_property(doc, jcal) {
let tag = doc.createElementNS(xcal, propertyName);
- if (params !== {}) {
- let params = doc.createElementNS(xcal, params);
- for (var key in params) {
- let el = doc.createElementNS(xcal, key);
-
- for (let v of asList(params[key])) {
- let text = doc.createElementNS(xcal, 'text');
- text.innerHTML = '' + v;
- el.appendChild(text);
- }
-
- params.appendChild(el);
+ /* setup parameters */
+ let paramEl = doc.createElementNS(xcal, 'params');
+ for (var key in params) {
+ /* Check if the key actually belongs to us.
+ At least (my) format also appears when iterating
+ over the parameters. Probably a case of builtins
+ vs user defined.
+
+ This is also the reason we can't check if params
+ is empty beforehand, and instead check the
+ number of children of paramEl below.
+ */
+ if (! params.hasOwnProperty(key)) continue;
+
+ let el = doc.createElementNS(xcal, key);
+
+ for (let v of asList(params[key])) {
+ let text = doc.createElementNS(xcal, 'text');
+ text.innerHTML = '' + v;
+ el.appendChild(text);
}
- tag.appendChild(params);
+ paramEl.appendChild(el);
+ }
+
+ if (paramEl.childCount > 0) {
+ tag.appendChild(paramEl);
}
+ /* setup value (and type) */
// let typeEl = doc.createElementNS(xcal, type);
switch (propertyName) {
@@ -140,7 +153,7 @@ function jcal_to_xcal_inner(doc, jcal) {
let xcal_properties = doc.createElementNS(xcal, 'properties');
for (let property of properties) {
- xcal_properties.appendChild(jcal_property_to_xcal_property(property));
+ xcal_properties.appendChild(jcal_property_to_xcal_property(doc, property));
}
let xcal_children = doc.createElementNS(xcal, 'components');