last.fm.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. $.fn.waypoint.defaults = {
  2. context: window,
  3. continuous: true,
  4. enabled: true,
  5. horizontal: false,
  6. offset: '70%',
  7. triggerOnce: true
  8. }
  9. $('.timeline').waypoint(function() {
  10. $(function() {
  11. options = {
  12. responsive: true,
  13. maintainAspectRatio: true,
  14. animationSteps: 100,
  15. animationEasing: "easeInQuart",
  16. legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
  17. };
  18. var data = {
  19. labels: ["January", "February", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"],
  20. datasets: [
  21. {
  22. label: "Ambient",
  23. fillColor: "rgba(254, 254, 51,0.2)",
  24. strokeColor: "rgba(254, 254, 51,1)",
  25. pointColor: "rgba(254, 254, 51,1)",
  26. pointStrokeColor: "#fff",
  27. pointHighlightFill: "#fff",
  28. pointHighlightStroke: "rgba(220,220,220,1)",
  29. data: [115, 91, 47, 31, 26, 55, 60, 70, 85, 94, 100, 63]
  30. },
  31. {
  32. label: "Blues",
  33. fillColor: "rgba(250, 188, 2,0.2)",
  34. strokeColor: "rgba(250, 188, 2,1)",
  35. pointColor: "rgba(250, 188, 2,1)",
  36. pointStrokeColor: "#fff",
  37. pointHighlightFill: "#fff",
  38. pointHighlightStroke: "rgba(151,187,205,1)",
  39. data: [83, 91, 104, 79, 56, 27, 52, 35, 33, 25, 22, 86]
  40. },
  41. {
  42. label: "Classical",
  43. fillColor: "RGBA(251, 153, 2, .3)",
  44. strokeColor: "rgba(251, 153, 2,1)",
  45. pointColor: "rgba(251, 153, 2,1)",
  46. pointStrokeColor: "#fff",
  47. pointHighlightFill: "#fff",
  48. pointHighlightStroke: "rgba(151,187,205,1)",
  49. data: [118, 78, 30, 9, 16, 37, 50, 41, 34, 50, 99, 200]
  50. },
  51. {
  52. label: "Country",
  53. fillColor: "RGBA(253, 83, 8, .3)",
  54. strokeColor: "rgba(253, 83, 8,1)",
  55. pointColor: "rgba(253, 83, 8,1)",
  56. pointStrokeColor: "#fff",
  57. pointHighlightFill: "#fff",
  58. pointHighlightStroke: "rgba(151,187,205,1)",
  59. data: [46, 85, 91, 79, 26, 37, 50, 41, 34, 50, 49, 81]
  60. },
  61. {
  62. label: "Electronic",
  63. fillColor: "RGBA(254, 39, 18, .3)",
  64. strokeColor: "rgba(254, 39, 18,1)",
  65. pointColor: "rgba(254, 39, 18,1)",
  66. pointStrokeColor: "#fff",
  67. pointHighlightFill: "#fff",
  68. pointHighlightStroke: "rgba(151,187,205,1)",
  69. data: [28, 42, 34, 59, 86, 77, 50, 41, 34, 67, 70, 81]
  70. },
  71. {
  72. label: "Folk",
  73. fillColor: "RGBA(167, 25, 75, .3)",
  74. strokeColor: "rgba(167, 25, 75,1)",
  75. pointColor: "rgba(167, 25, 75,1)",
  76. pointStrokeColor: "#fff",
  77. pointHighlightFill: "#fff",
  78. pointHighlightStroke: "rgba(151,187,205,1)",
  79. data: [38, 31, 70, 39, 56, 117, 50, 41, 34, 50, 90, 121]
  80. },
  81. {
  82. label: "Hip Hop",
  83. fillColor: "RGBA(134, 1, 175, .3)",
  84. strokeColor: "rgba(134, 1, 175,1)",
  85. pointColor: "rgba(134, 1, 175,1)",
  86. pointStrokeColor: "#fff",
  87. pointHighlightFill: "#fff",
  88. pointHighlightStroke: "rgba(151,187,205,1)",
  89. data: [21, 17, 31, 89, 86, 77, 50, 41, 34, 50, 90, 81]
  90. },
  91. {
  92. label: "Jazz",
  93. fillColor: "RGBA(61, 1, 164, .3)",
  94. strokeColor: "rgba(61, 1, 164,1)",
  95. pointColor: "rgba(61, 1, 164,1)",
  96. pointStrokeColor: "#fff",
  97. pointHighlightFill: "#fff",
  98. pointHighlightStroke: "rgba(151,187,205,1)",
  99. data: [51, 38, 33, 19, 26, 57, 50, 81, 170, 200, 195, 172]
  100. },
  101. {
  102. label: "Pop",
  103. fillColor: "RGBA(2, 71, 254, .3)",
  104. strokeColor: "rgba(2, 71, 254,1)",
  105. pointColor: "rgba(2, 71, 254,1)",
  106. pointStrokeColor: "#fff",
  107. pointHighlightFill: "#fff",
  108. pointHighlightStroke: "rgba(151,187,205,1)",
  109. data: [48, 53, 63, 107, 191, 177, 118, 91, 74, 60, 51, 123]
  110. },
  111. {
  112. label: "R&B",
  113. fillColor: "RGBA(3, 146, 206, .3)",
  114. strokeColor: "rgba(3, 146, 206,1)",
  115. pointColor: "rgba(3, 146, 206,1)",
  116. pointStrokeColor: "#fff",
  117. pointHighlightFill: "#fff",
  118. pointHighlightStroke: "rgba(151,187,205,1)",
  119. data: [73, 43, 52, 29, 56, 73, 24, 33, 37, 14, 26, 41]
  120. },
  121. {
  122. label: "Rock",
  123. fillColor: "RGBA(102, 176, 50, .3)",
  124. strokeColor: "rgba(102, 176, 50,1)",
  125. pointColor: "rgba(102, 176, 50,1)",
  126. pointStrokeColor: "#fff",
  127. pointHighlightFill: "#fff",
  128. pointHighlightStroke: "rgba(151,187,205,1)",
  129. data: [28, 37, 30, 59, 146, 157, 200, 105, 94, 40, 36, 89]
  130. },
  131. {
  132. label: "World",
  133. fillColor: "RGBA(208, 234, 43, .3)",
  134. strokeColor: "rgba(208, 234, 43,1)",
  135. pointColor: "rgba(208, 234, 43,1)",
  136. pointStrokeColor: "#fff",
  137. pointHighlightFill: "#fff",
  138. pointHighlightStroke: "rgba(151,187,205,1)",
  139. data: [36, 41, 23, 34, 94, 85, 87, 71, 44, 39, 30, 11]
  140. }
  141. ]
  142. };
  143. ctx = $("#timechart").get(0).getContext("2d");
  144. LineChart = new Chart(ctx).Line(data, options);
  145. });
  146. });
  147. $('.music-types').waypoint(function() {
  148. $(function() {
  149. options = {
  150. scaleShowLabelBackdrop: true,
  151. scaleBackdropColor: "rgba(255,255,255,0.75)",
  152. scaleBeginAtZero: true,
  153. scaleBackdropPaddingY: 2,
  154. scaleBackdropPaddingX: 2,
  155. scaleShowLine: true,
  156. segmentShowStroke: true,
  157. segmentStrokeColor: "#fff",
  158. segmentStrokeWidth: 2,
  159. animationSteps: 100,
  160. animationEasing: "easeInCirc",
  161. animateRotate: true,
  162. animateScale: false,
  163. legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
  164. };
  165. data = [
  166. {
  167. value: 440,
  168. color: "RGBA(254, 254, 51, .7)",
  169. highlight: "RGBA(254, 254, 51, .3)",
  170. label: "Ambient"
  171. },
  172. {
  173. value: 510,
  174. color: "RGBA(250, 188, 2, .7)",
  175. highlight: "RGBA(250, 188, 2, .3)",
  176. label: "Blues"
  177. },
  178. {
  179. value: 410,
  180. color: "RGBA(251, 153, 2, .7)",
  181. highlight: "RGBA(251, 153, 2, .3)",
  182. label: "Classical"
  183. },
  184. {
  185. value: 510,
  186. color: "RGBA(253, 83, 8, .7)",
  187. highlight: "RGBA(253, 83, 8, .3)",
  188. label: "Country"
  189. },
  190. {
  191. value: 548,
  192. color: "RGBA(254, 39, 18, .7)",
  193. highlight: "RGBA(254, 39, 18, .3)",
  194. label: "Electronic"
  195. },
  196. {
  197. value: 460,
  198. color: "RGBA(167, 25, 75, .7)",
  199. highlight: "RGBA(167, 25, 75, .3)",
  200. label: "Folk"
  201. },
  202. {
  203. value: 261,
  204. color: "RGBA(134, 1, 175, .7)",
  205. highlight: "RGBA(134, 1, 175, .3)",
  206. label: "Hip Hop"
  207. },
  208. {
  209. value: 1038,
  210. color: "RGBA(61, 1, 164, .7)",
  211. highlight: "RGBA(61, 1, 164, .3)",
  212. label: "Jazz"
  213. },
  214. {
  215. value: 970,
  216. color: "RGBA(2, 71, 254, .7)",
  217. highlight: "RGBA(2, 71, 254, .3)",
  218. label: "Pop"
  219. },
  220. {
  221. value: 777,
  222. color: "RGBA(3, 146, 206, .7)",
  223. highlight: "RGBA(3, 146, 206, .3)",
  224. label: "R&B"
  225. },
  226. {
  227. value: 712,
  228. color: "RGBA(102, 176, 50, .7)",
  229. highlight: "RGBA(102, 176, 50, .3)",
  230. label: "Rock"
  231. },
  232. {
  233. value: 625,
  234. color: "RGBA(208, 234, 43, .7)",
  235. highlight: "RGBA(208, 234, 43, .3)",
  236. label: "World"
  237. }
  238. ];
  239. ctx = $("#typechart").get(0).getContext("2d");
  240. styles = new Chart(ctx).Doughnut(data, options);
  241. document.getElementById('key').innerHTML = styles.generateLegend();
  242. });
  243. });
  244. $('.music-typed').waypoint(function() {
  245. $(function() {
  246. options = {
  247. scaleShowLabelBackdrop: true,
  248. scaleBackdropColor: "rgba(255,255,255,0.75)",
  249. scaleBeginAtZero: true,
  250. scaleBackdropPaddingY: 2,
  251. scaleBackdropPaddingX: 2,
  252. scaleShowLine: true,
  253. segmentShowStroke: true,
  254. segmentStrokeColor: "#fff",
  255. segmentStrokeWidth: 2,
  256. animationSteps: 100,
  257. animationEasing: "easeOutQuart",
  258. animateRotate: true,
  259. animateScale: false,
  260. legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
  261. };
  262. data = [
  263. {
  264. value: 440,
  265. color: "RGBA(254, 254, 51, .7)",
  266. highlight: "RGBA(254, 254, 51, .3)",
  267. label: "Ambient"
  268. },
  269. {
  270. value: 510,
  271. color: "RGBA(250, 188, 2, .7)",
  272. highlight: "RGBA(250, 188, 2, .3)",
  273. label: "Blues"
  274. },
  275. {
  276. value: 410,
  277. color: "RGBA(251, 153, 2, .7)",
  278. highlight: "RGBA(251, 153, 2, .3)",
  279. label: "Classical"
  280. },
  281. {
  282. value: 510,
  283. color: "RGBA(253, 83, 8, .7)",
  284. highlight: "RGBA(253, 83, 8, .3)",
  285. label: "Country"
  286. },
  287. {
  288. value: 548,
  289. color: "RGBA(254, 39, 18, .7)",
  290. highlight: "RGBA(254, 39, 18, .3)",
  291. label: "Electronic"
  292. },
  293. {
  294. value: 460,
  295. color: "RGBA(167, 25, 75, .7)",
  296. highlight: "RGBA(167, 25, 75, .3)",
  297. label: "Folk"
  298. },
  299. {
  300. value: 261,
  301. color: "RGBA(134, 1, 175, .7)",
  302. highlight: "RGBA(134, 1, 175, .3)",
  303. label: "Hip Hop"
  304. },
  305. {
  306. value: 1000,
  307. color: "RGBA(61, 1, 164, .7)",
  308. highlight: "RGBA(61, 1, 164, .3)",
  309. label: "Jazz"
  310. },
  311. {
  312. value: 970,
  313. color: "RGBA(2, 71, 254, .7)",
  314. highlight: "RGBA(2, 71, 254, .3)",
  315. label: "Pop"
  316. },
  317. {
  318. value: 777,
  319. color: "RGBA(3, 146, 206, .7)",
  320. highlight: "RGBA(3, 146, 206, .3)",
  321. label: "R&B"
  322. },
  323. {
  324. value: 712,
  325. color: "RGBA(102, 176, 50, .7)",
  326. highlight: "RGBA(102, 176, 50, .3)",
  327. label: "Rock"
  328. },
  329. {
  330. value: 625,
  331. color: "RGBA(208, 234, 43, .7)",
  332. highlight: "RGBA(208, 234, 43, .3)",
  333. label: "World"
  334. }
  335. ];
  336. ctx = $("#artchart").get(0).getContext("2d");
  337. myNewChart = new Chart(ctx).PolarArea(data, options);
  338. });
  339. });
  340. (function( $ ) {
  341. $.fn.lfmr = function(options){
  342. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&format=json&limit=17";
  343. var tracks = [];
  344. function isLoadedr (recentElement) {
  345. for (var i = 0; i < tracks.length; i++){
  346. var markup = $("<li class='list-group-item'>" + tracks[i].artist + " - <span class='artist'>" + tracks[i].title + " : " + tracks[i].album + "</li>");
  347. recentElement.append(markup);
  348. }
  349. }
  350. return this.each(function(){
  351. var $this = $(this);
  352. $.getJSON( urla, function(data){
  353. $(data.recenttracks.track).each(function(){
  354. tracks.push ({
  355. artist: this.artist["#text"],
  356. title: this.name,
  357. album: this.album["#text"]
  358. });
  359. });
  360. isLoadedr($this);
  361. });
  362. });
  363. };
  364. $.fn.lfmtw = function(options){
  365. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=7day&format=json&limit=20";
  366. var tracks = [];
  367. function isLoadedt (tracksElement) {
  368. for (var i = 0; i < tracks.length; i++){
  369. var markup = $("<li class='list-group-item'>" + tracks[i].artist + " - <span class='artist'>" + tracks[i].title + "</span><span class='badge'>" + tracks[i].played + "</span></li>");
  370. tracksElement.append(markup);
  371. }
  372. }
  373. return this.each(function(){
  374. var $this = $(this);
  375. $.getJSON( urla, function(data){
  376. $(data.toptracks.track).each(function(){
  377. tracks.push ({
  378. title: this.name,
  379. artist: this.artist.name,
  380. played: this.playcount,
  381. });
  382. });
  383. isLoadedt($this);
  384. });
  385. });
  386. };
  387. $.fn.lfmaw = function(options){
  388. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=7day&format=json&limit=25";
  389. var artists = [];
  390. function isLoadeda (artistElement) {
  391. for (var i = 0; i < artists.length; i++){
  392. var markup = $("<li class='list-group-item'>" + artists[i].aname + "<span class='badge'>" + artists[i].played + "</span></li>");
  393. artistElement.append(markup);
  394. }
  395. }
  396. return this.each(function(){
  397. var $this = $(this);
  398. $.getJSON( urla, function(data){
  399. $(data.topartists.artist).each(function(){
  400. artists.push ({
  401. aname: this.name,
  402. played: this.playcount
  403. });
  404. });
  405. isLoadeda($this);
  406. });
  407. });
  408. };
  409. $.fn.lfma = function(options){
  410. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=6month&format=json&limit=50";
  411. var artists = [];
  412. function isLoadeda (artistElement) {
  413. for (var i = 0; i < artists.length; i++){
  414. var markup = $("<li class='list-group-item'>" + artists[i].aname + "<span class='badge'>" + artists[i].played + "</span></li>");
  415. artistElement.append(markup);
  416. }
  417. }
  418. return this.each(function(){
  419. var $this = $(this);
  420. $.getJSON( urla, function(data){
  421. $(data.topartists.artist).each(function(){
  422. artists.push ({
  423. aname: this.name,
  424. played: this.playcount
  425. });
  426. });
  427. isLoadeda($this);
  428. });
  429. });
  430. };
  431. $.fn.lfmt = function(options){
  432. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=6month&format=json&limit=50";
  433. var tracks = [];
  434. function isLoadedt (tracksElement) {
  435. for (var i = 0; i < tracks.length; i++){
  436. var markup = $("<li class='list-group-item'>" + tracks[i].artist + " - <span class='artist'>" + tracks[i].title + "</span><span class='badge'>" + tracks[i].played + "</span></li>");
  437. tracksElement.append(markup);
  438. }
  439. }
  440. return this.each(function(){
  441. var $this = $(this);
  442. $.getJSON( urla, function(data){
  443. $(data.toptracks.track).each(function(){
  444. tracks.push ({
  445. title: this.name,
  446. artist: this.artist.name,
  447. played: this.playcount,
  448. });
  449. });
  450. isLoadedt($this);
  451. });
  452. });
  453. };
  454. $.fn.lfm = function(options){
  455. var url = "https://ws.audioscrobbler.com/2.0/?method=user.gettopalbums&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=12month&format=json&limit=200";
  456. var albums = [];
  457. function isLoaded (albumElement) {
  458. for (var i = 0; i < albums.length; i++){
  459. var markup = $("<div class='album'><div class='front'><img src='" + albums[i].art + "'><div class='alpha'></div></div><div class='back'><h2>" + albums[i].artist + "</h2><h1>" + albums[i].name + "</h1><h3><span class='badge'>" + albums[i].played + "</span> tracks played</h3></div></div>");
  460. albumElement.append(markup);
  461. }
  462. albumElement.find('.album').hover(function(){
  463. $(this).addClass('flip');
  464. },function(){
  465. $(this).removeClass('flip');
  466. });
  467. }
  468. return this.each(function(){
  469. var $this = $(this);
  470. $.getJSON( url, function(data){
  471. $(data.topalbums.album).each(function(){
  472. albums.push ({
  473. name: this.name,
  474. artist: this.artist.name,
  475. played: this.playcount,
  476. art: this.image[this.image.length-1]["#text"]
  477. });
  478. });
  479. isLoaded($this);
  480. });
  481. });
  482. };
  483. })( jQuery );
  484. $('.recent').lfmr();
  485. $('.wtracks').lfmtw();
  486. $('.wartists').lfmaw();
  487. $('.artists').lfma();
  488. $('.tracks').lfmt();
  489. $('.albums').lfm();