Created
April 28, 2011 15:46
-
-
Save jesperbjensen/946615 to your computer and use it in GitHub Desktop.
Simple tweet rotator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"> | |
</script> | |
<script type="text/javascript" charset="utf-8"> | |
var query = 'javascript'; | |
$(function() { | |
$.getJSON("http://search.twitter.com/search.json?callback=?&q=" + query, | |
function (r) { | |
setResults(r); | |
}); | |
}) | |
var results = []; | |
var index = 0; | |
function setResults(data) { | |
results = data.results; | |
update(); | |
} | |
function setTweet(result) { | |
$("#image").attr("src" , result.profile_image_url); | |
$("#name").text(result.from_user) | |
$("#text").text(result.text); | |
} | |
function update() { | |
setTweet(results[index]); | |
index += 1; | |
if(index == results.length) { | |
index = 0; | |
} | |
setTimeout(update,15000); | |
} | |
</script> | |
<body> | |
<img id="image" /> | |
<h2 id="name"></h2> | |
<p id="text"></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment