From 7949fcdc683d07689bad5da5d20bfa3eeb5a6a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Sep 2023 01:25:00 +0200 Subject: Move frontend code to subdirectories, to simplify command line flags. --- static/ts/components/vevent-dl.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 static/ts/components/vevent-dl.ts (limited to 'static/ts/components/vevent-dl.ts') diff --git a/static/ts/components/vevent-dl.ts b/static/ts/components/vevent-dl.ts new file mode 100644 index 00000000..a792c07f --- /dev/null +++ b/static/ts/components/vevent-dl.ts @@ -0,0 +1,35 @@ +export { VEventDL } + +import { ComponentVEvent } from './vevent' +import { VEvent } from '../vevent' +import { makeElement } from '../lib' + +import { RecurrenceRule } from '../vevent' + +/* */ +class VEventDL extends ComponentVEvent { + redraw(obj: VEvent) { + let dl = buildDescriptionList( + Array.from(obj.boundProperties) + .map(key => [key, obj.getProperty(key)])) + this.replaceChildren(dl); + } +} + +function buildDescriptionList(data: [string, any][]): HTMLElement { + let dl = document.createElement('dl'); + for (let [key, val] of data) { + dl.appendChild(makeElement('dt', { textContent: key })) + let fmtVal: string = val; + if (val instanceof Date) { + fmtVal = val.format( + val.dateonly + ? '~Y-~m-~d' + : '~Y-~m-~dT~H:~M:~S'); + } else if (val instanceof RecurrenceRule) { + fmtVal = JSON.stringify(val.to_jcal()) + } + dl.appendChild(makeElement('dd', { textContent: fmtVal })) + } + return dl; +} -- cgit v1.2.3 From f653a01328be3b8be6af35c0c96867623765ca5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 5 Sep 2023 11:41:46 +0200 Subject: 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 - ... --- static/ts/components/vevent-dl.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'static/ts/components/vevent-dl.ts') diff --git a/static/ts/components/vevent-dl.ts b/static/ts/components/vevent-dl.ts index a792c07f..a4b51dd9 100644 --- a/static/ts/components/vevent-dl.ts +++ b/static/ts/components/vevent-dl.ts @@ -1,3 +1,15 @@ +/** + * `` + * + * A description list of a vevent, used for debugging. + * + * No guarantees are given about the contents of the data fields, more + * than that they are related to the value in question. + * + * @category Web Components + * @mergeTarget components + * @module + */ export { VEventDL } import { ComponentVEvent } from './vevent' -- cgit v1.2.3