mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 10:41:36 +00:00
Highlight current chapter in video description
This commit is contained in:
parent
eb111a44c4
commit
f62fce4fea
8 changed files with 86 additions and 4 deletions
24
html/static/js/modules/MarkWatchedButton.js
Normal file
24
html/static/js/modules/MarkWatchedButton.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import {ElemJS} from "/static/js/elemjs/elemjs.js"
|
||||
|
||||
class MarkWatchedButton extends ElemJS {
|
||||
constructor(element) {
|
||||
super(element)
|
||||
this.on("click", this.onClick.bind(this))
|
||||
}
|
||||
|
||||
onClick(event) {
|
||||
event.preventDefault()
|
||||
let video = this.element
|
||||
while (!video.classList.contains("subscriptions-video")) {
|
||||
video = video.parentElement
|
||||
}
|
||||
video.classList.add("video-list-item--watched")
|
||||
const form = this.element.parentElement
|
||||
fetch(form.getAttribute("action"), {method: "POST"})
|
||||
form.remove()
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
MarkWatchedButton
|
||||
}
|
||||
28
html/static/js/modules/SubscribeButton.js
Normal file
28
html/static/js/modules/SubscribeButton.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import {ElemJS} from "/static/js/elemjs/elemjs.js"
|
||||
|
||||
class SubscribeButton extends ElemJS {
|
||||
constructor(element) {
|
||||
super(element)
|
||||
this.subscribed = this.element.getAttribute("data-subscribed") === "1"
|
||||
this.ucid = this.element.getAttribute("data-ucid")
|
||||
this.on("click", this.onClick.bind(this))
|
||||
this.render()
|
||||
}
|
||||
|
||||
onClick(event) {
|
||||
event.preventDefault()
|
||||
this.subscribed = !this.subscribed
|
||||
const path = this.subscribed ? "subscribe" : "unsubscribe"
|
||||
fetch(`/formapi/${path}/${this.ucid}`, {method: "POST"})
|
||||
this.render()
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.subscribed) this.text("Subscribe")
|
||||
else this.text("Unsubscribe")
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
SubscribeButton
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue