Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save makevoid/877535 to your computer and use it in GitHub Desktop.
Thorrents JSONP embed example [HAML]
%script{ type: "text/javascript" }
:plain
$(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+'?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
})
})
})
%style{ text: "type/css" }
:plain
#thorrents li {
display: block;
}
#thorrents li a span {
display: block;
float: left;
text-align: right;
width: 80px;
margin-right: 12px
}
#thorrents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment