diff --git a/src/General/UI.ts b/src/General/UI.ts index b1d2ac7..adad6dc 100644 --- a/src/General/UI.ts +++ b/src/General/UI.ts @@ -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,13 +25,13 @@ 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 { static initClass() { - currentMenu = null + currentMenu = null lastToggledButton = null } @@ -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) @@ -59,8 +54,8 @@ var Menu = (function() { makeMenu() { const menu = $.el('div', { className: 'dialog', - id: 'menu', - tabIndex: 0 + id: 'menu', + tabIndex: 0 } ) menu.dataset.type = this.type @@ -88,7 +83,7 @@ var Menu = (function() { open(button, data) { let entry const menu = (this.menu = this.makeMenu()) - currentMenu = this + currentMenu = this lastToggledButton = button this.entries.sort((first, second) => first.order - second.order) @@ -116,21 +111,21 @@ var Menu = (function() { } setPosition() { - const mRect = this.menu.getBoundingClientRect() - const bRect = lastToggledButton.getBoundingClientRect() - const bTop = window.scrollY + bRect.top - const bLeft = window.scrollX + bRect.left + const mRect = this.menu.getBoundingClientRect() + const bRect = lastToggledButton.getBoundingClientRect() + const bTop = window.scrollY + bRect.top + const bLeft = window.scrollX + bRect.left const cHeight = doc.clientHeight - const cWidth = doc.clientWidth + const cWidth = doc.clientWidth const [top, bottom] = Array.from((bRect.top + bRect.height + mRect.height) < cHeight ? [`${bRect.bottom}px`, ''] - : + : ['', `${cHeight - bRect.top}px`]) const [left, right] = Array.from((bRect.left + mRect.width) < cWidth ? [`${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) } @@ -166,7 +161,7 @@ var Menu = (function() { $.rm(this.menu) delete this.menu $.rmClass(lastToggledButton, 'active') - currentMenu = null + currentMenu = null lastToggledButton = null $.off(d, 'click scroll CloseMenu', this.close) $.off(d, 'scroll', this.setPosition) @@ -244,23 +239,23 @@ var Menu = (function() { // Submenu positioning. if (!(submenu = $('.submenu', entry))) { return } - const sRect = submenu.getBoundingClientRect() - const eRect = entry.getBoundingClientRect() + const sRect = submenu.getBoundingClientRect() + const eRect = entry.getBoundingClientRect() const cHeight = doc.clientHeight - const cWidth = doc.clientWidth + const cWidth = doc.clientWidth const [top, bottom] = Array.from((eRect.top + sRect.height) < cHeight ? ['0px', 'auto'] - : + : ['auto', '0px']) const [left, right] = Array.from((eRect.right + sRect.width) < (cWidth - 150) ? ['100%', 'auto'] - : + : ['auto', '100%']) - const {style} = submenu - style.top = top + const { style } = submenu + style.top = top style.bottom = bottom - style.left = left - return style.right = right + style.left = left + return style.right = right } addEntry(entry) { @@ -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 @@ -296,14 +291,14 @@ export var dragstart = function (e) { const el = $.x('ancestor::div[contains(@class,"dialog")][1]', this) const rect = el.getBoundingClientRect() const screenHeight = doc.clientHeight - const screenWidth = doc.clientWidth + const screenWidth = doc.clientWidth const o = { - id: el.id, - style: el.style, - dx: e.clientX - rect.left, - dy: e.clientY - rect.top, + id: el.id, + style: el.style, + dx: e.clientX - rect.left, + dy: e.clientY - rect.top, height: screenHeight - rect.height, - width: screenWidth - rect.width, + width: screenWidth - rect.width, screenHeight, screenWidth, isTouching @@ -311,26 +306,26 @@ export var dragstart = function (e) { [o.topBorder, o.bottomBorder] = Array.from(Conf['Header auto-hide'] || !Conf['Fixed Header'] ? [0, 0] - : Conf['Bottom Header'] ? - [0, Header.bar.getBoundingClientRect().height] - : - [Header.bar.getBoundingClientRect().height, 0]) + : Conf['Bottom Header'] ? + [0, Header.bar.getBoundingClientRect().height] + : + [Header.bar.getBoundingClientRect().height, 0]) if (isTouching) { o.identifier = e.identifier o.move = touchmove.bind(o) - o.up = touchend.bind(o) + o.up = touchend.bind(o) $.on(d, 'touchmove', o.move) return $.on(d, 'touchend touchcancel', o.up) } else { // mousedown o.move = drag.bind(o) - o.up = dragend.bind(o) + o.up = dragend.bind(o) $.on(d, 'mousemove', o.move) - return $.on(d, 'mouseup', o.up) + return $.on(d, 'mouseup', o.up) } } -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,43 +334,43 @@ 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 ? 0 - : (this.width - left) < 10 ? - '' - : - ((left / this.screenWidth) * 100) + '%' + : (this.width - left) < 10 ? + '' + : + ((left / this.screenWidth) * 100) + '%' let top = clientY - this.dy top = top < (10 + this.topBorder) ? this.topBorder + 'px' - : (this.height - top) < (10 + this.bottomBorder) ? - '' - : - ((top / this.screenHeight) * 100) + '%' + : (this.height - top) < (10 + this.bottomBorder) ? + '' + : + ((top / this.screenHeight) * 100) + '%' const right = left === '' ? 0 - : + : '' const bottom = top === '' ? this.bottomBorder + 'px' - : + : '' - const {style} = this - style.left = left - style.right = right - style.top = top + 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,13 +379,13 @@ 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) } else { // mouseup $.off(d, 'mousemove', this.move) - $.off(d, 'mouseup', this.up) + $.off(d, 'mouseup', this.up) } return $.set(`${this.id}.position`, this.style.cssText) } @@ -406,43 +401,43 @@ const hoverstart = function ({ root, el, latestEvent, endEvents, height, width, endEvents, latestEvent, clientHeight: doc.clientHeight, - clientWidth: doc.clientWidth, + clientWidth: doc.clientWidth, height, width, noRemove, clientX: (rect.left + rect.right) / 2, clientY: (rect.top + rect.bottom) / 2 } - o.hover = hover.bind(o) + o.hover = hover.bind(o) 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) + $.on(root, endEvents, o.hoverend) if ($.x('ancestor::div[contains(@class,"inline")][1]', root)) { - $.on(d, 'keydown', o.hoverend) + $.on(d, 'keydown', o.hoverend) } $.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) + 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 width = (this.width || this.el.offsetWidth) + const { clientX, clientY } = Conf['Follow Cursor'] ? e : this const top = this.isImage ? Math.max(0, (clientY * (this.clientHeight - height)) / this.clientHeight) - : + : Math.max(0, Math.min(this.clientHeight - height, clientY - 120)) let threshold = this.clientWidth / 2 @@ -452,27 +447,27 @@ export var hover = function (e) { marginX += 'px' const [left, right] = Array.from(clientX <= threshold ? [marginX, ''] : ['', marginX]) - const {style} = this - style.top = top + 'px' - style.left = left + 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) - $.off(d, 'keydown', this.hoverend) + $.off(this.root, this.endEvents, this.hoverend) + $.off(d, 'keydown', this.hoverend) $.off(this.root, 'mousemove', this.hover) // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955 - $.off(doc, 'mousemove', this.workaround) + $.off(doc, 'mousemove', this.workaround) if (this.cb) { return this.cb.call(this) } } 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 } @@ -480,7 +475,7 @@ export const checkbox = function (name, text, checked) { const UI = { dialog, Menu, - hover: hoverstart, + hover: hoverstart, checkbox } export default UI diff --git a/src/Posting/QR.ts b/src/Posting/QR.ts index efdc961..b6abbc4 100644 --- a/src/Posting/QR.ts +++ b/src/Posting/QR.ts @@ -25,18 +25,18 @@ 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, typeFromExtension: { - 'jpg': 'image/jpeg', + 'jpg': 'image/jpeg', 'jpeg': 'image/jpeg', - 'png': 'image/png', - 'gif': 'image/gif', - 'pdf': 'application/pdf', - 'swf': 'application/vnd.adobe.flash.movie', + 'png': 'image/png', + 'gif': 'image/gif', + 'pdf': 'application/pdf', + 'swf': 'application/vnd.adobe.flash.movie', 'webm': 'video/webm' }, @@ -60,7 +60,7 @@ var QR = { Callbacks.Post.push({ name: 'Quick Reply', - cb: this.node + cb: this.node }) this.shortcut = (sc = $.el('a', { @@ -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,33 +89,33 @@ 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) + QR.min_width = prop('min_image_width', 1) QR.min_height = prop('min_image_height', 1) - QR.max_width = (QR.max_height = 10000) + QR.max_width = (QR.max_height = 10000) - QR.max_size = prop('max_filesize', 4194304) + QR.max_size = prop('max_filesize', 4194304) QR.max_size_video = prop('max_webm_filesize', QR.max_size) - QR.max_comment = prop('max_comment_chars', 2000) + QR.max_comment = prop('max_comment_chars', 2000) QR.max_width_video = (QR.max_height_video = 2048) QR.max_duration_video = prop('max_webm_duration', 120) QR.forcedAnon = !!config.forced_anon - QR.spoiler = !!config.spoilers + QR.spoiler = !!config.spoilers if (origToggle = $.id('togglePostFormLink')) { const link = $.el('h1', - {className: "qr-link-container"}) + { className: "qr-link-container" }) $.extend(link, { innerHTML: `${g.VIEW === "thread" ? "Reply to Thread" : "Start a Thread"}` }) 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: 'Reply to Thread'}) + { className: "brackets-wrap qr-link-container-bottom" }) + $.extend(linkBot, { innerHTML: 'Reply to Thread' }) - $.on(linkBot.firstElementChild, 'click', function() { + $.on(linkBot.firstElementChild, 'click', function () { QR.open() return QR.nodes.com.focus() }) @@ -138,14 +138,14 @@ var QR = { if (navLinksBot = $('.navLinksBot')) { $.prepend(navLinksBot, linkBot) } } - $.on(d, 'QRGetFile', QR.getFile) - $.on(d, 'QRDrawFile', QR.drawFile) - $.on(d, 'QRSetFile', QR.setFile) + $.on(d, 'QRGetFile', QR.getFile) + $.on(d, 'QRDrawFile', QR.drawFile) + $.on(d, 'QRSetFile', QR.setFile) - $.on(d, 'paste', QR.paste) - $.on(d, 'dragover', QR.dragOver) - $.on(d, 'drop', QR.dropFile) - $.on(d, 'dragstart dragend', QR.drag) + $.on(d, 'paste', QR.paste) + $.on(d, 'dragover', QR.dragOver) + $.on(d, 'drop', QR.dropFile) + $.on(d, 'dragstart dragend', QR.drag) $.on(d, 'IndexRefreshInternal', QR.generatePostableThreadsList) $.on(d, 'ThreadUpdate', QR.statusCheck) @@ -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,20 +310,21 @@ 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() } - , 7 * SECOND) + , 7 * SECOND) } } }, connectionError() { return $.el('span', - { innerHTML: - 'Connection error while posting. ' + - '[More info]' + { + innerHTML: + 'Connection error while posting. ' + + '[More info]' } ) }, @@ -340,25 +341,25 @@ 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' + value = 'Dead' disabled = true QR.cooldown.auto = false } value = QR.req ? QR.req.progress - : + : QR.cooldown.seconds || value - const {status} = QR.nodes + const { status } = QR.nodes status.value = !value ? 'Submit' - : QR.cooldown.auto ? - `Auto ${value}` - : - value + : QR.cooldown.auto ? + `Auto ${value}` + : + value return status.disabled = disabled || false }, @@ -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 } @@ -376,9 +377,9 @@ var QR = { let range e?.preventDefault() if (!QR.postingIsEnabled) { return } - const sel = d.getSelection() + 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` @@ -396,7 +397,7 @@ var QR = { if (!range.toString().trim()) { continue } - const frag = range.cloneContents() + const frag = range.cloneContents() const ancestor = range.commonAncestorContainer // Quoting the insides of a spoiler/code tag. if ($.x('ancestor-or-self::*[self::s or contains(@class,"removed-spoiler")]', ancestor)) { @@ -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() @@ -448,9 +449,9 @@ var QR = { characterCount() { const counter = QR.nodes.charCount - const count = QR.nodes.com.value.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '_').length + 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,8 +483,8 @@ var QR = { }, setFile(e) { - const {file, name, source} = e.detail - if (name != null) { file.name = name } + const { file, name, source } = e.detail + if (name != null) { file.name = name } if (source != null) { file.source = source } QR.open() return QR.handleFiles([file]) @@ -493,7 +494,7 @@ var QR = { // Let it drag anything from the page. const toggle = e.type === 'dragstart' ? $.off : $.on toggle(d, 'dragover', QR.dragOver) - return toggle(d, 'drop', QR.dropFile) + return toggle(d, 'drop', QR.dropFile) }, dragOver(e) { @@ -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 { @@ -575,7 +576,7 @@ var QR = { handleFiles(files) { if (this !== QR) { // file input - files = [...Array.from(this.files)] + files = [...Array.from(this.files)] this.value = null } if (!files.length) { return } @@ -611,7 +612,7 @@ var QR = { generatePostableThreadsList() { if (!QR.nodes) { return } - const list = QR.nodes.thread + const list = QR.nodes.thread const options = [list.firstElementChild] for (const thread of g.BOARD.threads.keys) { options.push($.el('option', { @@ -629,7 +630,7 @@ var QR = { // Fix the value if the option disappeared. list.value = g.VIEW === 'thread' ? g.THREADID - : + : 'new' return (g.VIEW === 'thread' ? $.addClass : $.rmClass)(QR.nodes.el, 'reply-to-thread') }, @@ -644,50 +645,50 @@ var QR = { const setNode = (name, query) => nodes[name] = $(query, dialog) - setNode('move', '.move') - setNode('autohide', '#autohide') - setNode('close', '.close') - setNode('thread', 'select') - setNode('form', 'form') - setNode('sjisToggle', '#sjis-toggle') - setNode('texButton', '#tex-preview-button') - setNode('name', '[data-name=name]') - setNode('email', '[data-name=email]') - setNode('sub', '[data-name=sub]') - setNode('com', '[data-name=com]') - setNode('charCount', '#char-count') - setNode('texPreview', '#tex-preview') - setNode('dumpList', '#dump-list') - setNode('addPost', '#add-post') - setNode('oekaki', '.oekaki') - setNode('drawButton', '#qr-draw-button') - setNode('fileSubmit', '#file-n-submit') - setNode('fileButton', '#qr-file-button') - setNode('noFile', '#qr-no-file') - setNode('filename', '#qr-filename') - setNode('spoiler', '#qr-file-spoiler') - setNode('oekakiButton', '#qr-oekaki-button') - setNode('fileRM', '#qr-filerm') - setNode('urlButton', '#url-button') - setNode('pasteArea', '#paste-area') + setNode('move', '.move') + setNode('autohide', '#autohide') + setNode('close', '.close') + setNode('thread', 'select') + setNode('form', 'form') + setNode('sjisToggle', '#sjis-toggle') + setNode('texButton', '#tex-preview-button') + setNode('name', '[data-name=name]') + setNode('email', '[data-name=email]') + setNode('sub', '[data-name=sub]') + setNode('com', '[data-name=com]') + setNode('charCount', '#char-count') + setNode('texPreview', '#tex-preview') + setNode('dumpList', '#dump-list') + setNode('addPost', '#add-post') + setNode('oekaki', '.oekaki') + setNode('drawButton', '#qr-draw-button') + setNode('fileSubmit', '#file-n-submit') + setNode('fileButton', '#qr-file-button') + setNode('noFile', '#qr-no-file') + setNode('filename', '#qr-filename') + setNode('spoiler', '#qr-file-spoiler') + setNode('oekakiButton', '#qr-oekaki-button') + setNode('fileRM', '#qr-filerm') + setNode('urlButton', '#url-button') + setNode('pasteArea', '#paste-area') setNode('customCooldown', '#custom-cooldown-button') - setNode('dumpButton', '#dump-button') - setNode('status', '[type=submit]') - setNode('flashTag', '[name=filetag]') - setNode('fileInput', '[type=file]') + setNode('dumpButton', '#dump-button') + setNode('status', '[type=submit]') + setNode('flashTag', '[name=filetag]') + setNode('fileInput', '[type=file]') - 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) - classList.toggle('has-math', !!config.math_tags) + 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) + classList.toggle('has-math', !!config.math_tags) classList.toggle('sjis-preview', !!config.sjis_tags && Conf['sjisPreview']) classList.toggle('show-new-thread-option', Conf['Show New Thread Option in Threads']) 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) }) @@ -695,29 +696,29 @@ var QR = { QR.flagsInput() - $.on(nodes.autohide, 'change', QR.toggleHide) - $.on(nodes.close, 'click', QR.close) - $.on(nodes.status, 'click', QR.submit) - $.on(nodes.form, 'submit', QR.submit) - $.on(nodes.sjisToggle, 'click', QR.toggleSJIS) - $.on(nodes.texButton, 'mousedown', QR.texPreviewShow) - $.on(nodes.texButton, 'mouseup', QR.texPreviewHide) - $.on(nodes.addPost, 'click', () => new QR.post(true)) - $.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.spoiler, 'change', () => QR.selected.nodes.spoiler.click()) - $.on(nodes.oekakiButton, 'click', QR.oekaki.button) - $.on(nodes.fileRM, 'click', () => QR.selected.rmFile()) - $.on(nodes.urlButton, 'click', () => QR.handleUrl('')) - $.on(nodes.customCooldown, 'click', QR.toggleCustomCooldown) - $.on(nodes.dumpButton, 'click', () => nodes.el.classList.toggle('dump')) - $.on(nodes.fileInput, 'change', QR.handleFiles) + $.on(nodes.autohide, 'change', QR.toggleHide) + $.on(nodes.close, 'click', QR.close) + $.on(nodes.status, 'click', QR.submit) + $.on(nodes.form, 'submit', QR.submit) + $.on(nodes.sjisToggle, 'click', QR.toggleSJIS) + $.on(nodes.texButton, 'mousedown', QR.texPreviewShow) + $.on(nodes.texButton, 'mouseup', QR.texPreviewHide) + $.on(nodes.addPost, 'click', () => new QR.post(true)) + $.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.spoiler, 'change', () => QR.selected.nodes.spoiler.click()) + $.on(nodes.oekakiButton, 'click', QR.oekaki.button) + $.on(nodes.fileRM, 'click', () => QR.selected.rmFile()) + $.on(nodes.urlButton, 'click', () => QR.handleUrl('')) + $.on(nodes.customCooldown, 'click', QR.toggleCustomCooldown) + $.on(nodes.dumpButton, 'click', () => nodes.el.classList.toggle('dump')) + $.on(nodes.fileInput, 'change', QR.handleFiles) window.addEventListener('focus', QR.focus, true) - window.addEventListener('blur', QR.focus, true) + window.addEventListener('blur', QR.focus, true) // We don't receive blur events from captcha iframe. $.on(d, 'click', QR.focus) @@ -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