Skip to content
Snippets Groups Projects
Commit bdc23fb8 authored by ale's avatar ale
Browse files

provide feedback to the user when a search or other playlist mod returns no results

parent defc70be
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -157,6 +157,8 @@ $(document).ready(function() {
</form>
</div>
<div id="searchWarnMsg"></div>
<div id="playlistButtons" class="buttonbox">
<a id="playlistLast5">Last 5</a>&nbsp;<a id="playlistLast25">(25)</a>
| <a id="playlistRandom5">Random 5</a>&nbsp;<a id="playlistRandom25">(25)</a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment