f0ckv2/public/js/f0ck.js

34 lines
930 B
JavaScript
Raw Normal View History

2019-05-07 20:23:19 +00:00
import rt from "./rt.js";
2019-05-15 17:51:11 +00:00
import events from "./events.js";
import lib from "./lib.js";
2019-05-07 20:23:19 +00:00
2019-05-15 17:51:11 +00:00
(async () => {
lib.showLayer("page");
window.addEventListener("hashchange", events.hashchange);
2019-05-07 20:23:19 +00:00
2019-05-15 17:51:11 +00:00
const debug = document.querySelectorAll("span#debug > a");
debug[0].addEventListener("click", () => { // page
lib.showLayer("page");
2019-05-07 20:23:19 +00:00
});
2019-05-15 17:51:11 +00:00
debug[1].addEventListener("click", () => { // item
lib.showLayer("item");
2019-05-07 20:23:19 +00:00
});
2019-05-15 17:51:11 +00:00
debug[2].addEventListener("click", () => { // item
lib.showLayer("howto");
});
2019-05-07 20:23:19 +00:00
setTimeout(() => {
const pn = parseInt(document.location.pathname.split("/").splice(-1));
2019-05-15 17:51:11 +00:00
const hash = document.location.hash;
lib.scrolltomiddle(rt.ct.wrapper.pages);
lib.getItems({
el: rt.ct.wrapper.pages[1],
2019-05-07 20:23:19 +00:00
opt: pn > 0 ? `id=${pn + 1}&order=desc` : ""
});
2019-05-11 09:20:48 +00:00
2019-05-15 17:51:11 +00:00
if(hash)
window.dispatchEvent(new CustomEvent("hashchange", { detail: { newURL: hash } }));
}, 300);
2019-05-07 20:23:19 +00:00
2019-05-15 17:51:11 +00:00
})();