From ee9cedc7ce3c868e14588d97df63d486ec282b79 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Tue, 13 Nov 2007 21:08:37 +0000 Subject: [PATCH] Add "search as you type" to the HTTP interface. --- share/http-lua/dialogs/playlist | 9 +++++++++ share/http-lua/images/reset.png | Bin 0 -> 215 bytes share/http-lua/js/functions.js | 15 ++++++++++++++- share/http-lua/requests/playlist.xml | 14 +++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 share/http-lua/images/reset.png 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 0000000000000000000000000000000000000000..b9f3834154be0f20c31c858fb36e4d91157e9a3d GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg?ZeB4q!6XrLU!YL9r;B5V#p$)d zmP`x^99;kZr_ZuhStH}i!4+Mtqf)!;vw*{Ep4p5XN4Y&`Obd!G{IKRpaaaSB#O9_` zXQR2p6I>lWC$ck%9SE^3*e`ObX>R-az * @@ -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) ?> -- 2.39.5