]> git.sesse.net Git - vlc/blobdiff - share/http/js/functions.js
Fix commit.
[vlc] / share / http / js / functions.js
index 9dbf7d95e54fcb523667310236d7e6d9d4794f0e..fcd6c7a1677b9b7879ef6964be5802b9277c4dbe 100644 (file)
@@ -27,6 +27,7 @@
 
 var old_time = 0;
 var pl_cur_id;
+var albumart_id = -1;
 
 /**********************************************************************
  * Slider functions
@@ -287,7 +288,7 @@ function in_play()
     var input = value('input_mrl');
     if( value('sout_mrl') != '' )
         input += ' '+value('sout_mrl');
-    var url = 'requests/status.xml?command=in_play&input='+escape( input );
+    var url = 'requests/status.xml?command=in_play&input='+encodeURIComponent( addslashes(escapebackslashes(input)) );
     loadXMLDoc( url, parse_status );
     setTimeout( 'update_playlist()', 1000 );
 }
@@ -296,7 +297,7 @@ function in_enqueue()
     var input = value('input_mrl');
     if( value('sout_mrl') != '' )
         input += ' '+value('sout_mrl');
-    var url = 'requests/status.xml?command=in_enqueue&input='+escape( input );
+    var url = 'requests/status.xml?command=in_enqueue&input='+encodeURIComponent( addslashes(escapebackslashes(input)) );
     loadXMLDoc( url, parse_status );
     setTimeout( 'update_playlist()', 1000 );
 }
@@ -377,6 +378,15 @@ function fullscreen()
 {
     loadXMLDoc( 'requests/status.xml?command=fullscreen', parse_status );
 }
+function snapshot()
+{
+    loadXMLDoc( 'requests/status.xml?command=snapshot', parse_status );
+}
+function hotkey( str )
+{
+    /* Use hotkey name (without the "key-" part) as the argument to simulate a hotkey press */
+    loadXMLDoc( 'requests/status.xml?command=key&val='+str, parse_status );
+}
 function update_status()
 {
     loadXMLDoc( 'requests/status.xml', parse_status );
@@ -620,6 +630,7 @@ function parse_playlist()
                     {
                         elt = elt.parentNode;
                         if( ! elt.parentNode ) break;
+                        pos = pos.parentNode;
                     }
                     if( ! elt.parentNode ) break;
                     elt = elt.parentNode.nextSibling;
@@ -810,7 +821,7 @@ function update_input_fake()
 {
     var mrl = document.getElementById( 'input_mrl' );
 
-    mrl.value = "fake:";
+    mrl.value = "fake://";
     mrl.value += " :fake-file=" + value( "input_fake_filename" );
 
     if( value( "input_fake_width" ) )
@@ -1022,7 +1033,7 @@ function browse( dest )
 function browse_dir( dir )
 {
     document.getElementById( 'browse_lastdir' ).value = dir;
-    loadXMLDoc( 'requests/browse.xml?dir='+escape(dir), parse_browse_dir );
+    loadXMLDoc( 'requests/browse.xml?dir='+encodeURIComponent(dir), parse_browse_dir );
 }
 function browse_path( p )
 {
@@ -1030,7 +1041,16 @@ function browse_path( p )
     hide( 'browse' );
     document.getElementById( value( 'browse_dest' ) ).focus();
 }
-
+function refresh_albumart( force )
+{
+    if( albumart_id != pl_cur_id || force )
+    {
+        var now = new Date();
+        var albumart = document.getElementById( 'albumart' );
+        albumart.src = '/art?timestamp=' + now.getTime();
+        albumart_id = pl_cur_id;
+    }
+}
 /**********************************************************************
  * Periodically update stuff in the interface
  *********************************************************************/
@@ -1044,9 +1064,15 @@ function loop_refresh_playlist()
     /* setTimeout( 'loop_refresh_playlist()', 10000 ); */
     update_playlist();
 }
+function loop_refresh_albumart()
+{
+    setTimeout( 'loop_refresh_albumart()', 1000 );
+    refresh_albumart( false );
+}
 function loop_refresh()
 {
     setTimeout( 'loop_refresh_status()', 1 );
     setTimeout( 'loop_refresh_playlist()', 1 );
+    setTimeout( 'loop_refresh_albumart()', 1 );
 }