]> git.sesse.net Git - vlc/commitdiff
Add "search as you type" to the HTTP interface.
authorAntoine Cellerier <dionoea@videolan.org>
Tue, 13 Nov 2007 21:08:37 +0000 (21:08 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Tue, 13 Nov 2007 21:08:37 +0000 (21:08 +0000)
share/http-lua/dialogs/playlist
share/http-lua/images/reset.png [new file with mode: 0644]
share/http-lua/js/functions.js
share/http-lua/requests/playlist.xml

index 03d16116ec6cef13dbb11919f02bddddce4fabb1..cf3f58a2d0b17155a162efdf8ca21c353bcb3ccb 100644 (file)
@@ -88,6 +88,15 @@ This dialog needs the following dialogs to be fully functional: <none>
           ?>
           </div>
         </td>
+       <td style='width: 30px'></td>
+        <td>
+          <span class="btn_text">Live search:</span>
+          <input title="Live search" type="text" value="<?vlc if _G.search_key then print(search_key) else print('<search>') end ?>" id="search" onfocus="if( this.value == '<search>' ) this.value = ''" onblur="if( this.value == '' ) reset_search()" onchange="update_playlist_search(this.value)" onkeyup="update_playlist_search(this.value)" />
+          <button id="btn_search_reset" onclick="reset_search()" onmouseover="button_over(this);" onmouseout="button_out(this);" title="Reset search">
+            <img src="images/reset.png" alt="Reset" />
+            <span class="btn_text">Reset</span>
+          </button>
+        </td>
       </tr>
     </table>
   </div>
diff --git a/share/http-lua/images/reset.png b/share/http-lua/images/reset.png
new file mode 100644 (file)
index 0000000..b9f3834
Binary files /dev/null and b/share/http-lua/images/reset.png differ
index 1a141d4147b859b65bbf89da5358472176cf0cd1..fc2e1227ab08dbd7574234b971b3987b504e5601 100644 (file)
@@ -2,7 +2,7 @@
  * functions.js: VLC media player web interface
  *****************************************************************************
  * Copyright (C) 2005-2006 the VideoLAN team
- * $Id$
+ * $Id: functions.js 21264 2007-08-19 17:48:28Z dionoea $
  *
  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
  *
@@ -395,6 +395,19 @@ function update_playlist()
 {
     loadXMLDoc( 'requests/playlist.xml', parse_playlist );
 }
+function update_playlist_search(key)
+{
+    loadXMLDoc( 'requests/playlist.xml?search='+encodeURIComponent(key), parse_playlist )
+}
+function reset_search()
+{
+    var search = document.getElementById('search')
+    if( search )
+    {
+        search.value = '<search>'
+        update_playlist_search('')
+    }
+}
 
 /**********************************************************************
  * Parse xml replies to XMLHttpRequests
index 463f5d345a8cbf96de57f4864b7ea68b25dba28e..13541993bce479ffd0f956f44ba11da7063b9800 100644 (file)
@@ -28,6 +28,7 @@ vim:syntax=lua
 <?vlc
 --[[<node id="0" name="Undefined" ro="ro">]]
 function print_playlist(item)
+  if item.flags.disabled then return end
   if item.children then
     local name = vlc.convert_xml_special_chars(item.name)
     print("<node id=\""..tostring(item.id).."\" name=\""..name.."\" ro=\""..(item.flags.ro and "ro" or "rw").."\">")
@@ -56,7 +57,18 @@ for cat,pl in pairs(p) do
   print("</node>")
 end
 --]]
-local p = vlc.playlist.get()
+local p
+if _GET["search"] then
+  if _GET["search"] ~= "" then
+    _G.search_key = _GET["search"]
+  else
+    _G.search_key = nil
+  end
+  local key = vlc.decode_uri(_GET["search"])
+  p = vlc.playlist.search(key)
+else
+  p = vlc.playlist.get()
+end
 -- a(p) Uncomment to debug
 print_playlist(p)
 ?>