diff --git a/server/djrandom/frontend/static/css/style.css b/server/djrandom/frontend/static/css/style.css index 693a21ce477b4cfb1a72ebdc19918171bd8b45d3..5f9468fbbc214ab98c11824720af09e3de1b3f5f 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 3e7944c3870391b20a43696be47eccc374fbdbe1..8654e476b36e385afe84c9936bc2d13d00aa7464 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 9f9541eed6d9b12efc4c5ecc5af1f089a9088c09..254ca0f3b545901dbd9d0b0deb9ebb5251de5cbe 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 e423cab84e17487ab634f957fefce275e02caddf..d5e12108cd2630aabda10ff34c3f113b01e21739 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>