Information Technology Reference
In-Depth Information
Figure 3-2. Notice the preceding URL from Android Thoughts uses hyphens instead of spaces to present the user
with a much more friendly and human readable URL
After we grab the JSONP data from Twitter, we are going to parse the data for the
data.resultsfield and then grab the length of that array, the number of records in it,
and then push them off to the correctarray that we created earlier, as can be seen in
Listing 3-7.
Listing 3-7. Javascript for I Love Ham -Part 3
// this function will grab a random user from
// the tweets array.
functiongetRandom() {
var l = tweets.length; // grab length of tweet array
var ran = Math.floor(Math.random()*l); // grab random user
return tweets[ran];
}
functionbuildQuiz() {
var h = '';
for(i=0;i<choice.length;i++){
h += '<li>';
h += ' <blockquote>' + choice[i] + '</blockquote>';
h += '</li>';
}
// write buttons to the page
$('ul').html(h);
}
$(function(){
// run the init() function and start the application
init();
// check for correct user on user selection
$('ul li').live('click', function() {
var id = $(this).index();
Search WWH ::




Custom Search