diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-12-18 23:18:47 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-12-18 23:18:47 +0100 |
commit | 0e1eb02c1a6d596bd1e620b9c9bb13e6c125f5cb (patch) | |
tree | fef88b7581e8e3f2b41f739137ad42859e67915c /static/rrule.js | |
parent | Add convert entry-point. (diff) | |
download | calp-0e1eb02c1a6d596bd1e620b9c9bb13e6c125f5cb.tar.gz calp-0e1eb02c1a6d596bd1e620b9c9bb13e6c125f5cb.tar.xz |
Start work on jcal system.
Diffstat (limited to '')
-rw-r--r-- | static/rrule.js | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/static/rrule.js b/static/rrule.js index abc648af..f11cc640 100644 --- a/static/rrule.js +++ b/static/rrule.js @@ -8,6 +8,14 @@ function recur_xml_to_rrule(dom_element) { return rr; } +function recur_jcal_to_rrule(jcal) { + let rr = new RRule; + for (var key in jcal) { + rr[key] = jcal[key]; + } + return rr; +} + class RRule { /* direct access to fields is fine */ @@ -17,7 +25,9 @@ class RRule { fields = ['freq', 'until', 'count', 'interval', 'bysecond', 'byminute', 'byhour', 'bymonthday', 'byyearday', 'byweekno', - 'bymonth', 'bysetpos', 'wkst'] + 'bymonth', 'bysetpos', 'wkst', + 'byday' + ] constructor() { @@ -49,16 +59,30 @@ class RRule { this.listeners[field].push(proc); } - asXcal() { + asXcal(doc) { /* TODO empty case */ - let str = "<recur>"; + // let str = "<recur>"; + let root = doc.createElementNS(xcal, 'recur'); + for (let f of this.fields) { + let v = this.fields[f]; + if (! v) continue; + let tag = doc.createElementNS(xcal, f); + /* TODO type formatting */ + tag.innerHTML = `${v}`; + root.appendChild(tag); + } + return root; + } + + asJcal() { + let obj = {}; for (let f of this.fields) { let v = this.fields[f]; if (! v) continue; - str += `<${f}>${v}</${f}>`; + /* TODO special formatting for some types */ + obj[f] = v; } - str += "</recur>"; - return str; + return obj; } /* |