From 325eda5720d3eef75332939b775ef024c6436dc0 Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Fri, 17 Jun 2011 16:48:45 +0400 Subject: [PATCH] Trends with icons --- css/style.css | 2 +- mhd.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/css/style.css b/css/style.css index 21a2040..2a15bb5 100644 --- a/css/style.css +++ b/css/style.css @@ -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 { diff --git a/mhd.js b/mhd.js index 8ccd394..2e15287 100644 --- a/mhd.js +++ b/mhd.js @@ -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 = ''; + var down_img = ''; + var equal_img = ''; for(var platform in json.response.fans) { if(!json.response.fans.hasOwnProperty(platform)) continue; @@ -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('

' + platform + ': ' + totalFans + ' fans, ' + (Math.abs(currentFans - previousFans) < 100 ? 'holding up' : (currentFans > previousFans ? 'on the rise' : 'falling down')) + '

'); + $('#meta_info').append('

' + (Math.abs(currentFans - previousFans) < 5 ? equal_img : (currentFans > previousFans ? up_img : down_img)) + ' ' + platform + ': ' + (totalFans > 1000000 ? ((Math.floor(totalFans / 100000) / 10.0) + "M") : (totalFans > 1000 ? ((Math.floor(totalFans / 100) / 10.0) + "K") : totalFans)) + ' fans' + '

'); } $('#artist_span').append(' (' + json.response.fans.total.total + ' fans)'); }