Created
November 12, 2010 20:57
-
-
Save derek/674668 to your computer and use it in GitHub Desktop.
Snagging Github repos with YQL
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
// Create a JSONP wrapper | |
function executeYQL(yql, callbackFuncName) { | |
var url = "http://query.yahooapis.com/v1/public/yql?q=" + encodeURIComponent(yql) + "&env=store://datatables.org/alltableswithkeys&format=json&callback="+callbackFuncName; | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = url; | |
head.appendChild(script); | |
} | |
// Execute the query | |
executeYQL("select repository from github.user.repos where id='drgath' | reverse()", "daCallback"); | |
// Define the callback | |
function daCallback(data) { | |
var repositories = data.query.results.repositories; | |
var html = []; | |
for(i in repositories) { | |
var repo = repositories[i].repository; | |
html.push("<li><a href='" + repo.url + "'>" + repo.name + "</a> - " + repo.description + "</li>"); | |
} | |
document.getElementById("repositories").innerHTML = html.join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment