Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

revisit header search, move add channel form to settings modal

Christian Feie8d4f8d09d2b
diff --git a/client/index.html b/client/index.html
index 4982e59..2d6227e 100644
--- a/client/index.html
+++ b/client/index.html
@@ -9,14 +9,7 @@
</head>
<body>
<header>
- <h1 class="m-0">My-YT</h1>
- <br>
- <form id="add-channel-form">
- <label for="channel-name">Add a new channel</label>
- <input type="text" id="channel-name" placeholder="Channel Name" required>
- <button type="submit">Submit</button>
- <span class="loader"></span>
- </form>
+ <h1 class="">My-YT</h1>
<input type="text" id="search" placeholder="Search videos" autofocus>
</header>
@@ -29,6 +22,14 @@
</div>
<br>
<br>
+ <form id="add-channel-form">
+ <label for="channel-name">Add a new channel</label>
+ <input type="text" id="channel-name" placeholder="Channel Name" required>
+ <button type="submit">Submit</button>
+ <span class="loader"></span>
+ </form>
+ <br>
+ <br>
<label for="show-thumbnails">
Show video thumbnails
</label>
diff --git a/client/main.css b/client/main.css
index e52c950..1d1da52 100644
--- a/client/main.css
+++ b/client/main.css
@@ -165,6 +165,15 @@ body.dialog-opened {
body > header {
padding: 1em 0.5em;
margin-bottom: 3rem;
+ overflow: hidden;
+}
+
+#search {
+ display: block;
+ margin: 0 auto;
+ width: 90%;
+ padding: 1em;
+ font-size: 1.1rem;
}
details {
@@ -191,4 +200,4 @@ details[open] > summary {
#summary pre {
white-space: break-spaces;
-}
\ No newline at end of file
+}
diff --git a/client/main.js b/client/main.js
index 485882e..52aa158 100644
--- a/client/main.js
+++ b/client/main.js
@@ -180,6 +180,23 @@ eventSource.onmessage = (message) => {
updateDownloadedVideos(allVideos)
window.videos = data.videos
}
+ if (data.type === 'channel' && data.name && data.videos) {
+ data.videos
+ .sort((a, b) => +new Date(b.publishedAt) - +new Date(a.publishedAt))
+ .forEach(video => {
+ const $video = document.querySelector(`[data-video-id="${video.id}"]`)
+ if ($video) {
+ $video.dataset['data'] = JSON.stringify(video)
+ console.log('video exists', video.id)
+ return
+ }
+ console.log('video does not exist. prepending', video.id)
+ $videosContainer.insertBefore(createVideoElement(video), $videosContainer.firstChild)
+ })
+
+ updateDownloadedVideos(data.videos)
+ window.videos[data.name] = data.videos
+ }
if (data.type === 'summary' && data.videoId && data.summary && data.transcript) {
const $video = document.querySelector(`[data-video-id="${data.videoId}"]`)
if ($video) {