blob: 5c2bd954f6e7ef49957084f6f0f8d9729bf76cad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
@node clock
@subsection clock.js
@deftp {(abstract) class} Clock
Interface for ``things'' which wants to get updated on a human timescale.
@defmethod Clock update now
Called every now and then, with @var{now} being the current time.
@end defmethod
All instances are expected to implement @code{update}, but are free to
implement any other methods they see fit.
@end deftp
Below, only the methods (including @code{constructor} and
@code{update} which do something of note (excluding the expected))
are noted.
@deftp {class} Timebar @extends{Clock}
The (blue) vertical line which show the current time in the current day.
@c @defmethod Timebar constructor ∅
@c @end defmethod
@c
@c @defmethod Timebar update now
@c @end defmethod
@end deftp
@deftp {class} SmallcalCellHighlight @extends{Clock}
Highlights the current date in the small calendar to the side.
Currently directly sets a border
@TODO{but should preferably set a class instead}.
@defmethod SmallcalCellHighlight constructor small_cal
@var{small_cal} is the DOM-node of the calendar.
(it should support querySelector).
@end defmethod
@c @defmethod SmallcalCellHighlight update now
@c @end defmethod
@end deftp
@deftp {class} ButtonUpdater @extends{Clock}
Updates the ``Today'' link in the side panel to point directly to the
correct web-address. The link works without JavaScript, but then
requires a redirect from the server.
All actual updating logic is already abstracted away. It would be
desirable if something more was done with this.
@defmethod ButtonUpdater el proc
Takes the element @var{el} to be updated, and the procedure @var{proc}
which will be called with the element, and the current time.
@end defmethod
@end deftp
As of commit
@githash{c9719ce7937f0f0f2aa371ced1d585f67af22457,static/script.js,231}
all objects required manual setup. See static/script.js:
@verbatim
231 let start_time = document.querySelector("meta[name='start-time']").content;
232 let end_time = document.querySelector("meta[name='end-time']").content;
233
234 const button_updater = new ButtonUpdater(
235 document.getElementById("today-button"),
236 (e, d) => e.href = d.format('~Y-~m-~d') + ".html"
237 );
238
239 const sch = new SmallcalCellHighlight(
240 document.querySelector('.small-calendar'))
241
242 const timebar = new Timebar(start_time, end_time);
243
244 timebar.update(new Date);
245 window.setInterval(() => {
246 let d = new Date;
247 timebar.update(d);
248 button_updater.update(d);
249 sch.update(d);
250 }, 1000 * 60);
251
@end verbatim
|