1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-25 00:47:29 +00:00
cloudtube/html/static/js/continuous.js

34 lines
885 B
JavaScript
Raw Normal View History

2021-04-25 12:02:59 +00:00
import {q, ejs, ElemJS} from "/static/js/elemjs/elemjs.js"
const video = q("#video")
video.addEventListener("ended", () => {
if (data.continuous) {
const first = q("#continuous-first")
const url = first.querySelector(".title-link").href
location.assign(url)
2021-04-25 12:02:59 +00:00
}
})
class ContinuousControls extends ElemJS {
constructor() {
super(q("#continuous-controls"))
this.button = ejs(q("#continuous-stop"))
this.button.on("click", this.onClick.bind(this))
}
onClick(event) {
event.preventDefault()
this.element.style.display = "none"
data.continuous = false
q("#continuous-related-videos").remove()
q("#standard-related-videos").style.display = ""
const url = new URL(location)
url.searchParams.delete("continuous")
url.searchParams.delete("session-watched")
history.replaceState(null, "", url.toString())
}
}
new ContinuousControls(q("#continuous-stop"))