mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-22 07:37:29 +00:00
Change JS timestamp clicks to be object oriented
This commit is contained in:
parent
c811a4aaf9
commit
7caa4fb435
@ -3,7 +3,6 @@ import {SubscribeButton} from "/static/js/subscribe.js"
|
|||||||
|
|
||||||
const video = q("#video")
|
const video = q("#video")
|
||||||
const audio = q("#audio")
|
const audio = q("#audio")
|
||||||
const timestamps = qa("a[data-clickable-timestamp]")
|
|
||||||
|
|
||||||
const videoFormats = new Map()
|
const videoFormats = new Map()
|
||||||
const audioFormats = new Map()
|
const audioFormats = new Map()
|
||||||
@ -223,8 +222,21 @@ document.addEventListener("keydown", event => {
|
|||||||
|
|
||||||
new SubscribeButton(q("#subscribe"))
|
new SubscribeButton(q("#subscribe"))
|
||||||
|
|
||||||
Array.from(timestamps).forEach(el => el.addEventListener('click', event => {
|
const timestamps = qa("[data-clickable-timestamp]")
|
||||||
event.preventDefault()
|
|
||||||
video.currentTime = event.target.getAttribute("data-clickable-timestamp")
|
class Timestamp extends ElemJS {
|
||||||
window.history.replaceState({}, "", event.target.href)
|
constructor(element) {
|
||||||
}))
|
super(element)
|
||||||
|
this.on("click", this.onClick.bind(this))
|
||||||
|
}
|
||||||
|
|
||||||
|
onClick(event) {
|
||||||
|
event.preventDefault()
|
||||||
|
video.currentTime = event.target.getAttribute("data-clickable-timestamp")
|
||||||
|
window.history.replaceState(null, "", event.target.href)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamps.forEach(el => {
|
||||||
|
new Timestamp(el)
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user