Skip to content

Instantly share code, notes, and snippets.

@makevoid
Created March 19, 2011 15:28
Show Gist options
  • Select an option

  • Save makevoid/877536 to your computer and use it in GitHub Desktop.

Select an option

Save makevoid/877536 to your computer and use it in GitHub Desktop.
Thorrents JSONP embed example [html]
<html><body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type='text/javascript'>
$(function(){
var query = "ubuntu"
var element = "#thorrents"
var limit = 5
// TODO: jquery function - $("element").thorrents()
var domain = "thorrents.com"
var url = 'http://'+domain+'/search/'+query+'.json?callback=?'
$.getJSON(url, function(data) {
$(element).append("<ul></ul>")
$.each(data.results, function(idx, result) {
$(element+" ul").append("<li><a href='"+result.magnet+"'><span>"+result.seeds+"</span>"+result.name+"</a></li>")
if (idx+1 >= limit)
return false
})
})
})
</script>
<style text='type/css'>
#thorrents li {
display: block;
}
#thorrents li a span {
display: block;
float: left;
text-align: right;
width: 80px;
margin-right: 12px
}
</style>
<div id='thorrents'></div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment