aboutsummaryrefslogtreecommitdiff
path: root/static/clock.js
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-11-20 23:01:32 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-11-20 23:01:32 +0100
commit1b5ff103f589140473068fd83340b0cc443fb420 (patch)
treec90b3e2ae018df1f51ff87a755718581ca0254b1 /static/clock.js
parentStart looking into generalized input-list. (diff)
downloadcalp-1b5ff103f589140473068fd83340b0cc443fb420.tar.gz
calp-1b5ff103f589140473068fd83340b0cc443fb420.tar.xz
Work on templetazing js.
Diffstat (limited to 'static/clock.js')
-rw-r--r--static/clock.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/static/clock.js b/static/clock.js
new file mode 100644
index 00000000..badfd1db
--- /dev/null
+++ b/static/clock.js
@@ -0,0 +1,70 @@
+
+class Clock {
+ update(now) {
+ }
+}
+
+
+class Timebar extends Clock {
+
+ constructor(start_time, end_time) {
+ super();
+ this.start_time = start_time;
+ this.end_time = end_time;
+ this.bar_object = false
+ }
+
+
+ update(now) {
+ if (! (this.start_time <= now.getTime() && now.getTime() < this.end_time))
+ return;
+
+ var event_area = document.getElementById(now.format("~Y-~m-~d"))
+
+ if (event_area) {
+ if (this.bar_object) {
+ this.bar_object.parentNode.removeChild(bar_object)
+ } else {
+ this.bar_object = makeElement ('div', {
+ id: 'bar',
+ className: 'eventlike current-time',
+ });
+ }
+
+ this.bar_object.style.top = date_to_percent(now) + "%";
+ event_area.append(this.bar_object)
+ }
+ }
+}
+
+class SmallcalCellHighlight extends Clock {
+ constructor(small_cal) {
+ super();
+ this.small_cal = small_cal;
+ this.current_cell = false
+ }
+
+ update(now) {
+ if (current_cell) {
+ current_cell.style.border = "";
+ }
+
+ current_cell = this.small_cal.querySelector(
+ "time[datetime='" + now.format("~Y-~m-~d") + "']");
+
+ current_cell.style.border = "1px solid black";
+ }
+}
+
+/* Update [today] button */
+class ButtonUpdater extends Clock {
+ constructor(el, proc) {
+ super();
+ this.el = el;
+ this.proc = proc;
+ }
+
+ update(now) {
+ this.proc(e, now);
+ }
+}