diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-12 04:13:13 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-12 04:16:11 +0200 |
commit | 36f0d9f98eff7fe73f83ac074112924702f8ac42 (patch) | |
tree | 1868b63bd0fc8b650a77454ce54f532ed68e3604 /static/script.js | |
parent | Add deleteIndex to javascript arrays. (diff) | |
download | calp-36f0d9f98eff7fe73f83ac074112924702f8ac42.tar.gz calp-36f0d9f98eff7fe73f83ac074112924702f8ac42.tar.xz |
Reintroduce time input on generated events for HTML.
Diffstat (limited to 'static/script.js')
-rw-r--r-- | static/script.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/static/script.js b/static/script.js index 0338cee5..f54ab2d8 100644 --- a/static/script.js +++ b/static/script.js @@ -99,6 +99,36 @@ function create_event_move (e) { event.style.pointerEvents = "none"; + /* ---------------------------------------- */ + + function replace_with_time_input(fieldname, event) { + let field = event.getElementsByClassName(fieldname)[0]; + + let input = document.createElement("input"); + input.type = "time"; + input.required = true; + + input.onchange = function (e) { + // TODO capture date somewhere around here + let [hour, minute] = this.value.split(":").map(Number); + event.properties[fieldname] = new Date(0,0,0,hour,minute,0); + } + idx = event.properties["_slot_" + fieldname] + .findIndex(e => e[0] === field); + event.properties["_slot_" + fieldname].deleteIndex(idx); + event.properties["_slot_" + fieldname].push( + [input, (s, v) => s.value = v.format("%H:%M")]) + field.replaceWith(input); + + } + + /* TODO dtstart < dtend */ + replace_with_time_input("dtstart", event); + replace_with_time_input("dtend", event); + + /* ---------------------------------------- */ + + event.dataset.date = this.id; /* Makes all current events transparent when dragging over them. |