Просмотр исходного кода

marked current video in each playlist

Brandon Wong 1 год назад
Родитель
Сommit
39a108c522
4 измененных файлов с 599 добавлено и 1 удалено
  1. 561 0
      2025-04-18-12-claude-mark-current-video.md
  2. 7 0
      popup/popup.css
  3. 7 1
      popup/popup.html
  4. 24 0
      popup/popup.js

Разница между файлами не показана из-за своего большого размера
+ 561 - 0
2025-04-18-12-claude-mark-current-video.md


+ 7 - 0
popup/popup.css

@@ -96,4 +96,11 @@ button:hover, a.play-btn:hover {
     color: #888;
     font-style: italic;
     font-size: 14px;
+}
+
+.current-video {
+    background-color: #e3f2fd;
+    border-left: 3px solid #4285f4;
+    padding-left: 8px;
+    font-weight: bold;
 }

+ 7 - 1
popup/popup.html

@@ -23,7 +23,13 @@
             <h2 x-text="playlistName"></h2>
             <div class="video-list">
               <template x-for="(video, index) in videos" :key="index">
-                <div class="video-item" :title="video.title">
+                <div
+                  class="video-item"
+                  :title="video.title"
+                  :data-playlist-name="playlistName"
+                  :data-playlist-index="index"
+                  x-bind="videoItemClass"
+                >
                   <span
                     class="video-title"
                     x-text="video.title"

+ 24 - 0
popup/popup.js

@@ -171,6 +171,30 @@ document.addEventListener("alpine:init", () => {
       },
     },
 
+    isCurrentVideo(playlistName, index) {
+      const playlist = this.playlists[playlistName];
+      if (!playlist || !Array.isArray(playlist)) return false;
+
+      // Find the index of the first video that is not "done"
+      const currentIndex = playlist.findIndex(
+        (video) => video.status !== "done",
+      );
+
+      // If no "current" video found (all are done) or current index doesn't match, return false
+      return currentIndex === index && currentIndex !== -1;
+    },
+
+    videoItemClass: {
+      [":class"]() {
+        return {
+          "current-video": this.isCurrentVideo(
+            this.$el.dataset.playlistName,
+            parseInt(this.$el.dataset.playlistIndex),
+          ),
+        };
+      },
+    },
+
     removeVideoButton: {
       ["@click"]() {
         this.removeVideo(