Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Support artist images
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Cowans committed May 29, 2011
1 parent d078cc3 commit 246cb9d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
7 changes: 7 additions & 0 deletions popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ body
font-size: 0.8em;
}

.artist-image img
{
border: 1px solid black;
margin-right: 6px;
margin-top: 4px;
}

.songkick-listing
{
font-family: 'lucida grande', tahoma, verdana, sans-serif;
Expand Down
2 changes: 1 addition & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ul>

<script type="text/template" id="artist-template">
<h2><%= name %></h2>
<h2><span class="artist-image"></span><%= name %></h2>
<div class="soundCloudPlayer">Loading SoundCloud player...</div>
<h3>Youtube Plays</h3>
<div><span class="sparkline-youtube">Loading chart data...</span></div>
Expand Down
25 changes: 24 additions & 1 deletion tractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,28 @@ window.Timeseries = Backbone.Model.extend({
},

url: function() {
return "http://apib2.semetric.com/artist/musicbrainz:" + escape(this.musicbrainzID) + "/" + escape(this.dataset) + "?token=bbc004e8891211e0ba8f00163e499d92"
return "http://apib2.semetric.com/artist/musicbrainz:" + escape(this.musicbrainzID) + "/" + escape(this.dataset) + "?token=bbc004e8891211e0ba8f00163e499d92";
},

parse: function(response) {
return response.response;
}
});

window.ArtistImage = Backbone.Model.extend({
initialize: function() {
_.bindAll(this, "url");
},

url: function() {
return "http://ws.audioscrobbler.com/2.0/?format=json&method=artist.getinfo&artist=" + escape(this.artistName) + "&api_key=55452202851c1c703bb26c4f42045b16";
},

parse: function(response) {
return response.artist.image[1];
}
});

window.SongkickCalendarView = Backbone.View.extend({
initialize: function() {
_.bindAll(this, "setCalendar", "render");
Expand Down Expand Up @@ -123,6 +137,10 @@ window.ArtistView = Backbone.View.extend({
return function(timeseries) {element.sparkline(timeseries.get("data"));};
},

renderArtistImage: function(element) {
return function(artistImage) {element.html("<img src=\"" + artistImage.get("#text") + "\"></img>");};
},

render: function(artist) {
$(this.el).html(this.template(artist.toJSON()));

Expand All @@ -149,6 +167,11 @@ window.ArtistView = Backbone.View.extend({
timeseries.bind("change", this.renderTimeseries(this.$(".sparkline-myspace")));
timeseries.fetch();

var artistImage = new ArtistImage;
artistImage.artistName = artist.get("name");
artistImage.bind("change", this.renderArtistImage(this.$(".artist-image")));
artistImage.fetch();

var calendar = new Calendar;
calendar.musicbrainzID = artist.get("mbid");

Expand Down

0 comments on commit 246cb9d

Please sign in to comment.