diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-11 23:44:14 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-06-11 23:53:02 +0200 |
commit | d80cb4766155a5392b112756af3a64ae11604a10 (patch) | |
tree | 885e57db3b945d351ee43620000f584e611ffe87 /static | |
parent | Remove obsolete TODO about testing html sliders. (diff) | |
download | calp-d80cb4766155a5392b112756af3a64ae11604a10.tar.gz calp-d80cb4766155a5392b112756af3a64ae11604a10.tar.xz |
Move clock component initialization to procedure.
When the document was renederd as HTML the connectedCallback:s were ran
before the document was there, meaning that the initial content of the
tags were missing. This gives us controll over when its ran, and here
also ensures that it's ran once the document is there.
Diffstat (limited to 'static')
-rw-r--r-- | static/clock.ts | 12 | ||||
-rw-r--r-- | static/script.ts | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/static/clock.ts b/static/clock.ts index b0ddae00..fa975484 100644 --- a/static/clock.ts +++ b/static/clock.ts @@ -1,4 +1,7 @@ -export { SmallcalCellHighlight, Timebar } +export { + SmallcalCellHighlight, Timebar, + initialize_clock_components +} import { makeElement, date_to_percent } from './lib' @@ -104,7 +107,6 @@ class TodayButton extends ClockElement { (this.querySelector('a') as any).href = now.format("~Y-~m-~d.html") } } -customElements.define('today-button', TodayButton) class CurrentTime extends ClockElement { @@ -112,4 +114,8 @@ class CurrentTime extends ClockElement { this.textContent = now.format('~H:~M:~S') } } -customElements.define('current-time', CurrentTime) + +function initialize_clock_components() { + customElements.define('today-button', TodayButton) + customElements.define('current-time', CurrentTime) +} diff --git a/static/script.ts b/static/script.ts index 650a5aa0..ec771773 100644 --- a/static/script.ts +++ b/static/script.ts @@ -1,5 +1,8 @@ import { VEvent, xml_to_vcal } from './vevent' -import { SmallcalCellHighlight, Timebar } from './clock' +import { + SmallcalCellHighlight, Timebar, + initialize_clock_components +} from './clock' import { vcal_objects, event_calendar_mapping } from './globals' import { EventCreator } from './event-creator' import { PopupElement, setup_popup_element } from './components/popup-element' @@ -40,6 +43,7 @@ window.addEventListener('load', function() { } } + initialize_clock_components(); initialize_components(); /* A full redraw here is WAY to slow */ |