Skip to content

Commit

Permalink
Better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Freenerd committed Jun 17, 2011
1 parent fbd4344 commit e5f3945
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -21,7 +21,7 @@
</div>

<div class="not-found">
<h3>Oh no, artist was not found</h3>
<h3>Oh no, artist <span></span> was not found</h3>
<input type="submit" class="start" value="Try another pair">
</div>

Expand Down
15 changes: 14 additions & 1 deletion script.js
Expand Up @@ -37,8 +37,9 @@ var getTracks = function(artist, resultSelector) {
q_artist: artist
},
function(data) {
if ( !data.message.body.track_list[0].track ) {
if ( !(data.message.body.track_list[0] && data.message.body.track_list[0].track) ) {
$("body").removeClass().addClass("not-found");
$("div.not-found h3 span").text("\'" + artist + "\'");
} else {
$(".results ." + resultSelector + " .name").
text(data.message.body.track_list[0].track.artist_name);
Expand Down Expand Up @@ -137,6 +138,18 @@ $(document).ready( function() {
);
});

// Inputs submit-on-enter
$.each(RESULT_SELECTORS, function(i, selector) {
$(".start input." + selector).keypress( function(e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$('#submit').click();
return false;
} else {
return true;
}
});
});

// Reset
$("input.start").click( function() {
$('.inputs input.artist-a').val("")
Expand Down

0 comments on commit e5f3945

Please sign in to comment.