Created
August 31, 2011 20:29
-
-
Save orfeomorello/1184635 to your computer and use it in GitHub Desktop.
Twitter trend cities example
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<title> www.localstreamer.com - Twitter trend cities example </title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
function startme(){ | |
$.ajax({ | |
url: 'http://api.twitter.com/1/trends/available.json', | |
dataType: 'jsonp', | |
success: function( data ) | |
{ | |
var s=""; | |
var ss=""; | |
$.each(data, function(i, item) | |
{ | |
if(i==0) | |
{ | |
ss+="<tr><th>Name</th><th>Country</th></tr>"; | |
} | |
if(item.placeType.code=='7') | |
{ | |
s+="<tr>"; | |
s+="<th><a href=\"http://www.localstreamer.com/in/"+encodeURIComponent(item.name.toLowerCase())+","+item.countryCode.toLowerCase()+"\" target=\"_blank\">"+item.name+"</th>"; | |
s+="<td>"+item.country+"</td>"; | |
s+="</tr>"; | |
} | |
}); | |
$("#trends").html("<table id=\"trendstable\"><thead>"+ss+"</thead><tbody>"+s+"</tbody></table>"); | |
}} | |
); | |
} | |
</script> | |
</head> | |
<body onload="startme()"> | |
<div id="trends"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment