Created
March 19, 2011 15:28
-
-
Save makevoid/877536 to your computer and use it in GitHub Desktop.
Thorrents JSONP embed example [html]
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
| <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