diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2012-12-21 22:07:45 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2012-12-21 22:07:45 +0100 |
commit | e745764fc55043f6107f68986f82845310537fee (patch) | |
tree | ca8923d2b98f304759afa5799eebd25f129165d2 /static | |
parent | 1134dc1efa6a4326424cf7b1271cb4465afb712d (diff) |
Added feedback and limits to searches.
Diffstat (limited to 'static')
-rw-r--r-- | static/index.html | 1 | ||||
-rw-r--r-- | static/init.js | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/static/index.html b/static/index.html index b320435..0fc0023 100644 --- a/static/index.html +++ b/static/index.html @@ -52,6 +52,7 @@ <input type="text" id="search_box" /> <span> <input type="button" id="search-add" value="Add selected" /> + <span id="search-info"></span> </span> <table class="track-table"> <thead> diff --git a/static/init.js b/static/init.js index 117e8d9..c4f6c2c 100644 --- a/static/init.js +++ b/static/init.js @@ -236,8 +236,17 @@ $(document).ready(function() { }); $('#search_box').keypress(function(event) { if(event.keyCode == 13) { + $('#search-results').empty(); + $('#search-results').append('<tr><td colspan="3"><img src="/static/icons/loading.gif" alt="Searching..." /> Searching...</td></tr>'); var val = $(this).val(); - $.get('/json/search?q=' + encodeURIComponent(val), set_tracks($('#search-results'), $('#search-add')), 'json'); + $.get('/json/search?q=' + encodeURIComponent(val), function(data) { + var s = 'Showing ' + data.results.length; + if(data.total > data.results.length) + s += ' of ' + data.total; + s += ' results.'; + $('#search-info').text(s); + set_tracks($('#search-results'), $('#search-add'))(data.results); + }, 'json'); } }); $('#search-add').click(function(event) { |