mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-27 11:26:22 -07:00
Enforce strong equality checking by eslint
This commit is contained in:
parent
609c8cbc7f
commit
6ff58f8da4
26 changed files with 106 additions and 106 deletions
|
@ -25,7 +25,8 @@ module.exports = {
|
|||
"indent": ["warn", "tab"],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"quotes": ["warn", "double", {
|
||||
"allowTemplateLiterals": true
|
||||
"allowTemplateLiterals": true,
|
||||
"avoidEscape": true
|
||||
}],
|
||||
"semi": ["error", "always"],
|
||||
"no-var": ["error"],
|
||||
|
@ -45,6 +46,7 @@ module.exports = {
|
|||
}
|
||||
}],
|
||||
"no-constant-condition": ["off"],
|
||||
"eqeqeq": ["error"],
|
||||
"@typescript-eslint/no-explicit-any": ["off"],
|
||||
"@typescript-eslint/no-unused-vars": ["warn", {
|
||||
"argsIgnorePattern": "^_"
|
||||
|
|
|
@ -13,7 +13,7 @@ test("Checks for valid mock server timezone (serverTZ)", () => {
|
|||
test("Checks mock themes to make sure the default one (defaultStyle) exists and is pipes.css", () => {
|
||||
let styleName = "";
|
||||
for(const style of styles) {
|
||||
if(style.Filename == defaultStyle) {
|
||||
if(style.Filename === defaultStyle) {
|
||||
styleName = style.Name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import $ from "jquery";
|
|||
*/
|
||||
function getCooldown(data: BoardsJSON, board: string, type: string) {
|
||||
for(const boardData of data.boards) {
|
||||
if(boardData.board != board) continue;
|
||||
if(boardData.board !== board) continue;
|
||||
return (boardData.cooldowns as any)[type];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import $ from "jquery";
|
|||
* @param $elem the jQuery element of the post
|
||||
*/
|
||||
export function isThreadLocked($elem: JQuery<HTMLElement>) {
|
||||
return $elem.find("span.status-icons img.locked-icon").length == 1;
|
||||
return $elem.find("span.status-icons img.locked-icon").length === 1;
|
||||
}
|
||||
|
||||
interface BoardLockJSON {
|
||||
|
@ -39,7 +39,7 @@ export async function updateThreadLock(board: string, op: number, lock: boolean)
|
|||
}).then((_data) => {
|
||||
alert("Thread " + (lock?"locked":"unlocked") + " successfully");
|
||||
const $lockOpt = $(`select#op${op} option`)
|
||||
.filter((_i, el) => el.textContent == "Lock thread" || el.textContent == "Unlock thread");
|
||||
.filter((_i, el) => el.textContent === "Lock thread" || el.textContent === "Unlock thread");
|
||||
if(lock) {
|
||||
$(`div#op${op} span.status-icons`).append(
|
||||
$("<img/>").attr({
|
||||
|
|
|
@ -32,7 +32,7 @@ export async function getBoardList() {
|
|||
}
|
||||
|
||||
export async function getCatalog(board = "") {
|
||||
const useBoard = (board != "")?board:currentBoard();
|
||||
const useBoard = (board !== "")?board:currentBoard();
|
||||
|
||||
const data = await $.ajax({
|
||||
url: webroot + useBoard + "/catalog.json",
|
||||
|
@ -51,7 +51,7 @@ export async function getCatalog(board = "") {
|
|||
|
||||
export async function getThread(board = "", thread = 0) {
|
||||
const threadInfo = currentThread();
|
||||
if(board != "")
|
||||
if(board !== "")
|
||||
threadInfo.board = board;
|
||||
if(thread > 0)
|
||||
threadInfo.id = thread;
|
||||
|
|
|
@ -4,9 +4,9 @@ import { openQR } from "./dom/qr";
|
|||
|
||||
export function handleKeydown(e: JQuery.KeyDownEvent) {
|
||||
const ta = e.target;
|
||||
const isPostMsg = ta.nodeName == "TEXTAREA" && ta.name == "postmsg";
|
||||
const inForm = ta.form != undefined;
|
||||
if(!inForm && !e.ctrlKey && e.keyCode == 81) {
|
||||
const isPostMsg = ta.nodeName === "TEXTAREA" && ta.name === "postmsg";
|
||||
const inForm = ta.form !== undefined;
|
||||
if(!inForm && !e.ctrlKey && e.key === "q") {
|
||||
openQR();
|
||||
} else if(isPostMsg && e.ctrlKey) {
|
||||
applyBBCode(e);
|
||||
|
@ -15,29 +15,28 @@ export function handleKeydown(e: JQuery.KeyDownEvent) {
|
|||
|
||||
export function applyBBCode(e: JQuery.KeyDownEvent) {
|
||||
let tag = "";
|
||||
switch(e.keyCode) {
|
||||
case 10: // Enter key
|
||||
case 13: // Enter key in Chrome/IE
|
||||
switch(e.key) {
|
||||
case "Enter":
|
||||
// trigger the form submit event, whether the QR post box or the static post box is currently
|
||||
$(e.target).parents("form#postform,form#qrpostform").trigger("submit");
|
||||
break;
|
||||
case 66: // B
|
||||
case "b":
|
||||
tag = "b"; // bold
|
||||
break;
|
||||
case 73: // I
|
||||
case "i":
|
||||
tag = "i"; // italics
|
||||
break;
|
||||
case 82: // R
|
||||
case "r":
|
||||
tag = "s"; // strikethrough
|
||||
break;
|
||||
case 83:
|
||||
tag = "?"; // spoiler (not yet implemented)
|
||||
case "s":
|
||||
tag = "?";
|
||||
break;
|
||||
case 85: // U
|
||||
case "u":
|
||||
tag = "u"; // underline
|
||||
break;
|
||||
}
|
||||
if(tag == "") return;
|
||||
if(tag === "") return;
|
||||
|
||||
e.preventDefault();
|
||||
const ta = e.target;
|
||||
|
|
|
@ -11,7 +11,7 @@ export function getCookie(name: string, defaultVal = "") {
|
|||
|
||||
for(const cookie of cookieArr) {
|
||||
const pair = cookie.split("=");
|
||||
if(pair[0] != name) continue;
|
||||
if(pair[0] !== name) continue;
|
||||
try {
|
||||
val = decodeURIComponent(pair[1]).replace("+", " ");
|
||||
} catch(err) {
|
||||
|
@ -27,7 +27,7 @@ export function getNumberCookie(name: string, defaultVal = "0") {
|
|||
}
|
||||
|
||||
export function getBooleanCookie(name: string, defaultVal = "true") {
|
||||
return getCookie(name, defaultVal) == "true";
|
||||
return getCookie(name, defaultVal) === "true";
|
||||
}
|
||||
|
||||
function randomPassword(len = 8) {
|
||||
|
@ -45,7 +45,7 @@ function randomPassword(len = 8) {
|
|||
*/
|
||||
export function setCookie(name: string, value: string, expires = "", root = webroot) {
|
||||
let expiresStr = "";
|
||||
if(expires == "") {
|
||||
if(expires === "") {
|
||||
expiresStr = ";expires=";
|
||||
const d = new Date();
|
||||
d.setTime(d.getTime() + YEAR_IN_MS);
|
||||
|
@ -56,7 +56,7 @@ export function setCookie(name: string, value: string, expires = "", root = webr
|
|||
|
||||
export function initCookies() {
|
||||
let pwCookie = getCookie("password");
|
||||
if(pwCookie == "") {
|
||||
if(pwCookie === "") {
|
||||
pwCookie = randomPassword();
|
||||
setCookie("password", pwCookie);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ export function setPageBanner() {
|
|||
},
|
||||
dataType: "json"
|
||||
}).then(data => {
|
||||
if(!data || data.Filename == undefined || data.Filename == "") {
|
||||
if(!data || data.Filename === undefined || data.Filename === "") {
|
||||
return; // no banners :(
|
||||
}
|
||||
const props: BannerProps = {
|
||||
|
|
|
@ -54,7 +54,7 @@ export function promptLightbox(defVal = "", isMasked = false, onOk: ($el:JQuery<
|
|||
"id": "cancelbutton"
|
||||
}).text("Cancel");
|
||||
|
||||
const val = (typeof defVal == "string")?defVal:"";
|
||||
const val = (typeof defVal === "string")?defVal:"";
|
||||
const $promptInput = $("<input/>").prop({
|
||||
id: "promptinput",
|
||||
type: isMasked?"password":"text"
|
||||
|
@ -73,7 +73,7 @@ export function promptLightbox(defVal = "", isMasked = false, onOk: ($el:JQuery<
|
|||
const $lb = simpleLightbox({}, {}, [$form]);
|
||||
$promptInput.trigger("focus");
|
||||
$ok.on("click", function() {
|
||||
if(onOk($lb, $promptInput.val()) == false)
|
||||
if(onOk($lb, $promptInput.val()) === false)
|
||||
return;
|
||||
removeLightbox(this, $lb);
|
||||
});
|
||||
|
|
|
@ -31,8 +31,8 @@ function moveThread(id: number, _board: string) {
|
|||
}
|
||||
|
||||
function reportPost(id: number, board: string) {
|
||||
promptLightbox("", false, ($lb, reason) => {
|
||||
if(reason == "" || reason === null) return;
|
||||
promptLightbox("", false, (_$lb, reason) => {
|
||||
if(reason === "" || reason === null) return;
|
||||
const xhrFields: {[k: string]: string} = {
|
||||
board: board,
|
||||
report_btn: "Report",
|
||||
|
@ -96,7 +96,7 @@ function deletePost(id: number, board: string, fileOnly = false) {
|
|||
if(data !== "")
|
||||
alertLightbox(`Delete failed: ${data.error}`, "Error");
|
||||
}).done(data => {
|
||||
if(data.error == undefined || data == "") {
|
||||
if(data.error === undefined || data === "") {
|
||||
if(location.href.indexOf(`/${board}/res/${id}.html`) > -1) {
|
||||
alertLightbox("Thread deleted", "Success");
|
||||
} else if(fileOnly) {
|
||||
|
@ -174,11 +174,11 @@ function handleActions(action: string, postIDStr: string) {
|
|||
break;
|
||||
case "Ban filename":
|
||||
case "Ban file checksum": {
|
||||
const banType = (action == "Ban filename")?"filename":"checksum";
|
||||
const banType = (action === "Ban filename")?"filename":"checksum";
|
||||
getPostInfo(postID).then((info: any) => {
|
||||
return banFile(banType, info.originalFilename, info.checksum, `Added from post dropdown for post /${board}/${postID}`);
|
||||
}).then((result: any) => {
|
||||
if(result.error !== undefined && result.error != "") {
|
||||
if(result.error !== undefined && result.error !== "") {
|
||||
if(result.message !== undefined)
|
||||
alertLightbox(`Failed applying ${banType} ban: ${result.message}`, "Error");
|
||||
else
|
||||
|
@ -190,7 +190,7 @@ function handleActions(action: string, postIDStr: string) {
|
|||
let messageDetail = "";
|
||||
try {
|
||||
const responseJSON = JSON.parse(reason.responseText);
|
||||
if((typeof responseJSON.message) == "string" && responseJSON.message != "") {
|
||||
if((typeof responseJSON.message) === "string" && responseJSON.message !== "") {
|
||||
messageDetail = responseJSON.message;
|
||||
} else {
|
||||
messageDetail = reason.statusText;
|
||||
|
@ -248,12 +248,12 @@ export function addPostDropdown($post: JQuery<HTMLElement>) {
|
|||
$(() => {
|
||||
$(document).on("watchThread", (_e, thread) => {
|
||||
$<HTMLOptionElement>(`div#op${thread.id} select.post-actions > option`).each((i, el) => {
|
||||
if(el.text == "Watch thread")
|
||||
if(el.text === "Watch thread")
|
||||
el.text = "Unwatch thread";
|
||||
});
|
||||
}).on("unwatchThread", (_e, threadID) => {
|
||||
$<HTMLOptionElement>(`div#op${threadID} select.post-actions > option`).each((i, el) => {
|
||||
if(el.text == "Unwatch thread")
|
||||
if(el.text === "Unwatch thread")
|
||||
el.text = "Watch thread";
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,9 +41,9 @@ export function createPostElement(post: ThreadPost, boardDir: string, elementCla
|
|||
}).text(post.no), "<br/>",
|
||||
);
|
||||
const $postInfo = $post.find("label.post-info");
|
||||
const postName = (post.name == "" && post.trip == "")?"Anonymous":post.name;
|
||||
const postName = (post.name === "" && post.trip === "")?"Anonymous":post.name;
|
||||
const $postName = $("<span/>").prop({class: "postername"});
|
||||
if(post.email == "") {
|
||||
if(post.email === "") {
|
||||
$postName.text(postName);
|
||||
} else {
|
||||
$postName.append($("<a/>").prop({
|
||||
|
@ -51,16 +51,16 @@ export function createPostElement(post: ThreadPost, boardDir: string, elementCla
|
|||
}).text(post.name));
|
||||
}
|
||||
$postInfo.prepend($postName);
|
||||
if(post.trip != "") {
|
||||
if(post.trip !== "") {
|
||||
$postInfo.prepend($postName, $("<span/>").prop({class: "tripcode"}).text("!" + post.trip), " ");
|
||||
} else {
|
||||
$postInfo.prepend($postName, " ");
|
||||
}
|
||||
|
||||
if(post.sub != "")
|
||||
if(post.sub !== "")
|
||||
$postInfo.prepend($("<span/>").prop({class:"subject"}).text(post.sub), " ");
|
||||
|
||||
if(post.filename != "" && post.filename != "deleted") {
|
||||
if(post.filename !== "" && post.filename !== "deleted") {
|
||||
const thumbFile = getThumbFilename(post.tim);
|
||||
$post.append(
|
||||
$("<div/>").prop({class: "file-info"})
|
||||
|
|
|
@ -39,7 +39,7 @@ export function setPostVisibility(id: number|string, visibility: boolean, onComp
|
|||
$backlink.text(id);
|
||||
const newHidden = [];
|
||||
for(const sID of hiddenStorage) {
|
||||
if(sID != id && newHidden.indexOf(sID) == -1) newHidden.push(sID);
|
||||
if(sID !== id && newHidden.indexOf(sID) === -1) newHidden.push(sID);
|
||||
}
|
||||
setStorageVal("hiddenposts", newHidden.join(","));
|
||||
} else {
|
||||
|
@ -48,7 +48,7 @@ export function setPostVisibility(id: number|string, visibility: boolean, onComp
|
|||
elem.text = elem.text.replace("Hide", "Show");
|
||||
});
|
||||
$backlink.text(`${id} (hidden)`);
|
||||
if(hiddenStorage.indexOf(id as string) == -1) hiddenStorage.push(id as string);
|
||||
if(hiddenStorage.indexOf(id as string) === -1) hiddenStorage.push(id as string);
|
||||
setStorageVal("hiddenposts", hiddenStorage.join(","));
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ function setButtonTimeout(prefix = "", cooldown = 5) {
|
|||
let currentSeconds = cooldown;
|
||||
let interval: NodeJS.Timer = null;
|
||||
const timeoutCB = () => {
|
||||
if(currentSeconds == 0) {
|
||||
if(currentSeconds === 0) {
|
||||
setSubmitButtonEnabled(true);
|
||||
resetSubmitButtonText();
|
||||
clearInterval(interval);
|
||||
|
@ -263,7 +263,7 @@ function clearQR() {
|
|||
|
||||
export function openQR() {
|
||||
if($qr) {
|
||||
if($qr.parent().length == 0) {
|
||||
if($qr.parent().length === 0) {
|
||||
$qr.insertAfter("div#content");
|
||||
} else {
|
||||
$qr.show();
|
||||
|
@ -279,7 +279,7 @@ window.closeQR = closeQR;
|
|||
|
||||
$(() => {
|
||||
const board = currentBoard();
|
||||
if(board == "") return; // not on a board
|
||||
if(board === "") return; // not on a board
|
||||
getThreadCooldown(board).then(cd => threadCooldown = cd);
|
||||
getReplyCooldown(board).then(cd => replyCooldown = cd);
|
||||
});
|
|
@ -3,7 +3,7 @@ const noop = ()=>{
|
|||
};
|
||||
|
||||
export function updateUploadImage($elem: JQuery<HTMLElement>, onLoad = noop) {
|
||||
if($elem.length == 0) return;
|
||||
if($elem.length === 0) return;
|
||||
$elem[0].onchange = function() {
|
||||
const img = new Image();
|
||||
img.src = URL.createObjectURL((this as any).files[0]);
|
||||
|
|
|
@ -38,7 +38,7 @@ $(() => {
|
|||
$("input#delete-password").val(passwordText);
|
||||
|
||||
setPageBanner();
|
||||
if(pageThread.board != "") {
|
||||
if(pageThread.board !== "") {
|
||||
prepareThumbnails();
|
||||
if(getBooleanStorageVal("useqr", true))
|
||||
initQR();
|
||||
|
|
|
@ -4,7 +4,6 @@ import "jquery-ui/ui/unique-id";
|
|||
import "jquery-ui/ui/keycode";
|
||||
import "jquery-ui/ui/widgets/tabs";
|
||||
$(() => {
|
||||
if(window.location.pathname != webroot + "manage/filebans")
|
||||
return;
|
||||
$("div#fileban-tabs").tabs();
|
||||
if(window.location.pathname === webroot + "manage/filebans")
|
||||
$("div#fileban-tabs").tabs();
|
||||
});
|
|
@ -53,7 +53,7 @@ function setupManagementEvents() {
|
|||
$el.append("<option>Posts from this IP</option>");
|
||||
}
|
||||
const filenameOrig = $post.find("div.file-info a.file-orig").text();
|
||||
if(filenameOrig != "" && !dropdownHasItem(el, "Ban filename")) {
|
||||
if(filenameOrig !== "" && !dropdownHasItem(el, "Ban filename")) {
|
||||
$el.append(
|
||||
"<option>Ban filename</option>",
|
||||
"<option>Ban file checksum</option>"
|
||||
|
@ -206,17 +206,17 @@ function menuItem(action: StaffAction|string, isCategory = false) {
|
|||
|
||||
function getAction(id: string) {
|
||||
for(const action of staffActions) {
|
||||
if(action.id == id) {
|
||||
if(action.id === id) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function filterAction(action: StaffAction, perms: number) {
|
||||
return action.title != "Logout"
|
||||
&& action.title != "Dashboard"
|
||||
return action.title !== "Logout"
|
||||
&& action.title !== "Dashboard"
|
||||
&& action.jsonOutput < 2
|
||||
&& action.perms == perms;
|
||||
&& action.perms === perms;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,7 +251,7 @@ export function createStaffMenu(staff = staffInfo) {
|
|||
}
|
||||
getReports().then(updateReports);
|
||||
}
|
||||
if(rank == 3) {
|
||||
if(rank === 3) {
|
||||
const adminActions = staffActions.filter(val => filterAction(val, 3));
|
||||
if(adminActions.length > 0)
|
||||
$staffMenu.append(menuItem("Administration", true));
|
||||
|
@ -266,14 +266,14 @@ function createStaffButton() {
|
|||
if($staffBtn !== null || staffInfo.Rank === 0)
|
||||
return;
|
||||
$staffBtn = new TopBarButton("Staff", () => {
|
||||
$topbar.trigger("menuButtonClick", [$staffMenu, $(document).find($staffMenu).length == 0]);
|
||||
$topbar.trigger("menuButtonClick", [$staffMenu, $(document).find($staffMenu).length === 0]);
|
||||
});
|
||||
}
|
||||
|
||||
function updateReports(reports: any[]) {
|
||||
// append " (#)" to the Reports link, replacing # with the number of reports
|
||||
$staffMenu.find("a").each((e, elem) => {
|
||||
if(elem.text.search(reportsTextRE) != 0) return;
|
||||
if(elem.text.search(reportsTextRE) !== 0) return;
|
||||
const $span = $("<span/>").text(` (${reports.length})`).appendTo(elem);
|
||||
if(reports.length > 0) {
|
||||
// make it bold and red if there are reports
|
||||
|
|
|
@ -20,7 +20,7 @@ function applyOrderChanges() {
|
|||
const sectionname = $el.find(":nth-child(1)").html();
|
||||
const sectionabbr = $el.find(":nth-child(2)").html();
|
||||
const sectionpos = $el.find(":nth-child(3)").html();
|
||||
const sectionhidden = $el.find(":nth-child(4)").html().toLowerCase() == "yes"?"on":"off";
|
||||
const sectionhidden = $el.find(":nth-child(4)").html().toLowerCase() === "yes"?"on":"off";
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: webroot + "manage/boardsections",
|
||||
|
@ -76,7 +76,7 @@ function addButtons() {
|
|||
}
|
||||
|
||||
$(() => {
|
||||
if(window.location.pathname != webroot + "manage/boardsections")
|
||||
if(window.location.pathname !== webroot + "manage/boardsections")
|
||||
return;
|
||||
|
||||
$sectionsTable = $("table#sections");
|
||||
|
|
|
@ -11,7 +11,7 @@ interface LogFilter {
|
|||
let originalLog = "";
|
||||
|
||||
function updateLogFilter($log: JQuery<HTMLTextAreaElement>, filter: LogFilter) {
|
||||
let lines = originalLog.split("\n").filter((line) => {
|
||||
const lines = originalLog.split("\n").filter((line) => {
|
||||
try {
|
||||
const lineObj = JSON.parse(line);
|
||||
switch(lineObj.level) {
|
||||
|
@ -46,7 +46,7 @@ function updateLogFilter($log: JQuery<HTMLTextAreaElement>, filter: LogFilter) {
|
|||
}
|
||||
|
||||
$(() => {
|
||||
if(location.pathname.indexOf(webroot + "manage/viewlog") != 0)
|
||||
if(location.pathname.indexOf(webroot + "manage/viewlog") !== 0)
|
||||
return;
|
||||
const $log = $<HTMLTextAreaElement>("textarea.viewlog");
|
||||
originalLog = $log.text();
|
||||
|
@ -115,7 +115,7 @@ $(() => {
|
|||
showErrors: $filters.filter("#level-error-chk").get(0).checked,
|
||||
showWarnings: $filters.filter("#level-warning-chk").get(0).checked,
|
||||
showInfo: $filters.filter("#level-info-chk").get(0).checked,
|
||||
sortDesc: $filters.filter("select#log-sort").val() == "desc"
|
||||
sortDesc: $filters.filter("select#log-sort").val() === "desc"
|
||||
};
|
||||
updateLogFilter($log, filter);
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ const noteCloseTime = 4*1000; // 4 seconds
|
|||
const noteIcon = webroot + "/favicon.png";
|
||||
|
||||
function canNotify() {
|
||||
return (location.protocol == "https:")
|
||||
return (location.protocol === "https:")
|
||||
&& (typeof Notification !== "undefined");
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ $(() => {
|
|||
return;
|
||||
|
||||
Notification.requestPermission().then(granted => {
|
||||
if(granted != "granted")
|
||||
if(granted !== "granted")
|
||||
return Promise.reject("denied");
|
||||
}).catch(err => {
|
||||
if(err != "denied")
|
||||
if(err !== "denied")
|
||||
console.log(`Error starting notifications: ${err}`);
|
||||
});
|
||||
});
|
|
@ -6,16 +6,16 @@ const threadRE = /^\d+/;
|
|||
|
||||
export function currentBoard() {
|
||||
const board = $("form#main-form input[type=hidden][name=board]").val();
|
||||
if(typeof board == "string")
|
||||
if(typeof board === "string")
|
||||
return board;
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getPageThread() {
|
||||
let pathname = window.location.pathname;
|
||||
if(typeof webroot == "string" && webroot != "/") {
|
||||
if(webroot !== "/") {
|
||||
pathname = pathname.slice(webroot.length);
|
||||
if(pathname === "" || pathname[0] != "/") {
|
||||
if(pathname === "" || pathname[0] !== "/") {
|
||||
pathname = "/" + pathname;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ export function getPageThread() {
|
|||
|
||||
if(arr.length > 1) info.op = Number.parseInt(arr[1]);
|
||||
if(arr.length > 3) info.page = Number.parseInt(arr[3]);
|
||||
if(info.board != "") info.boardID = Number.parseInt($("form#postform input[name=boardid]").val() as string) -1;
|
||||
if(info.board !== "") info.boardID = Number.parseInt($("form#postform input[name=boardid]").val() as string) -1;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,14 @@ export function currentThread(): WatchedThreadJSON {
|
|||
// returns the board and thread ID if we are viewing a thread
|
||||
const thread = {board: currentBoard(), id: 0};
|
||||
let pathname = location.pathname;
|
||||
if(typeof webroot == "string" && webroot != "/") {
|
||||
if(typeof webroot === "string" && webroot !== "/") {
|
||||
pathname = pathname.slice(webroot.length);
|
||||
if(pathname === "" || pathname[0] != "/") {
|
||||
if(pathname === "" || pathname[0] !== "/") {
|
||||
pathname = "/" + pathname;
|
||||
}
|
||||
}
|
||||
const splits = pathname.split("/");
|
||||
if(splits.length != 4)
|
||||
if(splits.length !== 4)
|
||||
return thread;
|
||||
const reArr = threadRE.exec(splits[3]);
|
||||
if(reArr.length > 0)
|
||||
|
@ -65,7 +65,7 @@ export function getThumbFilename(filename: string) {
|
|||
if(nameParts === null) return filename;
|
||||
const name = nameParts[1] + "t";
|
||||
let ext = nameParts[2];
|
||||
if(ext == "gif" || ext == "webm")
|
||||
if(ext === "gif" || ext === "webm")
|
||||
ext = "jpg";
|
||||
|
||||
return name + "." + ext;
|
||||
|
|
|
@ -43,7 +43,7 @@ function updateThreadHTML() {
|
|||
let numAdded = 0;
|
||||
for(const post of currentThreadJSON.posts) {
|
||||
let selector = "";
|
||||
if(post.resto === 0 || post.resto == post.no)
|
||||
if(post.resto === 0 || post.resto === post.no)
|
||||
selector += `div#op${post.no}`;
|
||||
else
|
||||
selector += `div#reply${post.no}`;
|
||||
|
@ -95,7 +95,7 @@ function expandPost(e: JQuery.MouseEventBase) {
|
|||
e.preventDefault();
|
||||
if($hoverPreview !== null) $hoverPreview.remove();
|
||||
const $next = $(e.target).next();
|
||||
if($next.prop("class") == "inlinepostprev" && e.type == "click") {
|
||||
if($next.prop("class") === "inlinepostprev" && e.type === "click") {
|
||||
// inline preview is already opened, close it
|
||||
$next.remove();
|
||||
return;
|
||||
|
@ -107,14 +107,14 @@ function expandPost(e: JQuery.MouseEventBase) {
|
|||
|
||||
let $post = $(`div#op${postID}, div#reply${postID}`).first();
|
||||
if($post.length > 0) {
|
||||
const $preview = createPostPreview(e, $post, e.type == "click");
|
||||
if(e.type == "mouseenter") {
|
||||
const $preview = createPostPreview(e, $post, e.type === "click");
|
||||
if(e.type === "mouseenter") {
|
||||
$hoverPreview = $preview.insertAfter(e.target);
|
||||
$(document.body).on("mousemove", previewMoveHandler);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.type == "click") {
|
||||
if(e.type === "click") {
|
||||
$.get(href, data => {
|
||||
$post = $(data).find(`div#op${postID}, div#reply${postID}`).first();
|
||||
if($post.length < 1) return; // post not on this page.
|
||||
|
@ -127,7 +127,7 @@ function expandPost(e: JQuery.MouseEventBase) {
|
|||
}
|
||||
|
||||
export function initPostPreviews($post: JQuery<HTMLElement> = null) {
|
||||
if(getPageThread().board == "" && $post === null) return;
|
||||
if(getPageThread().board === "" && $post === null) return;
|
||||
doClickPreview = getBooleanStorageVal("enablepostclick", true);
|
||||
doHoverPreview = getBooleanStorageVal("enableposthover", false);
|
||||
let $refs = null;
|
||||
|
@ -230,11 +230,11 @@ export function quote(no: number) {
|
|||
}
|
||||
const cursor = (msgbox.selectionStart !== undefined)?msgbox.selectionStart:msgbox.value.length;
|
||||
let quoted = lines.join("\n");
|
||||
if(quoted != "") quoted += "\n";
|
||||
if(quoted !== "") quoted += "\n";
|
||||
msgbox.value = msgbox.value.slice(0, cursor) + `>>${no}\n` +
|
||||
quoted + msgbox.value.slice(cursor);
|
||||
|
||||
if(msgbox.id == "postmsg")
|
||||
if(msgbox.id === "postmsg")
|
||||
window.scroll(0,msgbox.offsetTop - 48);
|
||||
msgbox.focus();
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class TextSetting extends Setting<string, HTMLTextAreaElement> {
|
|||
this.element = this.createElement("<textarea/>");
|
||||
this.element.text(defaultVal);
|
||||
const val = this.getStorageValue();
|
||||
if(val != "") {
|
||||
if(val !== "") {
|
||||
this.setElementValue(val);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class BooleanSetting extends Setting<boolean, HTMLInputElement> {
|
|||
}
|
||||
getStorageValue() {
|
||||
const val = super.getStorageValue();
|
||||
return val == true;
|
||||
return val === true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,9 +115,9 @@ class NumberSetting extends Setting<number, HTMLInputElement> {
|
|||
const props: MinMax = {
|
||||
type: "number"
|
||||
};
|
||||
if(typeof minMax.min == "number" && !isNaN(minMax.min))
|
||||
if(typeof minMax.min === "number" && !isNaN(minMax.min))
|
||||
props.min = minMax.min;
|
||||
if(typeof minMax.max == "number" && !isNaN(minMax.max))
|
||||
if(typeof minMax.max === "number" && !isNaN(minMax.max))
|
||||
props.max = minMax.max;
|
||||
this.element = this.createElement("<input />", props).val(this.getStorageValue());
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ function createLightbox() {
|
|||
*/
|
||||
export function setCustomJS() {
|
||||
const customJS = getStorageVal("customjs");
|
||||
if(customJS != "") {
|
||||
if(customJS !== "") {
|
||||
eval(customJS);
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ export function setCustomJS() {
|
|||
*/
|
||||
export function setCustomCSS() {
|
||||
const customCSS = getStorageVal("customcss");
|
||||
if(customCSS != "") {
|
||||
if(customCSS !== "") {
|
||||
$("style#customCSS").remove();
|
||||
$("<style/>").prop({
|
||||
id: "customCSS"
|
||||
|
|
|
@ -2,7 +2,7 @@ import { getCookie, setCookie } from "./cookies";
|
|||
|
||||
|
||||
export function getStorageVal(key: string, defaultVal = "") {
|
||||
if(localStorage == undefined)
|
||||
if(localStorage === undefined)
|
||||
return getCookie(key, defaultVal);
|
||||
const val = localStorage.getItem(key);
|
||||
if(val === null)
|
||||
|
@ -12,7 +12,7 @@ export function getStorageVal(key: string, defaultVal = "") {
|
|||
|
||||
export function getBooleanStorageVal(key: string, defaultVal = false) {
|
||||
const val = getStorageVal(key, defaultVal?"true":"false");
|
||||
return val == "true";
|
||||
return val === "true";
|
||||
}
|
||||
|
||||
export function getNumberStorageVal(key: string, defaultVal = 0) {
|
||||
|
@ -31,7 +31,7 @@ export function getJsonStorageVal<T>(key: string, defaultVal: T) {
|
|||
|
||||
export function setStorageVal(key: string, val: any, isJSON = false) {
|
||||
const storeVal = isJSON?JSON.stringify(val):val;
|
||||
if(localStorage == undefined)
|
||||
if(localStorage === undefined)
|
||||
setCookie(key, storeVal);
|
||||
else
|
||||
localStorage.setItem(key, storeVal);
|
||||
|
|
|
@ -17,12 +17,12 @@ function addThreadToMenu(thread: WatchedThreadJSON) {
|
|||
updateThreadInWatcherMenu(thread);
|
||||
return;
|
||||
}
|
||||
if(thread.op == "") thread.op = "Anonymous";
|
||||
if(thread.op === "") thread.op = "Anonymous";
|
||||
const $replyCounter = $("<span/>")
|
||||
.prop({id: "reply-counter"})
|
||||
.text(`(Replies: ${thread.posts - 1})`);
|
||||
let infoElem = ` - <b>OP:</b> ${thread.op}<br/>`;
|
||||
if(thread.subject === undefined || thread.subject == "") {
|
||||
if(thread.subject === undefined || thread.subject === "") {
|
||||
infoElem += "<b>Subject:</b> <i>[None]</i>";
|
||||
} else {
|
||||
infoElem += `<b>Subject: </b> ${thread.subject}`;
|
||||
|
@ -58,7 +58,7 @@ function addThreadToMenu(thread: WatchedThreadJSON) {
|
|||
|
||||
function removeThreadFromMenu(threadID: number) {
|
||||
$watcherMenu.find(`div#thread${threadID}`).remove();
|
||||
if($watcherMenu.find("div.watcher-item").length == 0)
|
||||
if($watcherMenu.find("div.watcher-item").length === 0)
|
||||
$watcherMenu.append('<i id="no-threads">no watched threads</i>');
|
||||
}
|
||||
|
||||
|
@ -66,13 +66,13 @@ function updateThreadInWatcherMenu(thread: WatchedThreadJSON) {
|
|||
const currentPage = currentThread();
|
||||
|
||||
const $item = $watcherMenu.find(`div#thread${thread.op}`);
|
||||
if($item.length == 0) return; // watched thread isn't in the menu
|
||||
if($item.length === 0) return; // watched thread isn't in the menu
|
||||
$item.find("span#reply-counter").remove();
|
||||
const $replyCounter = $("<span>").prop({
|
||||
id: "reply-counter"
|
||||
}).insertBefore($item.find(`a#unwatch${thread.op}`));
|
||||
|
||||
if(currentPage.board == thread.board && currentPage.id == thread.id) {
|
||||
if(currentPage.board === thread.board && currentPage.id === thread.id) {
|
||||
// we're currently in the thread
|
||||
$replyCounter.text(` (Replies: ${thread.newNumPosts - 1}) `);
|
||||
} else {
|
||||
|
@ -105,7 +105,7 @@ $(() => {
|
|||
}
|
||||
if(watcherBtn === null) {
|
||||
watcherBtn = new TopBarButton("Watcher", () => {
|
||||
$topbar.trigger("menuButtonClick", [$watcherMenu, $(document).find($watcherMenu).length == 0]);
|
||||
$topbar.trigger("menuButtonClick", [$watcherMenu, $(document).find($watcherMenu).length === 0]);
|
||||
}, {
|
||||
before: "a#settings.dropdown-button"
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ export function updateWatchedThreads() {
|
|||
getThreadJSON(thread.id, board).then(data => {
|
||||
if(data.posts.length > thread.posts) {
|
||||
// watched thread has new posts, trigger a menu update
|
||||
if(currentPage.board == board && currentPage.id == thread.id) {
|
||||
if(currentPage.board === board && currentPage.id === thread.id) {
|
||||
// we're currently in the thread, update the cookie
|
||||
watched[board][t].posts = data.posts.length;
|
||||
watched[board][t].latest = data.posts[data.posts.length - 1].no;
|
||||
|
@ -40,7 +40,7 @@ export function updateWatchedThreads() {
|
|||
});
|
||||
}
|
||||
}).catch(e => {
|
||||
if(e.status == 404) {
|
||||
if(e.status === 404) {
|
||||
watched[board][t].err = e.statusText;
|
||||
setStorageVal("watched", watched, true);
|
||||
}
|
||||
|
@ -69,16 +69,16 @@ export interface WatchedThreadJSON {
|
|||
export function isThreadWatched(threadID: number, board: string) {
|
||||
const watched = getJsonStorageVal<WatchedThreadsListJSON>("watched", {});
|
||||
const threads = watched[board];
|
||||
if(threads == undefined) return false;
|
||||
if(threads === undefined) return false;
|
||||
for(const thread of threads) {
|
||||
if(thread.id == threadID) return true;
|
||||
if(thread.id === threadID) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function watchThread(threadID: string|number, board: string) {
|
||||
const watched = getJsonStorageVal<WatchedThreadsListJSON>("watched", {});
|
||||
if(typeof threadID == "string") {
|
||||
if(typeof threadID === "string") {
|
||||
threadID = parseInt(threadID);
|
||||
}
|
||||
if(!(watched[board] instanceof Array))
|
||||
|
@ -89,7 +89,7 @@ export function watchThread(threadID: string|number, board: string) {
|
|||
if(typeof thread === "number") {
|
||||
thread = watched[board][t] = {id: thread};
|
||||
}
|
||||
if(thread.id == threadID) return; // thread is already in the watched list
|
||||
if(thread.id === threadID) return; // thread is already in the watched list
|
||||
}
|
||||
getThreadJSON(threadID, board).then(data => {
|
||||
const op = data.posts[0];
|
||||
|
@ -100,8 +100,8 @@ export function watchThread(threadID: string|number, board: string) {
|
|||
op: op.name,
|
||||
latest: data.posts[data.posts.length-1].no
|
||||
};
|
||||
if(op.trip != "") threadObj.op += "!" + op.trip;
|
||||
if(op.sub != "") {
|
||||
if(op.trip !== "") threadObj.op += "!" + op.trip;
|
||||
if(op.sub !== "") {
|
||||
if(op.sub.length > subjectCuttoff)
|
||||
threadObj.subject = op.sub.slice(0, subjectCuttoff) + "...";
|
||||
else
|
||||
|
@ -118,7 +118,7 @@ export function unwatchThread(threadID: number, board: string) {
|
|||
if(!(watched[board] instanceof Array))
|
||||
return;
|
||||
for(const i in watched[board]) {
|
||||
if(watched[board][i].id == threadID) {
|
||||
if(watched[board][i].id === threadID) {
|
||||
console.log(threadID);
|
||||
watched[board].splice(i as any, 1);
|
||||
setStorageVal("watched", watched, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue