mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2026-03-20 01:37:47 +01:00
QR types and bug fixes
This commit is contained in:
parent
d8d36ef5dc
commit
8468e225a8
@ -1,11 +1,7 @@
|
|||||||
import { d } from "../globals/globals"
|
import { d } from "../globals/globals"
|
||||||
import $ from "../platform/$"
|
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 PostRedirect = {
|
const PostRedirect = {
|
||||||
init() {
|
init() {
|
||||||
return $.on(d, 'QRPostSuccessful', e => {
|
return $.on(d, 'QRPostSuccessful', e => {
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import QuickReplyPage from './QR/QuickReply.html'
|
|||||||
|
|
||||||
|
|
||||||
const QR = {
|
const QR = {
|
||||||
|
selected: null,
|
||||||
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'],
|
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,
|
validExtension: /\.(jpe?g|png|gif|pdf|swf|webm)$/i,
|
||||||
@ -258,9 +259,10 @@ const QR = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
blur() {
|
blur() {
|
||||||
if (QR.nodes.el.contains(d.activeElement)) { return d.activeElement.blur() }
|
if (QR.nodes.el.contains(d.activeElement) && d.activeElement instanceof HTMLElement) {
|
||||||
|
d.activeElement.blur()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleSJIS(e) {
|
toggleSJIS(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
Conf['sjisPreview'] = !Conf['sjisPreview']
|
Conf['sjisPreview'] = !Conf['sjisPreview']
|
||||||
@ -382,7 +384,7 @@ const QR = {
|
|||||||
QR.open()
|
QR.open()
|
||||||
if (QR.selected.isLocked) {
|
if (QR.selected.isLocked) {
|
||||||
const index = QR.posts.indexOf(QR.selected);
|
const index = QR.posts.indexOf(QR.selected);
|
||||||
(QR.posts[index + 1] || new QR.post()).select()
|
(QR.posts[index + 1] || new QR.post(QR.selected)).select()
|
||||||
$.addClass(QR.nodes.el, 'dump')
|
$.addClass(QR.nodes.el, 'dump')
|
||||||
return QR.cooldown.auto = true
|
return QR.cooldown.auto = true
|
||||||
}
|
}
|
||||||
@ -542,7 +544,7 @@ const QR = {
|
|||||||
if (file) {
|
if (file) {
|
||||||
const { type } = file
|
const { type } = file
|
||||||
const blob = new Blob([file], { type })
|
const blob = new Blob([file], { type })
|
||||||
blob.name = `${Conf['pastedname']}.${$.getOwn(QR.extensionFromType, type) || 'jpg'}`
|
file.name = blob.name
|
||||||
QR.open()
|
QR.open()
|
||||||
QR.handleFiles([blob])
|
QR.handleFiles([blob])
|
||||||
$.addClass(QR.nodes.el, 'dump')
|
$.addClass(QR.nodes.el, 'dump')
|
||||||
@ -613,7 +615,7 @@ const QR = {
|
|||||||
} else {
|
} else {
|
||||||
post = QR.posts[QR.posts.length - 1]
|
post = QR.posts[QR.posts.length - 1]
|
||||||
if (isText ? post.com || post.pasting : post.file) {
|
if (isText ? post.com || post.pasting : post.file) {
|
||||||
post = new QR.post()
|
post = new QR.post(QR.selected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return post[isText ? 'pasteText' : 'setFile'](file)
|
return post[isText ? 'pasteText' : 'setFile'](file)
|
||||||
@ -1048,7 +1050,7 @@ const QR = {
|
|||||||
|
|
||||||
const h1 = $('h1', this.response)
|
const h1 = $('h1', this.response)
|
||||||
|
|
||||||
let [_, threadID, postID] = Array.from(h1.nextSibling.textContent.match(/thread:(\d+),no:(\d+)/))
|
let [threadID, postID] = Array.from(h1.nextSibling.textContent.match(/thread:(\d+),no:(\d+)/))
|
||||||
postID = +postID
|
postID = +postID
|
||||||
threadID = +threadID || postID
|
threadID = +threadID || postID
|
||||||
const isReply = threadID !== postID
|
const isReply = threadID !== postID
|
||||||
@ -1567,10 +1569,11 @@ const QR = {
|
|||||||
bgColor: 'transparent'
|
bgColor: 'transparent'
|
||||||
})
|
})
|
||||||
const canvas = document.createElement('canvas')
|
const canvas = document.createElement('canvas')
|
||||||
canvas.width = (canvas.naturalWidth = +selected.dataset.width)
|
canvas.width = +selected.dataset.width
|
||||||
canvas.height = (canvas.naturalHeight = +selected.dataset.height)
|
canvas.height = +selected.dataset.height
|
||||||
canvas.hidden = true
|
canvas.hidden = true
|
||||||
document.body.appendChild(canvas)
|
document.body.appendChild(canvas)
|
||||||
|
|
||||||
canvas.addEventListener('QRImageDrawn', function () {
|
canvas.addEventListener('QRImageDrawn', function () {
|
||||||
this.remove()
|
this.remove()
|
||||||
return Tegaki.onOpenImageLoaded.call(this)
|
return Tegaki.onOpenImageLoaded.call(this)
|
||||||
@ -1696,6 +1699,7 @@ const QR = {
|
|||||||
filename: string
|
filename: string
|
||||||
pasting: boolean
|
pasting: boolean
|
||||||
URL: string
|
URL: string
|
||||||
|
file: File
|
||||||
constructor(select) {
|
constructor(select) {
|
||||||
this.select = this.select.bind(this)
|
this.select = this.select.bind(this)
|
||||||
const el = $.el('a', {
|
const el = $.el('a', {
|
||||||
@ -1823,7 +1827,7 @@ const QR = {
|
|||||||
// Scroll the list to center the focused post.
|
// Scroll the list to center the focused post.
|
||||||
const rectEl = this.nodes.el.getBoundingClientRect()
|
const rectEl = this.nodes.el.getBoundingClientRect()
|
||||||
const rectList = this.nodes.el.parentNode.getBoundingClientRect()
|
const rectList = this.nodes.el.parentNode.getBoundingClientRect()
|
||||||
this.nodes.el.parentNode.scrollLeft += (rectEl.left + (rectEl.width / 2)) - rectList.left - (rectList.width / 2)
|
this.nodes.el.scrollLeft += (rectEl.left + (rectEl.width / 2)) - rectList.left - (rectList.width / 2)
|
||||||
return this.load()
|
return this.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user