diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-09-13 00:01:28 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-09-13 00:01:28 +0200 |
commit | a82b6c772089aa46e30c6c89ef48f514294df3cb (patch) | |
tree | e25d9b6fd1fefe8b6ac293a5c0b53293872a8f54 /static/ts/formatters.ts | |
parent | Add basic documentation for lens. (diff) | |
parent | Even more documentation. (diff) | |
download | calp-a82b6c772089aa46e30c6c89ef48f514294df3cb.tar.gz calp-a82b6c772089aa46e30c6c89ef48f514294df3cb.tar.xz |
Merge branch 'next' into datarewrite-structures
Diffstat (limited to '')
-rw-r--r-- | static/ts/formatters.ts (renamed from static/formatters.ts) | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/static/formatters.ts b/static/ts/formatters.ts index e0018278..b5c55913 100644 --- a/static/formatters.ts +++ b/static/ts/formatters.ts @@ -1,3 +1,19 @@ +/** + * Formatting procedures used by some components. + * + * // TODO can we have a backref of every node containing `{@link formatters-proc}`? + * + * {@label FORMATTERS} + * + * Each procedure takes three arguments. The HTML-element which contents + * should be replaced, the VEvent containing all data, and the target + * value, as returned by {@linkcode vevent.VEvent.getProperty}. + * + * Also bound to the window object. + * + * @module + */ + export { format } @@ -16,6 +32,10 @@ declare global { let formatters: Map<string, formatter>; formatters = window.formatters = new Map(); +/** + * Checks if a specific formatter exists for the given key, and executes it. + * Defaults to 'default', and also runs that if the regular formatter throws. + */ async function format(targetElement: HTMLElement, data: VEvent, key: string): Promise<void> { let d = data.getProperty(key); if (!d) return |