2010-08-01 09:43:10 +08:00
|
|
|
var TwitSearch = function(){
|
|
|
|
|
|
|
|
return {
|
|
|
|
displayResults: function(tweets){
|
2010-08-24 12:38:20 +08:00
|
|
|
var updateStr = "";
|
2010-08-01 09:43:10 +08:00
|
|
|
|
2010-08-24 12:38:20 +08:00
|
|
|
$(tweets).each(function(index, tweet) {
|
|
|
|
updateStr += "<li><img src='" + tweet.imageUrl + "' alt='" + tweet.user + " profile image' />" +
|
2010-08-01 09:43:10 +08:00
|
|
|
"<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-01 09:43:10 +08:00
|
|
|
});
|
|
|
|
|
2010-08-24 12:38:20 +08:00
|
|
|
$("#results").html(updateStr);
|
2010-08-01 09:43:10 +08:00
|
|
|
},
|
2010-08-01 10:22:33 +08:00
|
|
|
|
2010-08-01 09:43:10 +08:00
|
|
|
searchFailure: function(response){
|
2010-08-24 12:38:20 +08:00
|
|
|
$("#results").html("<h2>Oops. Something went wrong.</h2>");
|
2010-08-01 09:43:10 +08:00
|
|
|
},
|
2010-08-01 10:22:33 +08:00
|
|
|
|
|
|
|
cleanup: function(){},
|
|
|
|
|
2010-08-01 09:43:10 +08:00
|
|
|
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' />");
|
2010-08-01 09:43:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}();
|