diff --git a/src/General/Get.ts b/src/General/Get.ts index ad32061..5e190aa 100644 --- a/src/General/Get.ts +++ b/src/General/Get.ts @@ -1,9 +1,10 @@ +import Post from "../classes/Post" import { Conf, g } from "../globals/globals" import $ from "../platform/$" const Get = { - url(type, IDs, ...args) { + url(type: string, IDs: any, ...args: any[]) { let f, site if ((site = g.sites[IDs.siteID]) && (f = $.getOwn(site.urls, type))) { return f(IDs, ...Array.from(args)) diff --git a/src/General/UI.ts b/src/General/UI.ts index adad6dc..1147452 100644 --- a/src/General/UI.ts +++ b/src/General/UI.ts @@ -1,3 +1,6 @@ +import { event } from "jquery" + +import Callbacks from "../classes/Callbacks" import { Conf, d, doc } from "../globals/globals" import Main from "../main/Main" import $ from "../platform/$" @@ -390,9 +393,20 @@ export const dragend = function () { return $.set(`${this.id}.position`, this.style.cssText) } -const hoverstart = function ({ root, el, latestEvent, endEvents, height, width, cb, noRemove }) { +const hoverstart = function ({ root, el, latestEvent, endEvents, height, width, cb, noRemove }: { + root: HTMLElement, + el: HTMLElement, + latestEvent: Event, + endEvents: string[], + height: number, + width: number, + cb: Callbacks, + noRemove: boolean +}) { const rect = root.getBoundingClientRect() const o = { + hover, + hoverend, root, el, style: el.style, @@ -403,6 +417,7 @@ const hoverstart = function ({ root, el, latestEvent, endEvents, height, width, clientHeight: doc.clientHeight, clientWidth: doc.clientWidth, height, + workaround: function (e) { if (!root.contains(e.target)) { return o.hoverend(e) } }, width, noRemove, clientX: (rect.left + rect.right) / 2, @@ -423,7 +438,6 @@ const hoverstart = function ({ root, el, latestEvent, endEvents, height, width, $.on(root, 'mousemove', o.hover) // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955 - o.workaround = function (e) { if (!root.contains(e.target)) { return o.hoverend(e) } } return $.on(doc, 'mousemove', o.workaround) } @@ -466,9 +480,10 @@ export const hoverend = function (e) { export const checkbox = function (name, text, checked) { if (checked == null) { checked = Conf[name] } - const label = $.el('label') + const label = $.el('label', { className: 'checkbox' }) const input = $.el('input', { type: 'checkbox', name, checked }) $.add(label, [input, $.tn(` ${text}`)]) + return label } diff --git a/src/Menu/Menu.ts b/src/Menu/Menu.ts index dd009a1..a522aa0 100644 --- a/src/Menu/Menu.ts +++ b/src/Menu/Menu.ts @@ -1,13 +1,10 @@ import Callbacks from "../classes/Callbacks" +import Post from "../classes/Post" import UI from "../General/UI" import { Conf, g } from "../globals/globals" import $ from "../platform/$" -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md - */ + const Menu = { init() { if (!['index', 'thread'].includes(g.VIEW) || !Conf['Menu']) { return } @@ -49,7 +46,7 @@ const Menu = { makeButton(post, button) { if (!button) { button = Menu.button.cloneNode(true) } - $.on(button, 'click', function (e) { + $.on(button, 'click', function (e: MouseEvent) { return Menu.menu.toggle(e, this, post) }) return button diff --git a/src/Monitoring/Unread.ts b/src/Monitoring/Unread.ts index b1d5651..63eecf8 100644 --- a/src/Monitoring/Unread.ts +++ b/src/Monitoring/Unread.ts @@ -1,5 +1,6 @@ import Callbacks from "../classes/Callbacks" import DataBoard from "../classes/DataBoard" +import Post from "../classes/Post" import RandomAccessList from "../classes/RandomAccessList" import Get from "../General/Get" import Header from "../General/Header" @@ -10,12 +11,7 @@ import QuoteYou from "../Quotelinks/QuoteYou" import Favicon from "./Favicon" import ThreadWatcher from "./ThreadWatcher" -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md - */ + const Unread = { init() { if ((g.VIEW !== 'thread') || ( @@ -52,6 +48,17 @@ const Unread = { cb: this.addPost }) }, + lastReadPost: null, + title: '', + readCount: 0, + posts: null, + thread: null, + postsQuotingYou: null, + hr: null, + order: null, + position: null, + db: null, + linePosition: null, node() { Unread.thread = this diff --git a/src/classes/DataBoard.ts b/src/classes/DataBoard.ts index 1ae9a6b..f4bd2b9 100644 --- a/src/classes/DataBoard.ts +++ b/src/classes/DataBoard.ts @@ -28,7 +28,7 @@ export default class DataBoard { this.changes = [] } - constructor(key: string, sync: boolean, dontClean: boolean) { + constructor(key: string, sync: boolean, dontClean?: boolean) { this.onSync = this.onSync.bind(this) this.key = key this.initData(Conf[this.key]) diff --git a/src/classes/RandomAccessList.ts b/src/classes/RandomAccessList.ts index d023f42..369a8da 100644 --- a/src/classes/RandomAccessList.ts +++ b/src/classes/RandomAccessList.ts @@ -7,7 +7,7 @@ export default class RandomAccessList { length: number last: any first: any - constructor(items) { + constructor(items?) { this.length = 0 if (items) { for (const item of items) { this.push(item) } } } diff --git a/src/globals/globals.ts b/src/globals/globals.ts index 9ae4d8a..5137df9 100644 --- a/src/globals/globals.ts +++ b/src/globals/globals.ts @@ -44,6 +44,7 @@ export interface BoardConfig { } export interface Board { + length?: number, cooldowns(): object forced_anon: 1 | 0, ID: string, diff --git a/src/platform/$.ts b/src/platform/$.ts index 4311c53..cee13b1 100644 --- a/src/platform/$.ts +++ b/src/platform/$.ts @@ -700,7 +700,12 @@ if (platform === 'crx') { } }) $.sync = (key: string, cb) => $.syncing[key] = cb - $.forceSync = function () {/* emptey */ } + $.forceSync = function (key: string) { + chrome.storage.local.get(key, function (data) { + const cb = $.syncing[key] + if (cb) { cb(data[key], key) } + }) + } $.crxWorking = function () { try { diff --git a/src/site/SW.tinyboard.ts b/src/site/SW.tinyboard.ts index 8985b17..4959c03 100644 --- a/src/site/SW.tinyboard.ts +++ b/src/site/SW.tinyboard.ts @@ -20,6 +20,7 @@ const SWTinyboard = { } }, name: 'Tinyboard', + software: 'Tinyboard', isOPContainerThread: true, mayLackJSON: true, threadModTimeIgnoresSage: true,