From bdc23fb81218e38a983f40a0d4c614b2602ed7c5 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 19 Nov 2011 12:53:59 +0000 Subject: [PATCH] provide feedback to the user when a search or other playlist mod returns no results --- server/djrandom/frontend/static/css/style.css | 13 ++++++++++--- server/djrandom/frontend/static/js/djr/djr.js | 14 +++++++++++++- server/djrandom/frontend/static/js/djr/player.js | 5 +++++ server/djrandom/frontend/templates/index.html | 2 ++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/server/djrandom/frontend/static/css/style.css b/server/djrandom/frontend/static/css/style.css index 693a21c..5f9468f 100644 --- a/server/djrandom/frontend/static/css/style.css +++ b/server/djrandom/frontend/static/css/style.css @@ -38,13 +38,13 @@ body { } #queryField { - width:75%; + width: 75%; font-size: 1.1em; - border:1px solid red; + border: 1px solid red; } .buttonbox a { - font-size:0.8em; + font-size: 0.8em; cursor: pointer; } @@ -61,6 +61,13 @@ h1.title { margin-right: 40px; } +#searchWarnMsg { + display: none; + font-weight: bold; + padding: 8px; + font-size: 1.1em; +} + /* Song style */ .song .artist { diff --git a/server/djrandom/frontend/static/js/djr/djr.js b/server/djrandom/frontend/static/js/djr/djr.js index 3e7944c..8654e47 100644 --- a/server/djrandom/frontend/static/js/djr/djr.js +++ b/server/djrandom/frontend/static/js/djr/djr.js @@ -34,6 +34,9 @@ djr.init = function (userid) { djr.state.player.search(query_string); return false; }); + $('#searchWarnMsg').click(function() { + $(this).hide(); + }); // Add onclick hooks to the playlist controls. $('#playlistClearBtn').click(function() { @@ -214,7 +217,16 @@ djr.playerError = function(event) { } }; -// Utility functions. +// Show a search-related warning message. +djr.showSearchWarning = function(msg) { + $('#searchWarnMsg').text(msg).show('fast'); +}; + +djr.clearSearchWarning = function() { + $('#searchWarnMsg').hide(); +}; + +// Generate a random UUID. var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); djr.generateRandomId = function() { var uuid = [], chars = CHARS, i; diff --git a/server/djrandom/frontend/static/js/djr/player.js b/server/djrandom/frontend/static/js/djr/player.js index 9f9541e..254ca0f 100644 --- a/server/djrandom/frontend/static/js/djr/player.js +++ b/server/djrandom/frontend/static/js/djr/player.js @@ -102,6 +102,7 @@ djr.Player.prototype.search = function(query) { songs.push(item.sha1); }); if (songs.length == 0) { + djr.showSearchWarning('No results found.'); djr.debug('No results found.'); return; } @@ -224,9 +225,13 @@ djr.Player.prototype.moreLikeThis = function(sha1) { }; djr.Player.prototype.createChunk = function(songs, chunk_title) { + // Clear any pending error message. + djr.clearSearchWarning(); + // Create the new chunk, with unique songs. var chunk = this.playlist.createUniqueChunk(songs, chunk_title); if (!chunk) { + djr.showSearchWarning('All results already in playlist.'); djr.debug('All the results are already in the playlist'); return; } diff --git a/server/djrandom/frontend/templates/index.html b/server/djrandom/frontend/templates/index.html index e423cab..d5e1210 100644 --- a/server/djrandom/frontend/templates/index.html +++ b/server/djrandom/frontend/templates/index.html @@ -157,6 +157,8 @@ $(document).ready(function() { </form> </div> + <div id="searchWarnMsg"></div> + <div id="playlistButtons" class="buttonbox"> <a id="playlistLast5">Last 5</a> <a id="playlistLast25">(25)</a> | <a id="playlistRandom5">Random 5</a> <a id="playlistRandom25">(25)</a> -- GitLab