1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-22 23:57:30 +00:00
cloudtube/html/static/js/continuous.js
2021-05-11 22:00:10 +12:00

34 lines
885 B
JavaScript

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)
}
})
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"))