1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-27 11:26:22 -07:00

Implement creating locked/sticky threads client-side

This commit is contained in:
Eggbertx 2024-09-08 16:07:02 -07:00
parent f1a5acc9e4
commit b6c27a27c6
4 changed files with 38 additions and 5 deletions

View file

@ -78,4 +78,8 @@ td#boardslist, td#conditions {
fieldset.fld-cndtns {
margin-bottom: 8px;
}
tr#threadoptions > td > label {
display:block;
}

View file

@ -6,7 +6,7 @@ import "./notifications";
import { setPageBanner } from "./dom/banners";
import { setCustomCSS, setCustomJS, setTheme } from "./settings";
import { handleKeydown } from "./boardevents";
import { initStaff, createStaffMenu } from "./management/manage";
import { initStaff, createStaffMenu, addStaffThreadOptions } from "./management/manage";
import { getPageThread } from "./postinfo";
import { prepareThumbnails, initPostPreviews } from "./postutil";
import { addPostDropdown } from "./dom/postdropdown";
@ -31,8 +31,13 @@ $(() => {
const pageThread = getPageThread();
initStaff()
.then(createStaffMenu)
.catch(() => {
.then((staff) => {
if(staff?.rank < 1)
return;
createStaffMenu(staff);
if(staff.rank >= 2)
addStaffThreadOptions();
}).catch(() => {
// not logged in
});

View file

@ -145,7 +145,7 @@ export async function initStaff() {
} else if(typeof result === "object") {
staffInfo = result;
}
staffActions = staffInfo.actions;
staffActions = staffInfo?.actions ?? [];
return staffInfo;
},
error: (e: JQuery.jqXHR) => {
@ -172,7 +172,7 @@ export async function getPostInfo(id: number):Promise<PostInfo> {
}
export async function isLoggedIn() {
return initStaff().then(info => {
return await initStaff().then(info => {
return info.rank > 0;
});
}
@ -265,6 +265,26 @@ export function createStaffMenu(staff = staffInfo) {
createStaffButton();
}
export function addStaffThreadOptions() {
const $threadOptionsRow = $("tr#threadoptions");
if($threadOptionsRow.length < 1) return;
$threadOptionsRow.show().find("td").append(
$("<label/>").append(
$("<input/>").attr({
type: "checkbox",
name: "modstickied"
}), " Sticky thread"
),
$("<label/>").append(
$("<input/>").attr({
type: "checkbox",
name: "modlocked"
}), " Locked thread"
),
);
}
function createStaffButton() {
if($staffBtn !== null || staffInfo === null || staffInfo.rank === 0)
return;

View file

@ -376,6 +376,10 @@ fieldset.fld-cndtns {
margin-bottom: 8px;
}
tr#threadoptions > td > label {
display: block;
}
.lightbox {
background: #CDCDCD;
border: 1px solid #000;