Add "search as you type" to the HTTP interface.

This commit is contained in:
Antoine Cellerier 2007-11-13 21:08:37 +00:00
parent 9f8aa0ff1f
commit ee9cedc7ce
4 changed files with 36 additions and 2 deletions

View 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

View 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

View 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)
?>