f0ckv2/public/js/f0ck.js
2019-05-15 17:51:11 +00:00

34 lines
930 B
JavaScript

import rt from "./rt.js";
import events from "./events.js";
import lib from "./lib.js";
(async () => {
lib.showLayer("page");
window.addEventListener("hashchange", events.hashchange);
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");
});
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)
window.dispatchEvent(new CustomEvent("hashchange", { detail: { newURL: hash } }));
}, 300);
})();