Created
May 28, 2010 23:15
-
-
Save ryanflorence/417877 to your computer and use it in GitHub Desktop.
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
Request.Fiddles = new Class({ | |
Extends: Request.JSONP, | |
options: { | |
update: document.body, | |
limit: 5, | |
item: 'li', | |
itemHtml: | |
'<a href="{url}{version}" target="_blank">{title}</a> ' + | |
'<span>rev{version}</span>' + | |
'<p>{description}</p>', | |
callbackKey: 'jsoncallback', | |
data: { | |
limit: 10 | |
} | |
}, | |
initialize: function(user, options){ | |
this.parent(options); | |
this.options.url = 'http://jsfiddle.net/api/user/' + user + '/demo/list.json'; | |
//this.options.url = 'http://jsfiddle.zalewa.info/api/user/' + user + '/demo/list.json'; | |
this.update = document.id(this.options.update); | |
this.addEvent('complete', this.listFiddles.bind(this)); | |
}, | |
listFiddles: function(response){ | |
if (response.status === 'ok'){ | |
response.list.each(function(fiddle){ | |
var html = this.options.itemHtml.substitute(fiddle); | |
new Element(this.options.item,{ html: html}).inject(this.update); | |
}, this); | |
} | |
return this; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment