Skip to content

Commit

Permalink
Trends with icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Amos Wenger committed Jun 17, 2011
1 parent 8a5f8eb commit 325eda5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ div.timeline {
div#progressbar { width: 0; height: 20px; background-color: #FA5945; }
div#preloadbar { width: 0; height: 20px; background-color: rgba(255,228,0,0.5); }

div.meta { background-color: rgba(0, 0, 0, 0.1); width:460px; padding:20px; font-size:12px; display:inline-block; }
div.meta { background-color: rgba(0, 0, 0, 0.1); width:460px; padding:20px; font-size:16px; display:inline-block; }


#footer {
Expand Down
13 changes: 12 additions & 1 deletion mhd.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,23 @@ function usePlayer (player) {
var artist_id = doc.find('artist').attr('id');
console.log("musicbrainz artist id = " + artist_id);

var icons = {
facebook: 'http://facebook.com/favicon.ico',
lastfm: 'http://last.fm/favicon.ico',
myspace: 'http://myspace.com/favicon.ico',
twitter: 'http://twitter.com/favicon.ico',
youtube: 'http://www.youtube.com/favicon.ico',
};

$.ajax({
type: "GET",
url: "http://jsmad.org/musicmetric/musicbrainz:" + artist_id,
dataType: "json",
success: function(json) {
console.log("success? " + json.success);
var up_img = '<img src="http://jsmad.org/images/up.png">';
var down_img = '<img src="http://jsmad.org/images/down.png">';
var equal_img = '<img src="http://jsmad.org/images/equal.png">';

for(var platform in json.response.fans) {
if(!json.response.fans.hasOwnProperty(platform)) continue;
Expand All @@ -114,7 +125,7 @@ function usePlayer (player) {
var currentFans = parseInt(fans.current);
var totalFans = parseInt(fans.total);
console.log("previous/current fans? " + previousFans + "/" + currentFans);
$('#meta_info').append('<p><strong>' + platform + ': ' + totalFans + ' fans, </strong>' + (Math.abs(currentFans - previousFans) < 100 ? 'holding up' : (currentFans > previousFans ? 'on the rise' : 'falling down')) + '</p>');
$('#meta_info').append('<p><strong>' + (Math.abs(currentFans - previousFans) < 5 ? equal_img : (currentFans > previousFans ? up_img : down_img)) + ' <img src="' + icons[platform] + '"> ' + platform + ': ' + (totalFans > 1000000 ? ((Math.floor(totalFans / 100000) / 10.0) + "M") : (totalFans > 1000 ? ((Math.floor(totalFans / 100) / 10.0) + "K") : totalFans)) + ' fans</strong>' + '</p>');
}
$('#artist_span').append(' <small>(' + json.response.fans.total.total + ' fans)</small>');
}
Expand Down

0 comments on commit 325eda5

Please sign in to comment.