jasmine-ajax/examples/jquery/public/javascripts/TwitSearch.js

33 lines
829 B
JavaScript
Raw Normal View History

var TwitSearch = function(){
return {
displayResults: function(tweets){
2010-08-24 12:38:20 +08:00
var updateStr = "";
2010-08-24 12:38:20 +08:00
$(tweets).each(function(index, tweet) {
updateStr += "<li><img src='" + tweet.imageUrl + "' alt='" + tweet.user + " profile image' />" +
"<p>" + tweet.text + "</p>" +
2010-08-01 10:22:33 +08:00
"<p class='user'>" + tweet.user + "</p>" +
"<p class='timestamp'>" + tweet.postedAt + "</p>";
});
2010-08-24 12:38:20 +08:00
$("#results").html(updateStr);
},
2010-08-01 10:22:33 +08:00
searchFailure: function(response){
2010-08-24 12:38:20 +08:00
$("#results").html("<h2>Oops. Something went wrong.</h2>");
},
2010-08-01 10:22:33 +08:00
cleanup: function(){},
rateLimitReached: function(){
console.log("rate limited");
2010-08-01 10:22:33 +08:00
},
failWhale: function(){
2010-08-24 12:38:20 +08:00
$("#results").html("<img src='images/fail-whale.png' />");
}
}
}();