github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/client/src/client.ts (about) 1 // Content managed by Project Forge, see [projectforge.md] for details. 2 import "./client.css"; 3 import {audit} from "./audit"; 4 import {menuInit} from "./menu"; 5 import {modeInit} from "./mode"; 6 import {flashInit} from "./flash"; 7 import {linkInit} from "./link"; 8 import {timeInit} from "./time"; 9 import {autocompleteInit} from "./autocomplete"; 10 import {modalInit} from "./modal"; 11 import {tagsInit} from "./tags"; 12 import {formInit} from "./form"; 13 import {themeInit} from "./theme"; 14 import {appInit} from "./app"; 15 16 declare global { 17 interface Window { // eslint-disable-line @typescript-eslint/consistent-type-definitions 18 "dbaudit": { 19 wireTime: (el: HTMLElement) => void; 20 relativeTime: (el: HTMLElement) => string; 21 autocomplete: (el: HTMLInputElement, url: string, field: string, title: (x: unknown) => string, val: (x: unknown) => string) => void; 22 setSiblingToNull: (el: HTMLElement) => void; 23 initForm: (frm: HTMLFormElement) => void; 24 flash: (key: string, level: "success" | "error", msg: string) => void; 25 tags: (el: HTMLElement) => void; 26 }; 27 audit: (s: string, ...args: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any 28 } 29 } 30 31 export function init(): void { 32 const [s, i] = formInit(); 33 const [wireTime, relativeTime] = timeInit(); 34 window.dbaudit = { 35 wireTime: wireTime, 36 relativeTime: relativeTime, 37 autocomplete: autocompleteInit(), 38 setSiblingToNull: s, 39 initForm: i, 40 flash: flashInit(), 41 tags: tagsInit() 42 }; 43 menuInit(); 44 modeInit(); 45 linkInit(); 46 modalInit(); 47 themeInit(); 48 window.audit = audit; 49 appInit(); 50 } 51 52 document.addEventListener("DOMContentLoaded", init);