mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
Add "mark watched" button to subscriptions page
This commit is contained in:
parent
27435cc3b5
commit
ac28332ac0
7 changed files with 83 additions and 18 deletions
24
html/static/js/mark-watched.js
Normal file
24
html/static/js/mark-watched.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
|
||||
}
|
||||
6
html/static/js/subscriptions.js
Normal file
6
html/static/js/subscriptions.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import {qa} from "/static/js/elemjs/elemjs.js"
|
||||
import {MarkWatchedButton} from "/static/js/mark-watched.js"
|
||||
|
||||
for (const button of qa(".mark-watched__button")) {
|
||||
new MarkWatchedButton(button)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue