diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-09-05 01:25:00 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-09-05 01:25:00 +0200 |
commit | 7949fcdc683d07689bad5da5d20bfa3eeb5a6a46 (patch) | |
tree | c1bc39dc0e508ee498cf7119f888f513db4bab8f /static/globals.ts | |
parent | Add build step for jsdoc. (diff) | |
download | calp-7949fcdc683d07689bad5da5d20bfa3eeb5a6a46.tar.gz calp-7949fcdc683d07689bad5da5d20bfa3eeb5a6a46.tar.xz |
Move frontend code to subdirectories, to simplify command line flags.
Diffstat (limited to 'static/globals.ts')
-rw-r--r-- | static/globals.ts | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/static/globals.ts b/static/globals.ts deleted file mode 100644 index 243e15e4..00000000 --- a/static/globals.ts +++ /dev/null @@ -1,60 +0,0 @@ -export { - find_block, - vcal_objects, event_calendar_mapping -} - -import { VEvent } from './vevent' -import { uid } from './types' -import { ComponentBlock } from './components/vevent-block' - -import { v4 as uuid } from 'uuid' -import { setup_popup_element } from './components/popup-element' - -const vcal_objects: Map<uid, VEvent> = new Map; -const event_calendar_mapping: Map<uid, string> = new Map; - -declare global { - interface Window { - vcal_objects: Map<uid, VEvent>; - VIEW: 'month' | 'week'; - EDIT_MODE: boolean; - default_calendar: string; - - addNewEvent(): void; - } -} -window.vcal_objects = vcal_objects; - - -window.addNewEvent = () => { - let ev = new VEvent(); - let uid = uuid() - let now = new Date() - /* Round seconds to 0, since time inputs wants exact seconds */ - now.setUTCSeconds(0); - ev.setProperties([ - ['uid', uid], - ['dtstart', now, 'date-time'], - ['dtend', new Date(now.getTime() + 3600 * 1000), 'date-time'], - ]) - ev.calendar = window.default_calendar; - - vcal_objects.set(uid, ev); - - let popup = setup_popup_element(ev); - popup.maximize(); -} - -function find_block(uid: uid): ComponentBlock | null { - let obj = vcal_objects.get(uid) - if (obj === undefined) { - return null; - } - for (let el of obj.registered) { - if (el instanceof ComponentBlock) { - return el; - } - } - // throw 'Popup not fonud'; - return null; -} |