blah
This commit is contained in:
@@ -2,31 +2,39 @@ 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", () => { // page
|
||||
lib.showLayer("page");
|
||||
});
|
||||
debug[1].addEventListener("click", () => { // item
|
||||
lib.showLayer("item");
|
||||
});
|
||||
debug[2].addEventListener("click", () => { // item
|
||||
lib.showLayer("howto");
|
||||
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;
|
||||
lib.scrolltomiddle(rt.ct.wrapper.pages);
|
||||
lib.getItems({
|
||||
el: rt.ct.wrapper.pages[1],
|
||||
opt: pn > 0 ? `id=${pn + 1}&order=desc` : ""
|
||||
});
|
||||
|
||||
if(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);
|
||||
|
||||
|
Reference in New Issue
Block a user