From e5f3945bb31595439f34edb68367e33b9d8047ae Mon Sep 17 00:00:00 2001 From: Freenerd Date: Fri, 17 Jun 2011 12:19:39 +0200 Subject: [PATCH] Better errors --- index.html | 2 +- script.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 3de693d..5c191b2 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@
-

Oh no, artist was not found

+

Oh no, artist was not found

diff --git a/script.js b/script.js index ce272ee..607aed1 100644 --- a/script.js +++ b/script.js @@ -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); @@ -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("")