//@ts-check import { fetchText } from "./utils/fetchText.mjs"; import { getElementById } from "./utils/getElementById.mjs"; import { onDocumentKeyUp } from "./utils/onDocumentKey.mjs"; import { parseFileList } from "./tickle/parseFileList.mjs"; import {createMenuEntriesFromFileList} from "./tickle/createMenuEntriesFromFileList.mjs" import { sortFileListLines } from "./tickle/sortFileListLines.mjs" import { mode } from "./tickle/mode.mjs"; import {bootstrapRouter} from "./tickle/bootstrapRouter.mjs"; /** * Loads the article list, parses it, creates the menu items */ export const bootstrap = () => { const [Menu, Body, Source, Burger] = ["Menu", "Body", "Source", "Burger"].map( getElementById ); Burger.addEventListener("click", mode.menuOpen.toggle); mode.loading.on(); fetchText("./files.txt").then((lines)=>{ const links = parseFileList(lines) const firstHref = links[0].href; sortFileListLines(links) Menu.appendChild(createMenuEntriesFromFileList(links)) bootstrapRouter(firstHref, (content, raw)=>{ Body.innerHTML = ""; Source.innerHTML = raw; Body.appendChild(content); }) }); onDocumentKeyUp("?", mode.sourceEnable.toggle); }; export default bootstrap;