mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2025-10-07 07:22:37 +02:00
types and bugfixes
This commit is contained in:
parent
5a34fa1435
commit
4494192787
@ -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))
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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])
|
||||
|
||||
@ -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) } }
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ export interface BoardConfig {
|
||||
}
|
||||
|
||||
export interface Board {
|
||||
length?: number,
|
||||
cooldowns(): object
|
||||
forced_anon: 1 | 0,
|
||||
ID: string,
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -20,6 +20,7 @@ const SWTinyboard = {
|
||||
}
|
||||
},
|
||||
name: 'Tinyboard',
|
||||
software: 'Tinyboard',
|
||||
isOPContainerThread: true,
|
||||
mayLackJSON: true,
|
||||
threadModTimeIgnoresSage: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user