Last.fm API weekly charts (nicer)

by Oski Krawczyk

CSS

div {
    font-family: Helvetica;
    font-size: 11px;
    padding: 5px 0;
}

JavaScript

Request.LastFm = new Class({

    Extends: Request.JSONP,

    options: {
        url: 'http://ws.audioscrobbler.com/2.0/',
        data: {
            api_key: 'b25b959554ed76058ac220b7b2e0a026',
            format: 'json'
        }
    }

});

var TasteFm = new Class({

    Implements: [Options, Events],

    options: {

    },

    initialize: function(username, options) {
        this.setOptions(options);
        this.username = username;
    },

    get: function(method, options) {
        new Request.LastFm($merge({
            data: {
                method: method,
                user: this.username
            }
        }, options)).send();
    }

});

var TFM = new TasteFm('wassago_');

TFM.get('user.getweeklyalbumchart', {

    onComplete: function(response) {
        response.weeklyalbumchart.album.each(function(album) {
            //console.log(album.artist.mbid);

            new Element('img', {
                src: TFM.get('album.getInfo', {
                    mbid: album.artist.mbid,
                    onComplete: function(response){
                        console.log(response);
                    }
                })
            }).inject(document.body);


            //new Element('div', {
            //    html: '{name} ({playcount})'.substitute(album)
            //}).inject(document.body);
        });
    }

});