fm.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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. responsive: true,
  151. scaleShowLabelBackdrop: true,
  152. scaleBackdropColor: "rgba(255,255,255,0.75)",
  153. scaleBeginAtZero: true,
  154. scaleBackdropPaddingY: 2,
  155. scaleBackdropPaddingX: 2,
  156. scaleShowLine: true,
  157. segmentShowStroke: true,
  158. segmentStrokeColor: "#fff",
  159. segmentStrokeWidth: 2,
  160. animationSteps: 100,
  161. animationEasing: "easeInCirc",
  162. animateRotate: true,
  163. animateScale: false,
  164. 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>"
  165. };
  166. data = [
  167. {
  168. value: 440,
  169. color: "RGBA(254, 254, 51, .7)",
  170. highlight: "RGBA(254, 254, 51, .3)",
  171. label: "Ambient"
  172. },
  173. {
  174. value: 510,
  175. color: "RGBA(250, 188, 2, .7)",
  176. highlight: "RGBA(250, 188, 2, .3)",
  177. label: "Blues"
  178. },
  179. {
  180. value: 410,
  181. color: "RGBA(251, 153, 2, .7)",
  182. highlight: "RGBA(251, 153, 2, .3)",
  183. label: "Classical"
  184. },
  185. {
  186. value: 510,
  187. color: "RGBA(253, 83, 8, .7)",
  188. highlight: "RGBA(253, 83, 8, .3)",
  189. label: "Country"
  190. },
  191. {
  192. value: 548,
  193. color: "RGBA(254, 39, 18, .7)",
  194. highlight: "RGBA(254, 39, 18, .3)",
  195. label: "Electronic"
  196. },
  197. {
  198. value: 460,
  199. color: "RGBA(167, 25, 75, .7)",
  200. highlight: "RGBA(167, 25, 75, .3)",
  201. label: "Folk"
  202. },
  203. {
  204. value: 261,
  205. color: "RGBA(134, 1, 175, .7)",
  206. highlight: "RGBA(134, 1, 175, .3)",
  207. label: "Hip Hop"
  208. },
  209. {
  210. value: 1038,
  211. color: "RGBA(61, 1, 164, .7)",
  212. highlight: "RGBA(61, 1, 164, .3)",
  213. label: "Jazz"
  214. },
  215. {
  216. value: 970,
  217. color: "RGBA(2, 71, 254, .7)",
  218. highlight: "RGBA(2, 71, 254, .3)",
  219. label: "Pop"
  220. },
  221. {
  222. value: 777,
  223. color: "RGBA(3, 146, 206, .7)",
  224. highlight: "RGBA(3, 146, 206, .3)",
  225. label: "R&B"
  226. },
  227. {
  228. value: 712,
  229. color: "RGBA(102, 176, 50, .7)",
  230. highlight: "RGBA(102, 176, 50, .3)",
  231. label: "Rock"
  232. },
  233. {
  234. value: 625,
  235. color: "RGBA(208, 234, 43, .7)",
  236. highlight: "RGBA(208, 234, 43, .3)",
  237. label: "World"
  238. }
  239. ];
  240. ctx = $("#typechart").get(0).getContext("2d");
  241. styles = new Chart(ctx).Doughnut(data, options);
  242. document.getElementById('key').innerHTML = styles.generateLegend();
  243. });
  244. });
  245. $('.music-typed').waypoint(function() {
  246. $(function() {
  247. options = {
  248. responsive: true,
  249. scaleShowLabelBackdrop: true,
  250. scaleBackdropColor: "rgba(255,255,255,0.75)",
  251. scaleBeginAtZero: true,
  252. scaleBackdropPaddingY: 2,
  253. scaleBackdropPaddingX: 2,
  254. scaleShowLine: true,
  255. segmentShowStroke: true,
  256. segmentStrokeColor: "#fff",
  257. segmentStrokeWidth: 2,
  258. animationSteps: 100,
  259. animationEasing: "easeOutQuart",
  260. animateRotate: true,
  261. animateScale: false,
  262. 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>"
  263. };
  264. data = [
  265. {
  266. value: 440,
  267. color: "RGBA(254, 254, 51, .7)",
  268. highlight: "RGBA(254, 254, 51, .3)",
  269. label: "Ambient"
  270. },
  271. {
  272. value: 510,
  273. color: "RGBA(250, 188, 2, .7)",
  274. highlight: "RGBA(250, 188, 2, .3)",
  275. label: "Blues"
  276. },
  277. {
  278. value: 410,
  279. color: "RGBA(251, 153, 2, .7)",
  280. highlight: "RGBA(251, 153, 2, .3)",
  281. label: "Classical"
  282. },
  283. {
  284. value: 510,
  285. color: "RGBA(253, 83, 8, .7)",
  286. highlight: "RGBA(253, 83, 8, .3)",
  287. label: "Country"
  288. },
  289. {
  290. value: 548,
  291. color: "RGBA(254, 39, 18, .7)",
  292. highlight: "RGBA(254, 39, 18, .3)",
  293. label: "Electronic"
  294. },
  295. {
  296. value: 460,
  297. color: "RGBA(167, 25, 75, .7)",
  298. highlight: "RGBA(167, 25, 75, .3)",
  299. label: "Folk"
  300. },
  301. {
  302. value: 261,
  303. color: "RGBA(134, 1, 175, .7)",
  304. highlight: "RGBA(134, 1, 175, .3)",
  305. label: "Hip Hop"
  306. },
  307. {
  308. value: 1000,
  309. color: "RGBA(61, 1, 164, .7)",
  310. highlight: "RGBA(61, 1, 164, .3)",
  311. label: "Jazz"
  312. },
  313. {
  314. value: 970,
  315. color: "RGBA(2, 71, 254, .7)",
  316. highlight: "RGBA(2, 71, 254, .3)",
  317. label: "Pop"
  318. },
  319. {
  320. value: 777,
  321. color: "RGBA(3, 146, 206, .7)",
  322. highlight: "RGBA(3, 146, 206, .3)",
  323. label: "R&B"
  324. },
  325. {
  326. value: 712,
  327. color: "RGBA(102, 176, 50, .7)",
  328. highlight: "RGBA(102, 176, 50, .3)",
  329. label: "Rock"
  330. },
  331. {
  332. value: 625,
  333. color: "RGBA(208, 234, 43, .7)",
  334. highlight: "RGBA(208, 234, 43, .3)",
  335. label: "World"
  336. }
  337. ];
  338. ctx = $("#artchart").get(0).getContext("2d");
  339. myNewChart = new Chart(ctx).PolarArea(data, options);
  340. });
  341. });
  342. (function( $ ) {
  343. $.fn.lfmr = function(options){
  344. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&format=json&limit=50";
  345. var tracks = [];
  346. function isLoadedr (recentElement) {
  347. for (var i = 0; i < tracks.length; i++){
  348. var markup = $("<li class='list-group-item'>" + tracks[i].artist + " - <span class='artist'>" + tracks[i].title + " : " + tracks[i].album + "</li>");
  349. recentElement.append(markup);
  350. }
  351. }
  352. return this.each(function(){
  353. var $this = $(this);
  354. $.getJSON( urla, function(data){
  355. $(data.recenttracks.track).each(function(){
  356. tracks.push ({
  357. artist: this.artist["#text"],
  358. title: this.name,
  359. album: this.album["#text"]
  360. });
  361. });
  362. isLoadedr($this);
  363. });
  364. });
  365. };
  366. $('.recent').lfmr();
  367. $.fn.lfmtw = function(options){
  368. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=7day&format=json&limit=25";
  369. var tracks = [];
  370. function isLoadedt (tracksElement) {
  371. for (var i = 0; i < tracks.length; i++){
  372. 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>");
  373. tracksElement.append(markup);
  374. }
  375. }
  376. return this.each(function(){
  377. var $this = $(this);
  378. $.getJSON( urla, function(data){
  379. $(data.toptracks.track).each(function(){
  380. tracks.push ({
  381. title: this.name,
  382. artist: this.artist.name,
  383. played: this.playcount,
  384. });
  385. });
  386. isLoadedt($this);
  387. });
  388. });
  389. };
  390. $.fn.lfmaw = function(options){
  391. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=7day&format=json&limit=25";
  392. var artists = [];
  393. function isLoadeda (artistElement) {
  394. for (var i = 0; i < artists.length; i++){
  395. var markup = $("<li class='list-group-item'>" + artists[i].aname + "<span class='badge'>" + artists[i].played + "</span></li>");
  396. artistElement.append(markup);
  397. }
  398. }
  399. return this.each(function(){
  400. var $this = $(this);
  401. $.getJSON( urla, function(data){
  402. $(data.topartists.artist).each(function(){
  403. artists.push ({
  404. aname: this.name,
  405. played: this.playcount
  406. });
  407. });
  408. isLoadeda($this);
  409. });
  410. });
  411. };
  412. $('.wtracks').lfmtw();
  413. $('.wartists').lfmaw();
  414. $.fn.lfmtm = function(options){
  415. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=1month&format=json&limit=45";
  416. var tracks = [];
  417. function isLoadedt (tracksElement) {
  418. for (var i = 0; i < tracks.length; i++){
  419. 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>");
  420. tracksElement.append(markup);
  421. }
  422. }
  423. return this.each(function(){
  424. var $this = $(this);
  425. $.getJSON( urla, function(data){
  426. $(data.toptracks.track).each(function(){
  427. tracks.push ({
  428. title: this.name,
  429. artist: this.artist.name,
  430. played: this.playcount,
  431. });
  432. });
  433. isLoadedt($this);
  434. });
  435. });
  436. };
  437. $.fn.lfmam = function(options){
  438. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=1month&format=json&limit=45";
  439. var artists = [];
  440. function isLoadeda (artistElement) {
  441. for (var i = 0; i < artists.length; i++){
  442. var markup = $("<li class='list-group-item'>" + artists[i].aname + "<span class='badge'>" + artists[i].played + "</span></li>");
  443. artistElement.append(markup);
  444. }
  445. }
  446. return this.each(function(){
  447. var $this = $(this);
  448. $.getJSON( urla, function(data){
  449. $(data.topartists.artist).each(function(){
  450. artists.push ({
  451. aname: this.name,
  452. played: this.playcount
  453. });
  454. });
  455. isLoadeda($this);
  456. });
  457. });
  458. };
  459. $('.mtracks').lfmtm();
  460. $('.martists').lfmam();
  461. $.fn.lfma = function(options){
  462. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=6month&format=json&limit=50";
  463. var artists = [];
  464. function isLoadeda (artistElement) {
  465. for (var i = 0; i < artists.length; i++){
  466. var markup = $("<li class='list-group-item'>" + artists[i].aname + "<span class='badge'>" + artists[i].played + "</span></li>");
  467. artistElement.append(markup);
  468. }
  469. }
  470. return this.each(function(){
  471. var $this = $(this);
  472. $.getJSON( urla, function(data){
  473. $(data.topartists.artist).each(function(){
  474. artists.push ({
  475. aname: this.name,
  476. played: this.playcount
  477. });
  478. });
  479. isLoadeda($this);
  480. });
  481. });
  482. };
  483. $.fn.lfmt = function(options){
  484. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=6month&format=json&limit=50";
  485. var tracks = [];
  486. function isLoadedt (tracksElement) {
  487. for (var i = 0; i < tracks.length; i++){
  488. 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>");
  489. tracksElement.append(markup);
  490. }
  491. }
  492. return this.each(function(){
  493. var $this = $(this);
  494. $.getJSON( urla, function(data){
  495. $(data.toptracks.track).each(function(){
  496. tracks.push ({
  497. title: this.name,
  498. artist: this.artist.name,
  499. played: this.playcount,
  500. });
  501. });
  502. isLoadedt($this);
  503. });
  504. });
  505. };
  506. $('.artists').lfma();
  507. $('.tracks').lfmt();
  508. $.fn.lfya = function(options){
  509. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=12month&format=json&limit=50";
  510. var artists = [];
  511. function isLoadeda (artistElement) {
  512. for (var i = 0; i < artists.length; i++){
  513. var markup = $("<li class='list-group-item'>" + artists[i].aname + "<span class='badge'>" + artists[i].played + "</span></li>");
  514. artistElement.append(markup);
  515. }
  516. }
  517. return this.each(function(){
  518. var $this = $(this);
  519. $.getJSON( urla, function(data){
  520. $(data.topartists.artist).each(function(){
  521. artists.push ({
  522. aname: this.name,
  523. played: this.playcount
  524. });
  525. });
  526. isLoadeda($this);
  527. });
  528. });
  529. };
  530. $.fn.lfyt = function(options){
  531. var urla = "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=12month&format=json&limit=50";
  532. var tracks = [];
  533. function isLoadedt (tracksElement) {
  534. for (var i = 0; i < tracks.length; i++){
  535. 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>");
  536. tracksElement.append(markup);
  537. }
  538. }
  539. return this.each(function(){
  540. var $this = $(this);
  541. $.getJSON( urla, function(data){
  542. $(data.toptracks.track).each(function(){
  543. tracks.push ({
  544. title: this.name,
  545. artist: this.artist.name,
  546. played: this.playcount,
  547. });
  548. });
  549. isLoadedt($this);
  550. });
  551. });
  552. };
  553. $('.artists').lfya();
  554. $('.tracks').lfyt();
  555. $.fn.lfm = function(options){
  556. var url = "https://ws.audioscrobbler.com/2.0/?method=user.gettopalbums&user=windhamdavid&api_key=e12ea1d0253898ee9a93edfe42ffdeab&period=12month&format=json&limit=200";
  557. var albums = [];
  558. function isLoaded (albumElement) {
  559. for (var i = 0; i < albums.length; i++){
  560. 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>");
  561. albumElement.append(markup);
  562. }
  563. albumElement.find('.album').hover(function(){
  564. $(this).addClass('flip');
  565. },function(){
  566. $(this).removeClass('flip');
  567. });
  568. }
  569. return this.each(function(){
  570. var $this = $(this);
  571. $.getJSON( url, function(data){
  572. $(data.topalbums.album).each(function(){
  573. albums.push ({
  574. name: this.name,
  575. artist: this.artist.name,
  576. played: this.playcount,
  577. art: this.image[this.image.length-1]["#text"]
  578. });
  579. });
  580. isLoaded($this);
  581. });
  582. });
  583. };
  584. $('.albums').lfm();
  585. })( jQuery );
  586. /* ======= SAVE FOR LATER Icecast 2.4 upgrade to fix CORs headers @ http://64.207.154.37:8008/status2.xsl ========
  587. (function($){
  588. $.fn.icecast = function(options){
  589. $.ajaxSetup({
  590. cache:true,
  591. scriptCharset:"utf-8",
  592. contentType:"text/json;charset=utf-8"
  593. });
  594. var defaults = {
  595. server:"",
  596. stationlogo:""
  597. };
  598. var options = $.extend(defaults,options);
  599. return this.each(function(){var icecast = $(this);
  600. $.getJSON('http://'+options.server+'/status2.xsl',
  601. function(data){$.each(data.mounts,function(i,mount){
  602. $(icecast).append('<li class="mount"><div class="track">'+mount.title+'</div><div class="listeners">Listeners: '+mount.listeners+' at '+mount.bitrate+'kbps</div></li>');
  603. });
  604. });
  605. });
  606. };})(jQuery);
  607. $(function(){
  608. $('.mounts').icecast({server:"64.207.154.37:8008"});
  609. });
  610. */
  611. amplitude_config = {
  612. "amplitude_songs": [
  613. {
  614. "url": "https://stream.davidawindham.com/stream",
  615. "live": true
  616. }
  617. ],
  618. "amplitude_volume": 90
  619. }
  620. function get_radio_tower() {
  621. return '../../wp-content/themes/dw/img/radio.gif';
  622. }
  623. function get_radio_none() {
  624. return '../../wp-content/themes/dw/img/none.svg';
  625. }
  626. function get_radio_eq() {
  627. return '../../wp-content/themes/dw/img/eq.gif';
  628. }
  629. function get_radio_eq_none() {
  630. return '../../wp-content/themes/dw/img/1.png';
  631. }
  632. function radioTitle() {
  633. $('#radio').attr('src', get_radio_none()).fadeIn(300);
  634. $('#eq').attr('src', get_radio_eq_none()).fadeIn(300);
  635. var url = 'https://stream.davidawindham.com/status2.xsl';
  636. var mountpoint = '/stream';
  637. $.ajax({ type: 'GET',
  638. url: url,
  639. async: true,
  640. jsonpCallback: 'parseMusic',
  641. contentType: "application/json",
  642. dataType: 'jsonp',
  643. success: function (json) {
  644. $('#track').text(json[mountpoint].title);
  645. $('#listeners').text(json[mountpoint].listeners);
  646. $('#peak-listeners').text(json[mountpoint].peak_listeners);
  647. $('#bitrate').text(json[mountpoint].bitrate);
  648. $('#radio').attr('src', get_radio_tower()).fadeIn(300);
  649. $('#eq').attr('src', get_radio_eq()).fadeIn(300);
  650. },
  651. error: function (e) { console.log(e.message);
  652. $('#radio').attr('src', get_radio_none()).fadeIn(300);
  653. $('#eq').attr('src', get_radio_eq_none()).fadeIn(300);
  654. }
  655. });
  656. }
  657. $(document).ready(function () {
  658. setTimeout(function () {radioTitle();}, 2000);
  659. setInterval(function () {radioTitle();}, 30000); // update every 30 seconds
  660. });
  661. $('.nav-toggle').on('touchstart click', function(e) {
  662. e.preventDefault();
  663. $( this ).toggleClass( 'active' );
  664. });
  665. $(function dw_hidenav() {
  666. var headerHeight = $('.navbar').height();
  667. $(window).on('scroll', { previousTop: 0 },
  668. function() {
  669. var currentTop = $(window).scrollTop();
  670. if (currentTop < this.previousTop) {
  671. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  672. $('.navbar').addClass('visible');
  673. } else {
  674. $('.navbar').removeClass('visible fixed');
  675. }
  676. }
  677. else {
  678. $('.navbar').removeClass('visible');
  679. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  680. }
  681. this.previousTop = currentTop;
  682. }
  683. );
  684. });