2022-08-11 12:38:08 +00:00
|
|
|
//@ts-check
|
2023-05-09 02:00:53 +00:00
|
|
|
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";
|
2022-08-11 12:38:08 +00:00
|
|
|
|
2023-05-09 02:00:53 +00:00
|
|
|
/**
|
|
|
|
* 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;
|