webm exclusion & topmost div defaults to hidden
This commit is contained in:
parent
41b5471ac1
commit
fbff3b4014
@ -10,6 +10,7 @@
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
// https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
||||||
// Decrease frame size, increase frame size, previous image, next image, toggle frame visibility, go to the source hash
|
// Decrease frame size, increase frame size, previous image, next image, toggle frame visibility, go to the source hash
|
||||||
const keybindings = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Escape", "Tab"]
|
const keybindings = ["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Escape", "Tab"]
|
||||||
|
const excludeWebm = true
|
||||||
|
|
||||||
const dragElement = (elem) => {
|
const dragElement = (elem) => {
|
||||||
const handler = (e) => {
|
const handler = (e) => {
|
||||||
@ -121,9 +122,10 @@ const keyDownEvent = async (e) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createElements = () => {
|
||||||
const limitElem = document.getElementsByClassName("boardBanner")[0]
|
const limitElem = document.getElementsByClassName("boardBanner")[0]
|
||||||
const newNode = document.createElement("div")
|
const newNode = document.createElement("div")
|
||||||
newNode.innerHTML = `<div id="drGallery">
|
newNode.innerHTML = `<div hidden id="drGallery">
|
||||||
<div id="drHeader" class="drag drDrag">Gallery</div>
|
<div id="drHeader" class="drag drDrag">Gallery</div>
|
||||||
<div id="drContainer"><img id="drImg" src="" alt="" /></div>
|
<div id="drContainer"><img id="drImg" src="" alt="" /></div>
|
||||||
</div>`
|
</div>`
|
||||||
@ -173,8 +175,9 @@ stylesheet.innerText = `#drGallery {
|
|||||||
|
|
||||||
document.head.appendChild(stylesheet)
|
document.head.appendChild(stylesheet)
|
||||||
document.body.insertBefore(newNode, limitElem)
|
document.body.insertBefore(newNode, limitElem)
|
||||||
|
}
|
||||||
|
|
||||||
let i = 0
|
const collectSources = () => {
|
||||||
let sources = []
|
let sources = []
|
||||||
let parentHashes = []
|
let parentHashes = []
|
||||||
|
|
||||||
@ -182,13 +185,25 @@ const fileDivs = document.getElementsByClassName("fileThumb")
|
|||||||
const hashPrefix = document.getElementsByClassName("postNum")[0].children[0].hash.slice(0, 3)
|
const hashPrefix = document.getElementsByClassName("postNum")[0].children[0].hash.slice(0, 3)
|
||||||
|
|
||||||
for (let e of fileDivs) {
|
for (let e of fileDivs) {
|
||||||
// TODO: webm & gif exclusion
|
const s = e.href.split(".")
|
||||||
|
const filetype = s[s.length - 1]
|
||||||
|
|
||||||
|
if (excludeWebm && filetype === "webm") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// div's id to post's hash (prefix x): fT12345678 => #px12345678
|
// div's id to post's hash (prefix x): fT12345678 => #px12345678
|
||||||
parentHashes.push(hashPrefix + e.parentElement.id.slice(2))
|
parentHashes.push(hashPrefix + e.parentElement.id.slice(2))
|
||||||
sources.push(e.href)
|
sources.push(e.href)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return [sources, parentHashes]
|
||||||
|
}
|
||||||
|
|
||||||
|
createElements()
|
||||||
|
|
||||||
|
let i = 0
|
||||||
|
const [sources, parentHashes] = collectSources()
|
||||||
const galleryElem = document.getElementById("drImg")
|
const galleryElem = document.getElementById("drImg")
|
||||||
document.addEventListener("keyup", keyDownEvent, false)
|
document.addEventListener("keyup", keyDownEvent, false)
|
||||||
dragElement(document.getElementById("drGallery"))
|
dragElement(document.getElementById("drGallery"))
|
||||||
|
Loading…
Reference in New Issue
Block a user