diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-04-26 21:02:35 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-04-26 21:02:35 +0200 |
commit | ab243461b0108b473ac514f5c25a0558ead9cbd2 (patch) | |
tree | fc630c9b6df99708cf99bc9802214111d6b53684 /static/script.js | |
parent | Update TODO. (diff) | |
download | calp-ab243461b0108b473ac514f5c25a0558ead9cbd2.tar.gz calp-ab243461b0108b473ac514f5c25a0558ead9cbd2.tar.xz |
Add popup close button.
Diffstat (limited to '')
-rw-r--r-- | static/script.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/static/script.js b/static/script.js index 494b6266..6bb55c2f 100644 --- a/static/script.js +++ b/static/script.js @@ -12,6 +12,16 @@ function time_to_percent (time) { return hour_to_part(time.getHours() + (time.getMinutes() / 60)) + "%" } +function parents_until (element, obj) { + if (element === null) { + return null; + } else if (element.id == obj.id || element.classList.contains(obj.class)) { + return element; + } else { + return parents_until (element.parentElement, obj); + } +} + let start_time = new Date(); let end_time = new Date(); @@ -125,6 +135,12 @@ function max(a, b) { a > b ? a : b; } +function close_popup (btn) { + o = { class: "popup" } + var popup = parents_until (btn, o); + popup.classList.toggle("show"); +} + /* https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively */ |