1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-27 19:36:24 -07:00
gochan/frontend/ts/gochan.ts
2023-06-15 14:38:57 -07:00

53 lines
1.4 KiB
TypeScript
Executable file

import $ from "jquery";
import "./vars";
import "./cookies";
import "./notifications";
import { setPageBanner } from "./dom/banners";
import { setCustomCSS, setCustomJS } from "./settings";
import { handleKeydown } from "./boardevents";
import { initStaff, createStaffMenu } from "./management/manage";
import { getPageThread } from "./postinfo";
import { prepareThumbnails, initPostPreviews } from "./postutil";
import { addPostDropdown } from "./dom/postdropdown";
import { initQR } from "./dom/qr";
import { getBooleanStorageVal, getStorageVal } from "./storage";
export function toTop() {
window.scrollTo(0,0);
}
window.toTop = toTop;
export function toBottom() {
window.scrollTo(0,document.body.scrollHeight);
}
window.toBottom = toBottom;
$(() => {
const style = getStorageVal("style", defaultStyle);
const themeElem = document.getElementById("theme");
if(themeElem) themeElem.setAttribute("href", `${webroot}css/${style}`);
const pageThread = getPageThread();
initStaff()
.then(createStaffMenu)
.catch(() => {
// not logged in
});
const passwordText = $("input#postpassword").val();
$("input#delete-password").val(passwordText);
setPageBanner();
if(pageThread.board !== "") {
prepareThumbnails();
if(getBooleanStorageVal("useqr", true))
initQR();
initPostPreviews();
}
$("div.post, div.reply").each((i, elem) => {
addPostDropdown($(elem));
});
$(document).on("keydown", handleKeydown);
setCustomCSS();
setCustomJS();
});