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 videos, clear status text wip

Christian Fei4d39f0699434
diff --git a/client/components/search-videos.js b/client/components/search-videos.js
index 9435e6f..26a8360 100644
--- a/client/components/search-videos.js
+++ b/client/components/search-videos.js
@@ -2,6 +2,7 @@
class SearchVideos extends HTMLElement {
constructor () {
super()
+ this.previousSearchTerm = ''
}
connectedCallback () {
this.render()
@@ -24,6 +25,9 @@ class SearchVideos extends HTMLElement {
searchHandler (event) {
event.preventDefault()
let searchTerm = event.target.value.trim()
+ if (this.previousSearchTerm === searchTerm) return
+ this.previousSearchTerm = searchTerm
+
const $status = document.querySelector('#filter-results-status')
$status.innerText = ''
@@ -52,9 +56,12 @@ class SearchVideos extends HTMLElement {
videos.forEach(video =>
$videosContainer.appendChild(window.createVideoElement(video, showOriginalThumbnail))
)
-
- if (videos.length > 0) $status.innerText = `Found ${videos.length} videos`
- else $status.innerText = `No videos found`
+ if (!searchTerm) {
+ $status.innerText = ''
+ } else {
+ if (videos.length > 0) $status.innerText = `Found ${videos.length} videos`
+ else $status.innerText = `No videos found`
+ }
})
.catch(err => {
console.error(err)
diff --git a/client/components/video-element.js b/client/components/video-element.js
index 961fba2..2b5dd2c 100644
--- a/client/components/video-element.js
+++ b/client/components/video-element.js
@@ -44,7 +44,7 @@ class VideoElement extends HTMLElement {
${this.video.downloaded
? /*html*/`<div class="play video-placeholder" style="background-image: url(${this.video.thumbnail})"><div class="play-icon"></div></div>`
: /*html*/`<img title="Download video" class="download" loading="lazy" src="${this.video.thumbnail}"/>`}
- <span class="action ignore" tabindex="0">ignore</span>
+ <span class="action ignore" tabindex="0">${this.video.ignored ? 'unignore' : 'ignore'}</span>
<div class="info">
<span class="channel-name">${this.video.channelName}</span>
<br>