mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 10:41:36 +00:00
Implement continuous mode
This commit is contained in:
parent
e4f6ffe122
commit
2b2f8bf84a
7 changed files with 130 additions and 14 deletions
34
html/static/js/continuous.js
Normal file
34
html/static/js/continuous.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import {q, ejs, ElemJS} from "/static/js/elemjs/elemjs.js"
|
||||
|
||||
const video = q("#video")
|
||||
|
||||
console.log
|
||||
|
||||
video.addEventListener("ended", () => {
|
||||
if (data.continuous) {
|
||||
const first = data.recommendedVideos[0]
|
||||
window.location.assign(`/watch?v=${first.videoId}&continuous=1`)
|
||||
}
|
||||
})
|
||||
|
||||
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"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue