Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

fix: single video filter can be applied

Christian Fei4e0c0751f3a7
diff --git a/client/components/video-filters.js b/client/components/video-filters.js
index caef93a..d9d6e3e 100644
--- a/client/components/video-filters.js
+++ b/client/components/video-filters.js
@@ -10,20 +10,14 @@ class VideoFilters extends HTMLElement {
this.deregisterEvents()
}
registerEvents () {
- const $showDownloadedVideos = this.querySelector('#show-downloaded-videos')
- const $showSummarizedVideos = this.querySelector('#show-summarized-videos')
- const $showIgnoredVideos = this.querySelector('#show-ignored-videos')
- $showDownloadedVideos.addEventListener('click', this.handleDownloadedVideos.bind(this))
- $showSummarizedVideos.addEventListener('click', this.handleSummarizedVideos.bind(this))
- $showIgnoredVideos.addEventListener('click', this.handleIgnoredVideos.bind(this))
+ this.querySelector('#show-downloaded-videos').addEventListener('click', this.handleDownloadedVideos.bind(this))
+ this.querySelector('#show-summarized-videos').addEventListener('click', this.handleSummarizedVideos.bind(this))
+ this.querySelector('#show-ignored-videos').addEventListener('click', this.handleIgnoredVideos.bind(this))
}
deregisterEvents () {
- const $showDownloadedVideos = this.querySelector('#show-downloaded-videos')
- const $showSummarizedVideos = this.querySelector('#show-summarized-videos')
- const $showIgnoredVideos = this.querySelector('#show-ignored-videos')
- $showDownloadedVideos.removeEventListener('click', this.handleDownloadedVideos.bind(this))
- $showSummarizedVideos.removeEventListener('click', this.handleSummarizedVideos.bind(this))
- $showIgnoredVideos.removeEventListener('click', this.handleIgnoredVideos.bind(this))
+ this.querySelector('#show-downloaded-videos').removeEventListener('click', this.handleDownloadedVideos.bind(this))
+ this.querySelector('#show-summarized-videos').removeEventListener('click', this.handleSummarizedVideos.bind(this))
+ this.querySelector('#show-ignored-videos').removeEventListener('click', this.handleIgnoredVideos.bind(this))
}
render () {
this.innerHTML = /*html*/`
@@ -35,16 +29,25 @@ class VideoFilters extends HTMLElement {
`
}
handleDownloadedVideos(event) {
+ this.reset()
event.target.classList.toggle('active')
document.body.classList.toggle('show-downloaded-videos')
}
handleSummarizedVideos(event) {
+ this.reset()
event.target.classList.toggle('active')
document.body.classList.toggle('show-summarized-videos')
}
handleIgnoredVideos(event) {
+ this.reset()
event.target.classList.toggle('active')
document.body.classList.toggle('show-ignored-videos')
}
+ reset() {
+ this.querySelectorAll('button').forEach(button => button.classList.remove('active'))
+ document.body.classList.remove('show-downloaded-videos')
+ document.body.classList.remove('show-summarized-videos')
+ document.body.classList.remove('show-ignored-videos')
+ }
}
customElements.define('video-filters', VideoFilters)