From: Antoine Cellerier Date: Tue, 13 Nov 2007 21:08:37 +0000 (+0000) Subject: Add "search as you type" to the HTTP interface. X-Git-Tag: 0.9.0-test0~4601 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ee9cedc7ce3c868e14588d97df63d486ec282b79;p=vlc Add "search as you type" to the HTTP interface. --- diff --git a/share/http-lua/dialogs/playlist b/share/http-lua/dialogs/playlist index 03d16116ec..cf3f58a2d0 100644 --- a/share/http-lua/dialogs/playlist +++ b/share/http-lua/dialogs/playlist @@ -88,6 +88,15 @@ This dialog needs the following dialogs to be fully functional: ?> + + + Live search: + + + diff --git a/share/http-lua/images/reset.png b/share/http-lua/images/reset.png new file mode 100644 index 0000000000..b9f3834154 Binary files /dev/null and b/share/http-lua/images/reset.png differ diff --git a/share/http-lua/js/functions.js b/share/http-lua/js/functions.js index 1a141d4147..fc2e1227ab 100644 --- a/share/http-lua/js/functions.js +++ b/share/http-lua/js/functions.js @@ -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 * @@ -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 = '' + update_playlist_search('') + } +} /********************************************************************** * Parse xml replies to XMLHttpRequests diff --git a/share/http-lua/requests/playlist.xml b/share/http-lua/requests/playlist.xml index 463f5d345a..13541993bc 100644 --- a/share/http-lua/requests/playlist.xml +++ b/share/http-lua/requests/playlist.xml @@ -28,6 +28,7 @@ vim:syntax=lua ]] 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("") @@ -56,7 +57,18 @@ for cat,pl in pairs(p) do print("") 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) ?>