aboutsummaryrefslogtreecommitdiff
path: root/static/ts/clock.ts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-09-05 11:41:46 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-09-05 11:41:46 +0200
commitf653a01328be3b8be6af35c0c96867623765ca5b (patch)
treeaee9a5d3abfc39270f55defd7bc1a7e47920ffc3 /static/ts/clock.ts
parentMinor whitespace cleanup. (diff)
downloadcalp-f653a01328be3b8be6af35c0c96867623765ca5b.tar.gz
calp-f653a01328be3b8be6af35c0c96867623765ca5b.tar.xz
Move JS documentation into the JS-code.
Texinfo was a bad match for how TypeScript is structured. This also allows generation of jsdoc pages, which can be nice. Another large win is that this opens up for the texinfo pages to replace the Guile heading with different subheadings, including - external library - internal library - C library - ...
Diffstat (limited to 'static/ts/clock.ts')
-rw-r--r--static/ts/clock.ts44
1 files changed, 41 insertions, 3 deletions
diff --git a/static/ts/clock.ts b/static/ts/clock.ts
index bbd15de0..a0e4670a 100644
--- a/static/ts/clock.ts
+++ b/static/ts/clock.ts
@@ -1,3 +1,18 @@
+/**
+ * Components for working with things which depend on the current time.
+ *
+ * Also introduces two web components:
+ *
+ * ```html
+ * <today-button />
+ * <current-time />
+ * ```
+ *
+ * TODO shouldn't these be defined with the rest of the components?
+ *
+ * @module
+ */
+
export {
SmallcalCellHighlight, Timebar,
initialize_clock_components
@@ -5,11 +20,17 @@ export {
import { makeElement, date_to_percent } from './lib'
-abstract class Clock {
+/**
+ * Interface for `things` which wants to get updated on a human timescale.
+ */
+export abstract class Clock {
+ /** Called every now and then
+ * @param now Called with the current time
+ */
abstract update(now: Date): void;
}
-
+/** The (blue) vertical line which show the current time in the current day. */
class Timebar extends Clock {
// start_time: Date
@@ -23,7 +44,6 @@ class Timebar extends Clock {
this.bar_object = null
}
-
update(now: Date) {
// if (! (this.start_time <= now.getTime() && now.getTime() < this.end_time))
// return;
@@ -46,11 +66,21 @@ class Timebar 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}.
+*/
class SmallcalCellHighlight extends Clock {
small_cal: HTMLElement
current_cell: HTMLElement | null
+ /**
+ * @param small_cal the DOM-node of the calendar widget. It must support
+ * querySelector.
+ */
constructor(small_cal: HTMLElement) {
super();
this.small_cal = small_cal;
@@ -103,6 +133,14 @@ class ClockElement extends HTMLElement {
}
+/**
+ * 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.
+ */
class TodayButton extends ClockElement {
a: HTMLAnchorElement;