Advertisement
D3vBl4ck

player

Sep 16th, 2019
17,966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.  
  3.     function wrap_list_input() {
  4.         $('.thumbsU').html(0);
  5.         $('.thumbsD').html(0);
  6.         $('.likes').attr('data-postid', 0);
  7.         $('.top').attr('data-postid', 0);
  8.         $('.top').attr('data-score', 0);
  9.         $('.bottom').attr('data-postid', 0);
  10.         $('.bottom').attr('data-score', 0);
  11.         $('.player .img img').fadeOut('slow', function () {
  12.             $('.player .img img').attr('src', artistTrack);
  13.             $('.player .img img').fadeIn('slow');
  14.         });
  15.         $('.comingUp span').html("");
  16.         /** @type {number} */
  17.         currentRelations = 0;
  18.         /** @type {number} */
  19.         newPath = 0;
  20.         /** @type {number} */
  21.         outFile = 0;
  22.     }
  23.  
  24.     var result;
  25.     var artistTrack = "images/logo.png";
  26.     /** @type {boolean} */
  27.     var _0x8879x4 = true;
  28.     /** @type {number} */
  29.     var currentRelations = 0;
  30.     /** @type {number} */
  31.     var newPath = 0;
  32.     /** @type {number} */
  33.     var outFile = 0;
  34.     startRadio();
  35.     $('#coveriTunes').click(function () {
  36.         if (result != undefined) {
  37.             window.open(result);
  38.             return false;
  39.         }
  40.     });
  41.     if (_0x8879x4 == true) {
  42.         $('.top').click(function () {
  43.             var addedRelations = currentRelations;
  44.             var origNewPath = newPath;
  45.             if (!($(this).parent().hasClass('.disabled'))) {
  46.                 if ($(this).data('action') == 'up') {
  47.                     $(this).parent().find('.thumbsU').html(++origNewPath);
  48.                     $('.player .img img').attr('src', 'images/thankyou.png');
  49.                     $('.comingUp span').html("Voto registado. Gracias.");
  50.                     $.ajax({
  51.                         data: {
  52.                             "postid": addedRelations,
  53.                             "action": 'up'
  54.                         }
  55.                     });
  56.                 }
  57.             } else {
  58.                 $('.comingUp span').html('Un solo voto basta. Gracias.');
  59.             }
  60.         });
  61.         $('.bottom').click(function () {
  62.             var addedRelations = currentRelations;
  63.             var originalOutFile = outFile;
  64.             if (!($(this).parent().hasClass('.disabled'))) {
  65.                 if ($(this).data('action') == "down") {
  66.                     $(this).parent().find('.thumbsD').html(++originalOutFile);
  67.                     $('.player .img img').attr('src', 'images/thankyou.png');
  68.                     $('.comingUp span').html("Voto registado. Gracias");
  69.                     $.ajax({
  70.                         data: {
  71.                             "postid": addedRelations,
  72.                             "action": 'down'
  73.                         }
  74.                     });
  75.                 }
  76.             } else {
  77.                 $('.comingUp span').html("Un solo voto basta. Gracias.");
  78.             }
  79.         });
  80.     }
  81.     $('.controls').on('click', '.play', function () {
  82.         $(this).addClass('pause');
  83.         $(this).removeClass('play');
  84.     });
  85.     $('.controls').on('click', '.pause', function () {
  86.         $(this).removeClass('pause');
  87.         $(this).addClass('play');
  88.     });
  89.     $('.controls').on('click', '.muteoff', function () {
  90.         $(this).removeClass('muteoff');
  91.         $(this).addClass('muteon');
  92.     });
  93.     $('.controls').on('click', '.muteon', function () {
  94.         $(this).removeClass('muteon');
  95.         $(this).addClass('muteoff');
  96.     });
  97. });
  98. /**
  99.  * @return {undefined}
  100.  */
  101. function startRadio() {
  102.     $('#playBtn').hide();
  103.     grabRadioInfo();
  104.     /** @type {number} */
  105.     radioInfoInterval = setInterval(grabRadioInfo, 25E3);
  106. }
  107. /**
  108.  * @return {undefined}
  109.  */
  110. function grabRadioInfo() {
  111.     var requestOrUrl = 'song.php';
  112.     $.ajax({
  113.         type: "POST",
  114.         url: requestOrUrl,
  115.         data: {},
  116.         dataType: "xml",
  117.         success: function (str) {
  118.             xmldoc = $(str);
  119.             xmldoc.find('data').each(function (canCreateDiscussions, delete_behavior_form) {
  120.                 key = $(delete_behavior_form).find('name').text();
  121.                 val = $(delete_behavior_form).find('value').text();
  122.                 if (key == "Current Song") {
  123.                     var _alarm = val.split('-');
  124.                     var _0x8879x17 = _alarm[0] != undefined ? _alarm[0] : "";
  125.                     var _0x8879x18 = _alarm[1] != undefined ? _alarm[1] : "";
  126.                     var _0x8879x19 = $('#artist').text();
  127.                     $('#song').text(_0x8879x18.trim());
  128.                     if (_0x8879x19 != _0x8879x17.trim()) {
  129.                         $('#artist').text(_0x8879x17.trim());
  130.                         Album(_0x8879x17.trim());
  131.                     }
  132.                 }
  133.             });
  134.         },
  135.         error: function (deleted_model, err, op) {
  136.             if (deleted_model.readyState == 4) {
  137.                 $('#artist').text('Musica');
  138.                 $('#song').text('various artistas');
  139.                 Album("");
  140.             } else {
  141.                 if (deleted_model.readyState == 0) {
  142.                 } else {
  143.                 }
  144.             }
  145.         }
  146.     });
  147. }
  148. /**
  149.  * @param {?} amgArtistId
  150.  * @return {undefined}
  151.  */
  152. function Album(amgArtistId) {
  153.     var requestOrUrl = "https://ws.audioscrobbler.com/2.0/";
  154.     if (location.protocol == "http:") {
  155.         requestOrUrl = requestOrUrl.replace('https:', 'http:');
  156.     } else {
  157.         requestOrUrl = requestOrUrl.replace('http:', 'https:');
  158.     }
  159.     art = amgArtistId.trim();
  160.     $.ajax({
  161.         url: requestOrUrl,
  162.         data: {
  163.             method: "artist.getinfo",
  164.             artist: art,
  165.             api_key: "4d8eb4ccf7af1cfb1edcc6e70c5a262b",
  166.             format: "json"
  167.         },
  168.         dataType: "json",
  169.         success: function (inRevIdx) {
  170.             bg_image = "images/nocover.jpg";
  171.             if (inRevIdx.artist == undefined) {
  172.                 $('#artwork').attr('src', artistTrack);
  173.                 $('#artwork').attr('src', 'images/nocover.jpg');
  174.             } else {
  175.                 var artistTrack = inRevIdx.artist.image[2]["#text"];
  176.                 if (location.protocol == "http:") {
  177.                     artistTrack = artistTrack.replace('https:', 'http:');
  178.                 } else {
  179.                     artistTrack = artistTrack.replace('http:', 'https:');
  180.                 }
  181.                 if (artistTrack.trim() != "") {
  182.                     $('#artwork').attr('src', artistTrack);
  183.                     bg_image = artistTrack;
  184.                 } else {
  185.                     $('#artwork').attr('src', 'images/nocover.jpg');
  186.                     bg_image = 'images/nocover.jpg';
  187.                 }
  188.             }
  189.             $('#artwork').css('background-repeat', 'no-repeat');
  190.             $('#artwork').fadeOut(1E3, function () {
  191.                 $('#artwork').css('background', 'url("' + bg_image +'")');
  192.                 //todo bien
  193.                 $('#artwork').css('background-size', 'cover');
  194.                 $('#artwork').fadeIn(1E3, function () {
  195.                     $('#artwork').css('background-size', 'cover');
  196.                 });
  197.             });
  198.             $('#artwork').css('background-position', '-100px -100px');
  199.             artistTrack = document.createElement('img');
  200.             artistTrack.setAttribute('crossorigin', "");
  201.             artistTrack.src = bg_image;
  202.             artistTrack.style.display = "none";
  203.             document.body.appendChild(artistTrack);
  204.             /** @type {number} */
  205.             var deltaY = 0;
  206.             /**
  207.              * @return {undefined}
  208.              */
  209.             artistTrack.onload = function () {
  210.                 var a = document.createElement('canvas');
  211.                 a.width = this.width;
  212.                 a.height = this.height;
  213.                 var globalAjaxOptions = a.getContext('2d');
  214.                 globalAjaxOptions.drawImage(this, 0, 0);
  215.                 var test_data = globalAjaxOptions.getImageData(0, 0, a.width, a.height);
  216.                 var data = test_data.data;
  217.                 var offset;
  218.                 var musicplaylistload;
  219.                 var name;
  220.                 var acceleration;
  221.                 /** @type {number} */
  222.                 for (i=0; i < data.length; i = i + 4) {
  223.                     offset = data[i];
  224.                     musicplaylistload = data[i + 1];
  225.                     name = data[i + 2];
  226.                     acceleration = Math.floor((offset + musicplaylistload + name) / 3);
  227.                     deltaY = deltaY + acceleration;
  228.                 }
  229.                 var rule_id = Math.floor(Math.random() * 999999 + 5);
  230.                 if (Math.floor(deltaY / (this.width * this.height)) > 170) {
  231.                     var filter_value_container_id = "js/dark.css?r=" + rule_id;
  232.                     $('#pstyle[rel=stylesheet]').attr('href', filter_value_container_id);
  233.                 } else {
  234.                     filter_value_container_id = "js/dark.light?r=" + rule_id;
  235.                     $('#pstyle[rel=stylesheet]').attr('href', filter_value_container_id);
  236.                 }
  237.             };
  238.         }
  239.     });
  240. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement