import rt from "./rt.js"; import events from "./events.js"; import lib from "./lib.js"; if(rt.debug) { window.d = { rt: rt, events: events, lib: lib }; } (async () => { lib.showLayer("page"); window.addEventListener("hashchange", events.hashchange); document.addEventListener("wheel", events.wheel); window.addEventListener("resize", events.resize); [...rt.ct.arrows] // add pagebuttons .forEach(p => p.addEventListener("click", events.wheel)); const debug = document.querySelectorAll("span#debug > a"); debug[0].addEventListener("click", async () => { // random const random = await (await fetch(`${rt.api}/random`)).json(); window.location = `${window.location.pathname}#${random.id}`; }); setTimeout(() => { const pn = parseInt(document.location.pathname.split("/").splice(-1)); const hash = document.location.hash; if(!hash) { lib.getItems({ el: rt.ct.wrapper.pages[1], opt: pn > 0 ? `id=${pn + 1}&order=desc` : "" }); lib.scrolltomiddle(rt.ct.wrapper.pages); } else window.dispatchEvent(new CustomEvent("hashchange", { detail: { newURL: hash } })); }, 300); })();