1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-12-22 05:06:57 +00:00

Seek videos without reloading the page on clicked timestamps

This commit is contained in:
Lomanic 2021-05-01 03:00:48 +02:00 committed by Cadence Ember
parent 81a4d10474
commit 7023d0287c
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -1,8 +1,9 @@
import {q, ElemJS} from "/static/js/elemjs/elemjs.js"
import {q, qa, ElemJS} from "/static/js/elemjs/elemjs.js"
import {SubscribeButton} from "/static/js/subscribe.js"
const video = q("#video")
const audio = q("#audio")
const timestamps = qa("a[data-clickable-timestamp]")
const videoFormats = new Map()
const audioFormats = new Map()
@ -221,3 +222,9 @@ document.addEventListener("keydown", event => {
})
new SubscribeButton(q("#subscribe"))
Array.from(timestamps).forEach(el => el.addEventListener('click', event => {
event.preventDefault()
video.currentTime = event.target.getAttribute("data-clickable-timestamp")
window.history.replaceState({}, "", event.target.href)
}))