Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

feat: search by multiple filters

Christian Fei9a4e13405e4c
diff --git a/client/components/search-videos.js b/client/components/search-videos.js
index 33db5d7..49fd799 100644
--- a/client/components/search-videos.js
+++ b/client/components/search-videos.js
@@ -40,24 +40,27 @@ class SearchVideos extends HTMLElement {
render () {
this.innerHTML = /* html */`
<input type="search" incremental="incremental" id="search" placeholder="🔍 Search videos or paste video url" autofocus>
- <div class="flex">
- <div class="flex-1">
- <label for="downloaded">downloaded</label>
- <input type="checkbox" id="downloaded"/>
+ <details>
+ <summary>Additional filters</summary>
+ <div class="flex " id="search-filters">
+ <div class="flex-1">
+ <label for="downloaded">downloaded</label>
+ <input type="checkbox" id="downloaded"/>
+ </div>
+ <div class="flex-1">
+ <label for="summarized">summarized</label>
+ <input type="checkbox" id="summarized"/>
+ </div>
+ <div class="flex-1">
+ <label for="ignored">ignored</label>
+ <input type="checkbox" id="ignored"/>
+ </div>
+ <div class="flex-1">
+ <label for="excluded">excluded</label>
+ <input type="checkbox" id="excluded"/>
+ </div>
</div>
- <div class="flex-1">
- <label for="summarized">summarized</label>
- <input type="checkbox" id="summarized"/>
- </div>
- <div class="flex-1">
- <label for="ignored">ignored</label>
- <input type="checkbox" id="ignored"/>
- </div>
- <div class="flex-1">
- <label for="excluded">excluded</label>
- <input type="checkbox" id="excluded"/>
- </div>
- </div>
+ </details>
`
}
@@ -91,15 +94,11 @@ class SearchVideos extends HTMLElement {
const summarized = this.querySelector('#summarized').checked
if (excluded) {
- this.querySelector('#downloaded').disabled = true
this.querySelector('#ignored').disabled = true
- this.querySelector('#summarized').disabled = true
} else {
- this.querySelector('#downloaded').disabled = false
this.querySelector('#ignored').disabled = false
- this.querySelector('#summarized').disabled = false
}
- if (downloaded || ignored || summarized) {
+ if (ignored) {
this.querySelector('#excluded').disabled = true
} else {
this.querySelector('#excluded').disabled = false
diff --git a/lib/repository.js b/lib/repository.js
index 529d528..3bf8464 100644
--- a/lib/repository.js
+++ b/lib/repository.js
@@ -77,7 +77,7 @@ export default class Repository {
}
filterByExcludedTerms (v, excludedTerms = this.getExcludedTerms()) {
- return v.downloaded || !excludedTerms.some(term => v.title?.toLowerCase().includes(term) || v.description?.toLowerCase().includes(term))
+ return !excludedTerms.some(term => v.title?.toLowerCase().includes(term.toLowerCase()) || v.description?.toLowerCase().includes(term.toLowerCase()))
}
getVideos (query = {}) {