Created
October 14, 2009 22:35
-
-
Save imlucas/210462 to your computer and use it in GitHub Desktop.
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
| $.getScript('http://amiestreet.com/static/js/amie-api-client.js', function(){ | |
| amiestreet.__gateway = 'http://beta.amiestreet.com/api/v0.1/'; | |
| amiestreet.UserApi_playHistory = function(user, limit, offset, callback){this.__call('UserApi', 'playHistory', arguments);}, | |
| amiestreet.UserApi_playHistory('lucas', 25, 0, function(history){ | |
| var lastAlbumId= ''; | |
| var list = {}; | |
| // group by albums | |
| $.each(history, function(){ | |
| if(this.song.album.id != lastAlbumId){ | |
| list[this.song.album.id] = []; | |
| lastAlbumId = this.song.album.id; | |
| } | |
| list[this.song.album.id].push(this); | |
| }); | |
| var html = '<h2 style="clear: both; margin-top: 20px;">What I\'m Listening To on <a href="http://amiestreet.com">Amie Street</a></h2><ul id="listen-history">'; | |
| lastAlbumId = ''; | |
| $.each(list, function(key, value){ | |
| html +='<li style="display: block; float: left; margin-right: 20px; width: 250px;">' | |
| html += '<div style="height: 120px; float:left; margin-right: 10px; overflow: hidden;"><a href="'+value[0].song.album.url+'"><img src="'+value[0].song.album.image.small+'" height="60" width="60"/></a></div><ul style="list-style-type: none;"><li style="margin-bottom: 5px;"><strong><a href="'+value[0].song.album.url+'">'+value[0].song.album.title+'</a><br />by '+value[0].song.artist.name+'</strong></li>'; | |
| $.each(value, function(){ | |
| html += '<li style="margin-bottom: 2px;">'+this.song.title+'</li>'; | |
| }); | |
| html += '</ul><br clear="both"/> '; | |
| html +='</li>'; | |
| }); | |
| html += '</ul>'; | |
| $('body').append(html); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment