]> git.sesse.net Git - vlc/commitdiff
WebUI: Update Playlist improvement
authorMark Hassman <mark@hassman.org>
Sat, 4 Aug 2012 23:32:30 +0000 (19:32 -0400)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 5 Aug 2012 15:47:22 +0000 (17:47 +0200)
Close #5583

Playlist is cached/updated locally within browser instead of
refreshing after each function call.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
share/lua/http/index.html
share/lua/http/js/controlers.js

index 60ff53283fdb25eb030d9c9517fedbec97c8d28a..258ed2bf2cb0f199d18801219f94e47c1b2dfa9e 100644 (file)
                                        sendCommand({'command':'pl_random'});
                                        return false;
                                })
-                               $('#buttonRefresh').click(updatePlayList);
+                               $('#buttonRefresh').click(function(){
+                                   updatePlayList(true);
+                                   return false;
+                               });
                                $('#buttonPlPlay').click(function(){
                                        sendCommand({
                                                'command': 'pl_play',
index ab59bcf58f0d4730f203925ffc23dce326148c3d..9233683d2e63c27afdb6a5502ff2f73c8ce2d1b8 100644 (file)
@@ -1,6 +1,8 @@
 var current_id = 1;
 var currentArt = null;
 var current_que = 'main';
+var previous_title = null;
+var current_title = null;
 
 function updateArt(url) {
     $('#albumArt').fadeOut(500, function () {
@@ -72,6 +74,13 @@ function updateStatus() {
                     currentArt = 'images/vlc-48.png';
                     updateArt(currentArt);
                 }
+
+                current_title = $('[name="filename"]', data).text();
+                if (previous_title != current_title) {
+                    updatePlayList();
+                }
+                previous_title = current_title;
+
                 if (pollStatus) {
                     setTimeout(updateStatus, 1000);
                 }
@@ -119,8 +128,30 @@ function updateStatus() {
     });
 }
 
-function updatePlayList() {
-    $('#libraryTree').jstree('refresh', -1);
+function updatePlayList(force_refresh) {
+    if (force_refresh) {
+        //refresh playlist..
+        $('#libraryTree').jstree('refresh', -1);
+    } else {
+        //iterate through playlist..
+        $('.jstree-leaf').each(function(){
+            var id = $(this).attr('id');
+            if (id != null && id.substr(0,5) == 'plid_') {
+                var name = $(this).attr('name');
+                if (name != null && name == current_title) {
+                    $(this).addClass('ui-state-highlight');
+                    $(this).attr('current', 'current');
+                    this.scrollIntoView(true);
+                } else {
+                    $(this).removeClass('ui-state-highlight');
+                    $(this).removeAttr('current');
+                }
+                if ($(this).children('a').size() > 0) {
+                    $($(this).children('a')[0]).removeClass('ui-state-active');
+                }
+            }
+       });
+    }
 }
 
 function sendCommand(params, append) {
@@ -133,7 +164,6 @@ function sendCommand(params, append) {
                     eval(append);
                 }
                 updateStatus();
-                updatePlayList();
             }
         });
     } else {
@@ -155,7 +185,6 @@ function sendCommand(params, append) {
                     if (append != undefined) {
                         eval(append);
                     }
-                    updatePlayList();
                 }
             });
         }
@@ -490,7 +519,6 @@ $(function () {
         event.preventDefault();
         current_id = $(this).parent().attr('id').substr(5);
         sendCommand('command=pl_play&id=' + current_id);
-        updatePlayList();
     });
     updateStatus();
     updateStreams();