mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2026-03-20 01:37:47 +01:00
var to const
This commit is contained in:
parent
80167e23f4
commit
b25d2023ca
@ -5,14 +5,9 @@ import $$ from "../platform/$$"
|
||||
import Header from "./Header"
|
||||
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS206: Consider reworking classes to avoid initClass
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
Very sensitive, changing var to const
|
||||
*/
|
||||
const dialog = function(id, properties) {
|
||||
const dialog = function (id, properties) {
|
||||
const el = $.el('div', {
|
||||
className: 'dialog',
|
||||
id
|
||||
@ -30,8 +25,8 @@ const dialog = function(id, properties) {
|
||||
|
||||
return el
|
||||
}
|
||||
|
||||
var Menu = (function() {
|
||||
//eslint-disable-next-line
|
||||
var Menu = (function () {
|
||||
let currentMenu = undefined
|
||||
let lastToggledButton = undefined
|
||||
Menu = class Menu {
|
||||
@ -48,7 +43,7 @@ var Menu = (function() {
|
||||
this.onFocus = this.onFocus.bind(this)
|
||||
this.addEntry = this.addEntry.bind(this)
|
||||
this.type = type
|
||||
$.on(d, 'AddMenuEntry', ({detail}) => {
|
||||
$.on(d, 'AddMenuEntry', ({ detail }) => {
|
||||
if (detail.type !== this.type) { return }
|
||||
delete detail.open
|
||||
return this.addEntry(detail)
|
||||
@ -130,7 +125,7 @@ var Menu = (function() {
|
||||
[`${bRect.left}px`, '']
|
||||
:
|
||||
['', `${cWidth - bRect.right}px`])
|
||||
$.extend(this.menu.style, {top, right, bottom, left})
|
||||
$.extend(this.menu.style, { top, right, bottom, left })
|
||||
return this.menu.classList.toggle('left', right)
|
||||
}
|
||||
|
||||
@ -155,7 +150,7 @@ var Menu = (function() {
|
||||
$.rm(submenu)
|
||||
}
|
||||
submenu = $.el('div',
|
||||
{className: 'dialog submenu'})
|
||||
{ className: 'dialog submenu' })
|
||||
for (const subEntry of entry.subEntries) {
|
||||
this.insertEntry(subEntry, submenu, data)
|
||||
}
|
||||
@ -256,7 +251,7 @@ var Menu = (function() {
|
||||
['100%', 'auto']
|
||||
:
|
||||
['auto', '100%'])
|
||||
const {style} = submenu
|
||||
const { style } = submenu
|
||||
style.top = top
|
||||
style.bottom = bottom
|
||||
style.left = left
|
||||
@ -269,7 +264,7 @@ var Menu = (function() {
|
||||
}
|
||||
|
||||
parseEntry(entry) {
|
||||
const {el, subEntries} = entry
|
||||
const { el, subEntries } = entry
|
||||
$.addClass(el, 'entry')
|
||||
$.on(el, 'focus mouseover', this.onFocus)
|
||||
el.style.order = entry.order || 100
|
||||
@ -284,7 +279,7 @@ var Menu = (function() {
|
||||
return Menu
|
||||
})()
|
||||
|
||||
export var dragstart = function (e) {
|
||||
export const dragstart = function (e) {
|
||||
let isTouching
|
||||
if ((e.type === 'mousedown') && (e.button !== 0)) { return } // not LMB
|
||||
// prevent text selection
|
||||
@ -330,7 +325,7 @@ export var dragstart = function (e) {
|
||||
}
|
||||
}
|
||||
|
||||
export var touchmove = function (e) {
|
||||
export const touchmove = function (e) {
|
||||
for (const touch of e.changedTouches) {
|
||||
if (touch.identifier === this.identifier) {
|
||||
drag.call(this, touch)
|
||||
@ -339,8 +334,8 @@ export var touchmove = function (e) {
|
||||
}
|
||||
}
|
||||
|
||||
export var drag = function (e) {
|
||||
const {clientX, clientY} = e
|
||||
export const drag = function (e) {
|
||||
const { clientX, clientY } = e
|
||||
|
||||
let left = clientX - this.dx
|
||||
left = left < 10 ?
|
||||
@ -368,14 +363,14 @@ export var drag = function (e) {
|
||||
:
|
||||
''
|
||||
|
||||
const {style} = this
|
||||
const { style } = this
|
||||
style.left = left
|
||||
style.right = right
|
||||
style.top = top
|
||||
return style.bottom = bottom
|
||||
}
|
||||
|
||||
export var touchend = function (e) {
|
||||
export const touchend = function (e) {
|
||||
for (const touch of e.changedTouches) {
|
||||
if (touch.identifier === this.identifier) {
|
||||
dragend.call(this)
|
||||
@ -384,7 +379,7 @@ export var touchend = function (e) {
|
||||
}
|
||||
}
|
||||
|
||||
export var dragend = function () {
|
||||
export const dragend = function () {
|
||||
if (this.isTouching) {
|
||||
$.off(d, 'touchmove', this.move)
|
||||
$.off(d, 'touchend touchcancel', this.up)
|
||||
@ -417,9 +412,9 @@ const hoverstart = function ({ root, el, latestEvent, endEvents, height, width,
|
||||
o.hoverend = hoverend.bind(o)
|
||||
|
||||
o.hover(o.latestEvent)
|
||||
new MutationObserver(function() {
|
||||
new MutationObserver(function () {
|
||||
if (el.parentNode) { return o.hover(o.latestEvent) }
|
||||
}).observe(el, {childList: true})
|
||||
}).observe(el, { childList: true })
|
||||
|
||||
$.on(root, endEvents, o.hoverend)
|
||||
if ($.x('ancestor::div[contains(@class,"inline")][1]', root)) {
|
||||
@ -428,17 +423,17 @@ 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) } }
|
||||
o.workaround = function (e) { if (!root.contains(e.target)) { return o.hoverend(e) } }
|
||||
return $.on(doc, 'mousemove', o.workaround)
|
||||
}
|
||||
|
||||
hoverstart.padding = 25
|
||||
|
||||
export var hover = function (e) {
|
||||
export const hover = function (e) {
|
||||
this.latestEvent = e
|
||||
const height = (this.height || this.el.offsetHeight) + hoverstart.padding
|
||||
const width = (this.width || this.el.offsetWidth)
|
||||
const {clientX, clientY} = Conf['Follow Cursor'] ? e : this
|
||||
const { clientX, clientY } = Conf['Follow Cursor'] ? e : this
|
||||
|
||||
const top = this.isImage ?
|
||||
Math.max(0, (clientY * (this.clientHeight - height)) / this.clientHeight)
|
||||
@ -452,13 +447,13 @@ export var hover = function (e) {
|
||||
marginX += 'px'
|
||||
const [left, right] = Array.from(clientX <= threshold ? [marginX, ''] : ['', marginX])
|
||||
|
||||
const {style} = this
|
||||
const { style } = this
|
||||
style.top = top + 'px'
|
||||
style.left = left
|
||||
return style.right = right
|
||||
}
|
||||
|
||||
export var hoverend = function (e) {
|
||||
export const hoverend = function (e) {
|
||||
if (((e.type === 'keydown') && (e.keyCode !== 13)) || (e.target.nodeName === "TEXTAREA")) { return }
|
||||
if (!this.noRemove) { $.rm(this.el) }
|
||||
$.off(this.root, this.endEvents, this.hoverend)
|
||||
@ -472,7 +467,7 @@ export var hoverend = function (e) {
|
||||
export const checkbox = function (name, text, checked) {
|
||||
if (checked == null) { checked = Conf[name] }
|
||||
const label = $.el('label')
|
||||
const input = $.el('input', {type: 'checkbox', name, checked})
|
||||
const input = $.el('input', { type: 'checkbox', name, checked })
|
||||
$.add(label, [input, $.tn(` ${text}`)])
|
||||
return label
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ import QuickReplyPage from './QR/QuickReply.html'
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
|
||||
var QR = {
|
||||
const QR = {
|
||||
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'],
|
||||
|
||||
validExtension: /\.(jpe?g|png|gif|pdf|swf|webm)$/i,
|
||||
@ -70,7 +70,7 @@ var QR = {
|
||||
href: 'javascript:;'
|
||||
}
|
||||
))
|
||||
$.on(sc, 'click', function() {
|
||||
$.on(sc, 'click', function () {
|
||||
if (!QR.postingIsEnabled) { return }
|
||||
if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) {
|
||||
QR.open()
|
||||
@ -89,7 +89,7 @@ var QR = {
|
||||
QR.captcha = Captcha[captchaVersion]
|
||||
QR.postingIsEnabled = true
|
||||
|
||||
const {config} = g.BOARD
|
||||
const { config } = g.BOARD
|
||||
const prop = (key, def) => +(config[key] ?? def)
|
||||
|
||||
QR.min_width = prop('min_image_width', 1)
|
||||
@ -108,14 +108,14 @@ var QR = {
|
||||
|
||||
if (origToggle = $.id('togglePostFormLink')) {
|
||||
const link = $.el('h1',
|
||||
{className: "qr-link-container"})
|
||||
{ className: "qr-link-container" })
|
||||
$.extend(link, {
|
||||
innerHTML:
|
||||
`<a href="javascript:;" class="qr-link">${g.VIEW === "thread" ? "Reply to Thread" : "Start a Thread"}</a>`
|
||||
})
|
||||
|
||||
QR.link = link.firstElementChild
|
||||
$.on(link.firstChild, 'click', function() {
|
||||
$.on(link.firstChild, 'click', function () {
|
||||
QR.open()
|
||||
return QR.nodes.com.focus()
|
||||
})
|
||||
@ -127,10 +127,10 @@ var QR = {
|
||||
if (g.VIEW === 'thread') {
|
||||
let navLinksBot
|
||||
const linkBot = $.el('div',
|
||||
{className: "brackets-wrap qr-link-container-bottom"})
|
||||
$.extend(linkBot, {innerHTML: '<a href="javascript:;" class="qr-link-bottom">Reply to Thread</a>'})
|
||||
{ className: "brackets-wrap qr-link-container-bottom" })
|
||||
$.extend(linkBot, { innerHTML: '<a href="javascript:;" class="qr-link-bottom">Reply to Thread</a>' })
|
||||
|
||||
$.on(linkBot.firstElementChild, 'click', function() {
|
||||
$.on(linkBot.firstElementChild, 'click', function () {
|
||||
QR.open()
|
||||
return QR.nodes.com.focus()
|
||||
})
|
||||
@ -157,7 +157,7 @@ var QR = {
|
||||
|
||||
statusCheck() {
|
||||
if (!QR.nodes) { return }
|
||||
const {thread} = QR.posts[0]
|
||||
const { thread } = QR.posts[0]
|
||||
if ((thread !== 'new') && g.threads.get(`${g.BOARD}.${thread}`).isDead) {
|
||||
return QR.abort()
|
||||
} else {
|
||||
@ -210,7 +210,7 @@ var QR = {
|
||||
},
|
||||
|
||||
focus() {
|
||||
return $.queueTask(function() {
|
||||
return $.queueTask(function () {
|
||||
if (!QR.inBubble()) {
|
||||
QR.hasFocus = d.activeElement && QR.nodes.el.contains(d.activeElement)
|
||||
return QR.nodes.el.classList.toggle('focus', QR.hasFocus)
|
||||
@ -310,7 +310,7 @@ var QR = {
|
||||
// Firefox automatically closes notifications
|
||||
// so we can't control the onclose properly.
|
||||
notif.onclose = () => notice.close()
|
||||
return notif.onshow = () => setTimeout(function() {
|
||||
return notif.onshow = () => setTimeout(function () {
|
||||
notif.onclose = null
|
||||
return notif.close()
|
||||
}
|
||||
@ -321,7 +321,8 @@ var QR = {
|
||||
|
||||
connectionError() {
|
||||
return $.el('span',
|
||||
{ innerHTML:
|
||||
{
|
||||
innerHTML:
|
||||
'Connection error while posting. ' +
|
||||
'[<a href="' + meta.faq + '#connection-errors" target="_blank">More info</a>]'
|
||||
}
|
||||
@ -340,7 +341,7 @@ var QR = {
|
||||
status() {
|
||||
let disabled, value
|
||||
if (!QR.nodes) { return }
|
||||
const {thread} = QR.posts[0]
|
||||
const { thread } = QR.posts[0]
|
||||
if ((thread !== 'new') && g.threads.get(`${g.BOARD}.${thread}`).isDead) {
|
||||
value = 'Dead'
|
||||
disabled = true
|
||||
@ -352,7 +353,7 @@ var QR = {
|
||||
:
|
||||
QR.cooldown.seconds || value
|
||||
|
||||
const {status} = QR.nodes
|
||||
const { status } = QR.nodes
|
||||
status.value = !value ?
|
||||
'Submit'
|
||||
: QR.cooldown.auto ?
|
||||
@ -366,7 +367,7 @@ var QR = {
|
||||
QR.open()
|
||||
if (QR.selected.isLocked) {
|
||||
const index = QR.posts.indexOf(QR.selected);
|
||||
(QR.posts[index+1] || new QR.post()).select()
|
||||
(QR.posts[index + 1] || new QR.post()).select()
|
||||
$.addClass(QR.nodes.el, 'dump')
|
||||
return QR.cooldown.auto = true
|
||||
}
|
||||
@ -378,7 +379,7 @@ var QR = {
|
||||
if (!QR.postingIsEnabled) { return }
|
||||
const sel = d.getSelection()
|
||||
const post = Get.postFromNode(this)
|
||||
const {root} = post.nodes
|
||||
const { root } = post.nodes
|
||||
const postRange = new Range()
|
||||
postRange.selectNode(root)
|
||||
let text = post.board.ID === g.BOARD.ID ? `>>${post}\n` : `>>>/${post.board}/${post}\n`
|
||||
@ -426,7 +427,7 @@ var QR = {
|
||||
}
|
||||
|
||||
QR.openPost()
|
||||
const {com, thread} = QR.nodes
|
||||
const { com, thread } = QR.nodes
|
||||
if (!com.value) { thread.value = Get.threadFromNode(this) }
|
||||
|
||||
const wasOnlyQuotes = QR.selected.isOnlyQuotes()
|
||||
@ -450,7 +451,7 @@ var QR = {
|
||||
const counter = QR.nodes.charCount
|
||||
const count = QR.nodes.com.value.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '_').length
|
||||
counter.textContent = count
|
||||
counter.hidden = count < (QR.max_comment/2)
|
||||
counter.hidden = count < (QR.max_comment / 2)
|
||||
return (count > QR.max_comment ? $.addClass : $.rmClass)(counter, 'warning')
|
||||
},
|
||||
|
||||
@ -464,7 +465,7 @@ var QR = {
|
||||
const isVideo = /^video\//.test(file)
|
||||
const el = $.el((isVideo ? 'video' : 'img'))
|
||||
$.on(el, 'error', () => QR.openError())
|
||||
$.on(el, (isVideo ? 'loadeddata' : 'load'), function() {
|
||||
$.on(el, (isVideo ? 'loadeddata' : 'load'), function () {
|
||||
e.target.getContext('2d').drawImage(el, 0, 0)
|
||||
URL.revokeObjectURL(el.src)
|
||||
return $.event('QRImageDrawn', null, e.target)
|
||||
@ -482,7 +483,7 @@ var QR = {
|
||||
},
|
||||
|
||||
setFile(e) {
|
||||
const {file, name, source} = e.detail
|
||||
const { file, name, source } = e.detail
|
||||
if (name != null) { file.name = name }
|
||||
if (source != null) { file.source = source }
|
||||
QR.open()
|
||||
@ -516,7 +517,7 @@ var QR = {
|
||||
for (const item of e.clipboardData.items) {
|
||||
var file2
|
||||
if ((item.kind === 'file') && (file2 = item.getAsFile())) {
|
||||
const score2 = (2*(file2.size <= QR.max_size)) + (file2.type === 'image/png')
|
||||
const score2 = (2 * (file2.size <= QR.max_size)) + (file2.type === 'image/png')
|
||||
if (score2 > score) {
|
||||
file = file2
|
||||
score = score2
|
||||
@ -524,8 +525,8 @@ var QR = {
|
||||
}
|
||||
}
|
||||
if (file) {
|
||||
const {type} = file
|
||||
const blob = new Blob([file], {type})
|
||||
const { type } = file
|
||||
const blob = new Blob([file], { type })
|
||||
blob.name = `${Conf['pastedname']}.${$.getOwn(QR.extensionFromType, type) || 'jpg'}`
|
||||
QR.open()
|
||||
QR.handleFiles([blob])
|
||||
@ -534,20 +535,20 @@ var QR = {
|
||||
},
|
||||
|
||||
pasteFF() {
|
||||
const {pasteArea} = QR.nodes
|
||||
const { pasteArea } = QR.nodes
|
||||
if (!pasteArea.childNodes.length) { return }
|
||||
const images = $$('img', pasteArea)
|
||||
$.rmAll(pasteArea)
|
||||
for (const img of images) {
|
||||
var m
|
||||
const {src} = img
|
||||
const { src } = img
|
||||
if (m = src.match(/data:(image\/(\w+));base64,(.+)/)) {
|
||||
const bstr = atob(m[3])
|
||||
const arr = new Uint8Array(bstr.length)
|
||||
for (let i = 0, end = bstr.length, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) {
|
||||
arr[i] = bstr.charCodeAt(i)
|
||||
}
|
||||
const blob = new Blob([arr], {type: m[1]})
|
||||
const blob = new Blob([arr], { type: m[1] })
|
||||
blob.name = `${Conf['pastedname']}.${m[2]}`
|
||||
QR.handleFiles([blob])
|
||||
} else if (/^https?:\/\//.test(src)) {
|
||||
@ -559,11 +560,11 @@ var QR = {
|
||||
handleUrl(urlDefault) {
|
||||
QR.open()
|
||||
QR.selected.preventAutoPost()
|
||||
return CrossOrigin.permission(function() {
|
||||
return CrossOrigin.permission(function () {
|
||||
const url = prompt('Enter a URL:', urlDefault)
|
||||
if (url === null) { return }
|
||||
QR.nodes.fileButton.focus()
|
||||
return CrossOrigin.file(url, function(blob) {
|
||||
return CrossOrigin.file(url, function (blob) {
|
||||
if (blob && !/^text\//.test(blob.type)) {
|
||||
return QR.handleFiles([blob])
|
||||
} else {
|
||||
@ -676,8 +677,8 @@ var QR = {
|
||||
setNode('flashTag', '[name=filetag]')
|
||||
setNode('fileInput', '[type=file]')
|
||||
|
||||
const {config} = g.BOARD
|
||||
const {classList} = QR.nodes.el
|
||||
const { config } = g.BOARD
|
||||
const { classList } = QR.nodes.el
|
||||
classList.toggle('forced-anon', QR.forcedAnon)
|
||||
classList.toggle('has-spoiler', QR.spoiler)
|
||||
classList.toggle('has-sjis', !!config.sjis_tags)
|
||||
@ -687,7 +688,7 @@ var QR = {
|
||||
|
||||
if (parseInt(Conf['customCooldown'], 10) > 0) {
|
||||
$.addClass(QR.nodes.fileSubmit, 'custom-cooldown')
|
||||
$.get('customCooldownEnabled', Conf['customCooldownEnabled'], function({customCooldownEnabled}) {
|
||||
$.get('customCooldownEnabled', Conf['customCooldownEnabled'], function ({ customCooldownEnabled }) {
|
||||
QR.setCustomCooldown(customCooldownEnabled)
|
||||
return $.sync('customCooldownEnabled', QR.setCustomCooldown)
|
||||
})
|
||||
@ -706,8 +707,8 @@ var QR = {
|
||||
$.on(nodes.drawButton, 'click', QR.oekaki.draw)
|
||||
$.on(nodes.fileButton, 'click', QR.openFileInput)
|
||||
$.on(nodes.noFile, 'click', QR.openFileInput)
|
||||
$.on(nodes.filename, 'focus', function() { return $.addClass(this.parentNode, 'focus') })
|
||||
$.on(nodes.filename, 'blur', function() { return $.rmClass(this.parentNode, 'focus') })
|
||||
$.on(nodes.filename, 'focus', function () { return $.addClass(this.parentNode, 'focus') })
|
||||
$.on(nodes.filename, 'blur', function () { return $.rmClass(this.parentNode, 'focus') })
|
||||
$.on(nodes.spoiler, 'change', () => QR.selected.nodes.spoiler.click())
|
||||
$.on(nodes.oekakiButton, 'click', QR.oekaki.button)
|
||||
$.on(nodes.fileRM, 'click', () => QR.selected.rmFile())
|
||||
@ -726,12 +727,12 @@ var QR = {
|
||||
if (($.engine === 'gecko') && !window.DataTransferItemList) {
|
||||
nodes.pasteArea.hidden = false
|
||||
}
|
||||
new MutationObserver(QR.pasteFF).observe(nodes.pasteArea, {childList: true})
|
||||
new MutationObserver(QR.pasteFF).observe(nodes.pasteArea, { childList: true })
|
||||
|
||||
// save selected post's data
|
||||
const items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']
|
||||
let i = 0
|
||||
const save = function() { return QR.selected.save(this) }
|
||||
const save = function () { return QR.selected.save(this) }
|
||||
while ((name = items[i++])) {
|
||||
var node
|
||||
if (!(node = nodes[name])) { continue }
|
||||
@ -742,7 +743,7 @@ var QR = {
|
||||
// XXX Blink and WebKit treat width and height of <textarea>s as min-width and min-height
|
||||
if (($.engine === 'gecko') && Conf['Remember QR Size']) {
|
||||
$.get('QR Size', '', item => nodes.com.style.cssText = item['QR Size'])
|
||||
$.on(nodes.com, 'mouseup', function(e) {
|
||||
$.on(nodes.com, 'mouseup', function (e) {
|
||||
if (e.button !== 0) { return }
|
||||
return $.set('QR Size', this.style.cssText)
|
||||
})
|
||||
@ -771,7 +772,7 @@ var QR = {
|
||||
}
|
||||
)
|
||||
|
||||
const addFlag = (value, textContent) => $.add(select, $.el('option', {value, textContent}))
|
||||
const addFlag = (value, textContent) => $.add(select, $.el('option', { value, textContent }))
|
||||
|
||||
addFlag('0', (g.BOARD.config.country_flags ? 'Geographic Location' : 'None'))
|
||||
for (const value in g.BOARD.config.board_flags) {
|
||||
@ -783,7 +784,7 @@ var QR = {
|
||||
},
|
||||
|
||||
flagsInput() {
|
||||
const {nodes} = QR
|
||||
const { nodes } = QR
|
||||
if (!nodes) { return }
|
||||
if (nodes.flag) {
|
||||
$.rm(nodes.flag)
|
||||
@ -896,7 +897,7 @@ var QR = {
|
||||
form: $.formData(formData)
|
||||
}
|
||||
if (Conf['Show Upload Progress']) {
|
||||
options.onprogress = function(e) {
|
||||
options.onprogress = function (e) {
|
||||
if (this !== QR.req?.upload) { return } // aborted
|
||||
if (e.loaded < e.total) {
|
||||
// Uploading...
|
||||
@ -910,7 +911,7 @@ var QR = {
|
||||
}
|
||||
}
|
||||
|
||||
let cb = function(response) {
|
||||
let cb = function (response) {
|
||||
if (response != null) {
|
||||
QR.currentCaptcha = response
|
||||
if (QR.captcha === Captcha.v2) {
|
||||
@ -942,7 +943,7 @@ var QR = {
|
||||
return cb = null
|
||||
}
|
||||
}
|
||||
captcha(function(response) {
|
||||
captcha(function (response) {
|
||||
if ((QR.captcha === Captcha.v2) && Captcha.cache.haveCookie()) {
|
||||
cb?.()
|
||||
if (response) { return Captcha.cache.save(response) }
|
||||
@ -1043,13 +1044,13 @@ var QR = {
|
||||
postID
|
||||
})
|
||||
// XXX deprecated
|
||||
$.event('QRPostSuccessful_', {boardID: g.BOARD.ID, threadID, postID})
|
||||
$.event('QRPostSuccessful_', { boardID: g.BOARD.ID, threadID, postID })
|
||||
|
||||
// Enable auto-posting if we have stuff left to post, disable it otherwise.
|
||||
const postsCount = QR.posts.length - 1
|
||||
QR.cooldown.auto = postsCount && isReply
|
||||
|
||||
const lastPostToThread = !((function() { for (const p of QR.posts.slice(1)) { if (p.thread === post.thread) { return true } } })())
|
||||
const lastPostToThread = !((function () { for (const p of QR.posts.slice(1)) { if (p.thread === post.thread) { return true } } })())
|
||||
|
||||
if (postsCount) {
|
||||
post.rm()
|
||||
@ -1097,7 +1098,7 @@ var QR = {
|
||||
|
||||
waitForThread(url, cb) {
|
||||
let attempts = 0
|
||||
const check = function() {
|
||||
const check = function () {
|
||||
return $.ajax(url, {
|
||||
onloadend() {
|
||||
attempts++
|
||||
|
||||
@ -16,19 +16,19 @@ import { dict } from "../platform/helpers"
|
||||
<3 aeosynth
|
||||
*/
|
||||
|
||||
var QuoteThreading = {
|
||||
const QuoteThreading = {
|
||||
init() {
|
||||
if (!Conf['Quote Threading'] || (g.VIEW !== 'thread')) { return }
|
||||
|
||||
this.controls = $.el('label',
|
||||
{innerHTML: "<input id=\"threadingControl\" name=\"Thread Quotes\" type=\"checkbox\"> Threading"})
|
||||
{ innerHTML: "<input id=\"threadingControl\" name=\"Thread Quotes\" type=\"checkbox\"> Threading" })
|
||||
|
||||
this.threadNewLink = $.el('span', {
|
||||
className: 'brackets-wrap threadnewlink',
|
||||
hidden: true
|
||||
}
|
||||
)
|
||||
$.extend(this.threadNewLink, {innerHTML: "<a href=\"javascript:;\">Thread New Posts</a>"})
|
||||
$.extend(this.threadNewLink, { innerHTML: "<a href=\"javascript:;\">Thread New Posts</a>" })
|
||||
|
||||
this.input = $('input', this.controls)
|
||||
this.input.checked = Conf['Thread Quotes']
|
||||
@ -83,7 +83,7 @@ var QuoteThreading = {
|
||||
|
||||
setThread() {
|
||||
QuoteThreading.thread = this
|
||||
return $.asap((() => !Conf['Thread Updater'] || $('.navLinksBot > .updatelink')), function() {
|
||||
return $.asap((() => !Conf['Thread Updater'] || $('.navLinksBot > .updatelink')), function () {
|
||||
let navLinksBot
|
||||
if (navLinksBot = $('.navLinksBot')) { return $.add(navLinksBot, [$.tn(' '), QuoteThreading.threadNewLink]) }
|
||||
})
|
||||
@ -137,15 +137,15 @@ var QuoteThreading = {
|
||||
|
||||
const descendants = QuoteThreading.descendants(post)
|
||||
if (!Unread.posts.has(parent.ID)) {
|
||||
if ((function() { for (const x of descendants) { if (Unread.posts.has(x.ID)) { return true } } })()) {
|
||||
if ((function () { for (const x of descendants) { if (Unread.posts.has(x.ID)) { return true } } })()) {
|
||||
QuoteThreading.threadNewLink.hidden = false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const {order} = Unread
|
||||
const { order } = Unread
|
||||
const children = (QuoteThreading.children[parent.fullID] || (QuoteThreading.children[parent.fullID] = []))
|
||||
const threadContainer = parent.nodes.threadContainer || $.el('div', {className: 'threadContainer'})
|
||||
const threadContainer = parent.nodes.threadContainer || $.el('div', { className: 'threadContainer' })
|
||||
const nodes = [post.nodes.root]
|
||||
if (post.nodes.threadContainer) { nodes.push(post.nodes.threadContainer) }
|
||||
|
||||
@ -160,7 +160,7 @@ var QuoteThreading = {
|
||||
let prev2
|
||||
let prev = parent
|
||||
while ((prev2 = QuoteThreading.children[prev.fullID]) && prev2.length) {
|
||||
prev = prev2[prev2.length-1]
|
||||
prev = prev2[prev2.length - 1]
|
||||
}
|
||||
for (let k = descendants.length - 1; k >= 0; k--) { x = descendants[k]; order.after(order[prev.ID], order[x.ID]) }
|
||||
children.push(post)
|
||||
@ -180,8 +180,8 @@ var QuoteThreading = {
|
||||
|
||||
rethread() {
|
||||
if (!QuoteThreading.ready) { return }
|
||||
const {thread} = QuoteThreading
|
||||
const {posts} = thread
|
||||
const { thread } = QuoteThreading
|
||||
const { posts } = thread
|
||||
|
||||
QuoteThreading.threadNewLink.hidden = true
|
||||
|
||||
@ -191,7 +191,7 @@ var QuoteThreading = {
|
||||
const nodes = []
|
||||
Unread.order = new RandomAccessList()
|
||||
QuoteThreading.inserted = dict()
|
||||
posts.forEach(function(post) {
|
||||
posts.forEach(function (post) {
|
||||
if (post.isFetchedQuote) { return }
|
||||
Unread.order.push(post)
|
||||
if (post.isReply) { nodes.push(post.nodes.root) }
|
||||
|
||||
@ -15,18 +15,18 @@ import PostRedirect from "../Posting/PostRedirect"
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var QuoteYou = {
|
||||
const QuoteYou = {
|
||||
init() {
|
||||
if (!Conf['Remember Your Posts']) { return }
|
||||
|
||||
this.db = new DataBoard('yourPosts')
|
||||
$.sync('Remember Your Posts', enabled => Conf['Remember Your Posts'] = enabled)
|
||||
$.on(d, 'QRPostSuccessful', function(e) {
|
||||
$.on(d, 'QRPostSuccessful', function (e) {
|
||||
const cb = PostRedirect.delay()
|
||||
return $.get('Remember Your Posts', Conf['Remember Your Posts'], function(items) {
|
||||
return $.get('Remember Your Posts', Conf['Remember Your Posts'], function (items) {
|
||||
if (!items['Remember Your Posts']) { return }
|
||||
const {boardID, threadID, postID} = e.detail
|
||||
return QuoteYou.db.set({boardID, threadID, postID, val: true}, cb)
|
||||
const { boardID, threadID, postID } = e.detail
|
||||
return QuoteYou.db.set({ boardID, threadID, postID, val: true }, cb)
|
||||
})
|
||||
})
|
||||
|
||||
@ -88,9 +88,9 @@ var QuoteYou = {
|
||||
menu: {
|
||||
init() {
|
||||
const label = $.el('label',
|
||||
{className: 'toggle-you'}
|
||||
{ className: 'toggle-you' }
|
||||
,
|
||||
{innerHTML: '<input type="checkbox"> You'})
|
||||
{ innerHTML: '<input type="checkbox"> You' })
|
||||
const input = $('input', label)
|
||||
$.on(input, 'change', QuoteYou.menu.toggle)
|
||||
return Menu.menu?.addEntry({
|
||||
@ -105,8 +105,8 @@ var QuoteYou = {
|
||||
},
|
||||
|
||||
toggle() {
|
||||
const {post} = QuoteYou.menu
|
||||
const data = {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID, val: true}
|
||||
const { post } = QuoteYou.menu
|
||||
const data = { boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID, val: true }
|
||||
if (this.checked) {
|
||||
QuoteYou.db.set(data)
|
||||
} else {
|
||||
@ -134,7 +134,7 @@ var QuoteYou = {
|
||||
seek(type) {
|
||||
let highlighted, post
|
||||
let result
|
||||
const {highlight} = g.SITE.classes
|
||||
const { highlight } = g.SITE.classes
|
||||
if (highlighted = $(`.${highlight}`)) { $.rmClass(highlighted, highlight) }
|
||||
|
||||
if (!QuoteYou.lastRead || !doc.contains(QuoteYou.lastRead) || !$.hasClass(QuoteYou.lastRead, 'quotesYou')) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import Redirect from "../Archive/Redirect"
|
||||
import Callbacks from "../classes/Callbacks"
|
||||
import Post from "../classes/Post"
|
||||
import { Conf, doc,g } from "../globals/globals"
|
||||
import { Conf, doc, g } from "../globals/globals"
|
||||
import ExpandComment from "../Miscellaneous/ExpandComment"
|
||||
import $ from "../platform/$"
|
||||
import $$ from "../platform/$$"
|
||||
@ -12,7 +12,7 @@ import $$ from "../platform/$$"
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
|
||||
*/
|
||||
var Quotify = {
|
||||
const Quotify = {
|
||||
init() {
|
||||
if (!['index', 'thread'].includes(g.VIEW) || !Conf['Resurrect Quotes']) { return }
|
||||
|
||||
@ -48,9 +48,9 @@ var Quotify = {
|
||||
const boardID = m[1]
|
||||
const threadID = m[2]
|
||||
const postID = link.hash.match(/^#[pq]?(\d+)$|$/)[1] || threadID
|
||||
if (Redirect.to('post', {boardID, postID})) {
|
||||
if (Redirect.to('post', { boardID, postID })) {
|
||||
$.addClass(link, 'quotelink')
|
||||
$.extend(link.dataset, {boardID, threadID, postID})
|
||||
$.extend(link.dataset, { boardID, threadID, postID })
|
||||
return this.nodes.archivelinks.push(link)
|
||||
}
|
||||
},
|
||||
@ -99,12 +99,12 @@ var Quotify = {
|
||||
}
|
||||
)
|
||||
$.add(a, Post.deadMark.cloneNode(true))
|
||||
$.extend(a.dataset, {boardID, threadID: post.thread.ID, postID})
|
||||
$.extend(a.dataset, { boardID, threadID: post.thread.ID, postID })
|
||||
}
|
||||
|
||||
} else {
|
||||
const redirect = Redirect.to('thread', {boardID, threadID: 0, postID})
|
||||
const fetchable = Redirect.to('post', {boardID, postID})
|
||||
const redirect = Redirect.to('thread', { boardID, threadID: 0, postID })
|
||||
const fetchable = Redirect.to('post', { boardID, postID })
|
||||
if (redirect || fetchable) {
|
||||
// Replace the .deadlink span if we can redirect or fetch the post.
|
||||
a = $.el('a', {
|
||||
@ -117,7 +117,7 @@ var Quotify = {
|
||||
if (fetchable) {
|
||||
// Make it function as a normal quote if we can fetch the post.
|
||||
$.addClass(a, 'quotelink')
|
||||
$.extend(a.dataset, {boardID, postID})
|
||||
$.extend(a.dataset, { boardID, postID })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ var Quotify = {
|
||||
let el
|
||||
if (!(el = deadlink.previousSibling) || (el.nodeName === 'BR')) {
|
||||
const green = $.el('span',
|
||||
{className: 'quote'})
|
||||
{ className: 'quote' })
|
||||
$.before(deadlink, green)
|
||||
$.add(green, deadlink)
|
||||
}
|
||||
|
||||
@ -111,12 +111,12 @@ const Main = {
|
||||
if (platform === 'crx') { w = (w.wrappedJSObject || w) }
|
||||
if (`${meta.name} antidup` in w) { return }
|
||||
w[`${meta.name} antidup`] = true
|
||||
} catch (error) { }
|
||||
} catch (error) { /* empty */ }
|
||||
|
||||
// Don't run inside ad iframes.
|
||||
try {
|
||||
if (window.frameElement && ['', 'about:blank'].includes(window.frameElement.src)) { return }
|
||||
} catch (error1) { }
|
||||
} catch (error1) { /* empty */ }
|
||||
|
||||
// Detect multiple copies of 4chan X
|
||||
if (doc && $.hasClass(doc, 'fourchan-x')) { return }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user