Commit f589193e authored by Sidorela Uku's avatar Sidorela Uku
Browse files

removed not needed code js

parent c241d7d0
Pipeline #994 passed with stage
in 14 seconds
......@@ -79,123 +79,123 @@ function Page() {
}
}
this.refreshHistoric = function (info, n) {
var $historicDiv = document.querySelectorAll('#historicSong article');
var $songName = document.querySelectorAll('#historicSong article .music-info .song');
var $artistName = document.querySelectorAll('#historicSong article .music-info .artist');
// Default cover art
var urlCoverArt = 'img/bg-capa.jpg';
// Get cover art for song history
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
var data = JSON.parse(this.responseText);
var artworkUrl100 = (data.resultCount) ? data.results[0].artworkUrl100 : urlCoverArt;
document.querySelectorAll('#historicSong article .cover-historic')[n].style.backgroundImage = 'url(' + artworkUrl100 + ')';
}
// Formating characters to UTF-8
var music = info.song.replace(/'/g, '\'');
var songHist = music.replace(/&/g, '&');
var artist = info.artist.replace(/'/g, '\'');
var artistHist = artist.replace(/&/g, '&');
$songName[n].innerHTML = songHist;
$artistName[n].innerHTML = artistHist;
// Add class for animation
$historicDiv[n].classList.add('animated');
$historicDiv[n].classList.add('slideInRight');
}
xhttp.open('GET', 'https://itunes.apple.com/search?term=' + info.artist + ' ' + info.song + '&media=music&limit=1', true);
xhttp.setRequestHeader("Content-Type", "audio/mpeg");
xhttp.send();
setTimeout(function () {
for (var j = 0; j < 2; j++) {
$historicDiv[j].classList.remove('animated');
$historicDiv[j].classList.remove('slideInRight');
}
}, 2000);
}
this.refreshCover = function (song = '', artist) {
// Default cover art
var urlCoverArt = 'img/bg-capa.jpg';
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
var coverArt = document.getElementById('currentCoverArt');
var coverBackground = document.getElementById('bgCover');
// Get cover art URL on iTunes API
if (this.readyState === 4 && this.status === 200) {
var data = JSON.parse(this.responseText);
var artworkUrl100 = (data.resultCount) ? data.results[0].artworkUrl100 : urlCoverArt;
// Se retornar algum dado, alterar a resolução da imagem ou definir a padrão
urlCoverArt = (artworkUrl100 != urlCoverArt) ? artworkUrl100.replace('100x100bb', '512x512bb') : urlCoverArt;
var urlCoverArt96 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '96x96bb') : urlCoverArt;
var urlCoverArt128 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '128x128bb') : urlCoverArt;
var urlCoverArt192 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '192x192bb') : urlCoverArt;
var urlCoverArt256 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '256x256bb') : urlCoverArt;
var urlCoverArt384 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '384x384bb') : urlCoverArt;
coverArt.style.backgroundImage = 'url(' + urlCoverArt + ')';
coverArt.className = 'animated bounceInLeft';
coverBackground.style.backgroundImage = 'url(' + urlCoverArt + ')';
setTimeout(function () {
coverArt.className = '';
}, 2000);
if ('mediaSession' in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({
title: song,
artist: artist,
artwork: [{
src: urlCoverArt96,
sizes: '96x96',
type: 'image/png'
},
{
src: urlCoverArt128,
sizes: '128x128',
type: 'image/png'
},
{
src: urlCoverArt192,
sizes: '192x192',
type: 'image/png'
},
{
src: urlCoverArt256,
sizes: '256x256',
type: 'image/png'
},
{
src: urlCoverArt384,
sizes: '384x384',
type: 'image/png'
},
{
src: urlCoverArt,
sizes: '512x512',
type: 'image/png'
}
]
});
}
}
}
xhttp.open('GET', 'https://itunes.apple.com/search?term=' + artist + ' ' + song + '&media=music&limit=1', true);
xhttp.setRequestHeader("Content-Type", "audio/mpeg");
xhttp.send();
}
// this.refreshHistoric = function (info, n) {
// var $historicDiv = document.querySelectorAll('#historicSong article');
// var $songName = document.querySelectorAll('#historicSong article .music-info .song');
// var $artistName = document.querySelectorAll('#historicSong article .music-info .artist');
//
// // Default cover art
// var urlCoverArt = 'img/bg-capa.jpg';
//
// // Get cover art for song history
// var xhttp = new XMLHttpRequest();
// xhttp.onreadystatechange = function () {
// if (this.readyState === 4 && this.status === 200) {
// var data = JSON.parse(this.responseText);
// var artworkUrl100 = (data.resultCount) ? data.results[0].artworkUrl100 : urlCoverArt;
//
// document.querySelectorAll('#historicSong article .cover-historic')[n].style.backgroundImage = 'url(' + artworkUrl100 + ')';
// }
// // Formating characters to UTF-8
// var music = info.song.replace(/&apos;/g, '\'');
// var songHist = music.replace(/&amp;/g, '&');
//
// var artist = info.artist.replace(/&apos;/g, '\'');
// var artistHist = artist.replace(/&amp;/g, '&');
//
// $songName[n].innerHTML = songHist;
// $artistName[n].innerHTML = artistHist;
//
// // Add class for animation
// $historicDiv[n].classList.add('animated');
// $historicDiv[n].classList.add('slideInRight');
// }
// xhttp.open('GET', 'https://itunes.apple.com/search?term=' + info.artist + ' ' + info.song + '&media=music&limit=1', true);
// xhttp.setRequestHeader("Content-Type", "audio/mpeg");
// xhttp.send();
//
// setTimeout(function () {
// for (var j = 0; j < 2; j++) {
// $historicDiv[j].classList.remove('animated');
// $historicDiv[j].classList.remove('slideInRight');
// }
// }, 2000);
// }
//
// this.refreshCover = function (song = '', artist) {
// // Default cover art
// var urlCoverArt = 'img/bg-capa.jpg';
//
// var xhttp = new XMLHttpRequest();
// xhttp.onreadystatechange = function () {
// var coverArt = document.getElementById('currentCoverArt');
// var coverBackground = document.getElementById('bgCover');
//
// // Get cover art URL on iTunes API
// if (this.readyState === 4 && this.status === 200) {
// var data = JSON.parse(this.responseText);
// var artworkUrl100 = (data.resultCount) ? data.results[0].artworkUrl100 : urlCoverArt;
//
// // Se retornar algum dado, alterar a resolução da imagem ou definir a padrão
// urlCoverArt = (artworkUrl100 != urlCoverArt) ? artworkUrl100.replace('100x100bb', '512x512bb') : urlCoverArt;
// var urlCoverArt96 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '96x96bb') : urlCoverArt;
// var urlCoverArt128 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '128x128bb') : urlCoverArt;
// var urlCoverArt192 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '192x192bb') : urlCoverArt;
// var urlCoverArt256 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '256x256bb') : urlCoverArt;
// var urlCoverArt384 = (artworkUrl100 != urlCoverArt) ? urlCoverArt.replace('512x512bb', '384x384bb') : urlCoverArt;
//
// coverArt.style.backgroundImage = 'url(' + urlCoverArt + ')';
// coverArt.className = 'animated bounceInLeft';
//
// coverBackground.style.backgroundImage = 'url(' + urlCoverArt + ')';
//
// setTimeout(function () {
// coverArt.className = '';
// }, 2000);
//
// if ('mediaSession' in navigator) {
// navigator.mediaSession.metadata = new MediaMetadata({
// title: song,
// artist: artist,
// artwork: [{
// src: urlCoverArt96,
// sizes: '96x96',
// type: 'image/png'
// },
// {
// src: urlCoverArt128,
// sizes: '128x128',
// type: 'image/png'
// },
// {
// src: urlCoverArt192,
// sizes: '192x192',
// type: 'image/png'
// },
// {
// src: urlCoverArt256,
// sizes: '256x256',
// type: 'image/png'
// },
// {
// src: urlCoverArt384,
// sizes: '384x384',
// type: 'image/png'
// },
// {
// src: urlCoverArt,
// sizes: '512x512',
// type: 'image/png'
// }
// ]
// });
// }
// }
// }
// xhttp.open('GET', 'https://itunes.apple.com/search?term=' + artist + ' ' + song + '&media=music&limit=1', true);
// xhttp.setRequestHeader("Content-Type", "audio/mpeg");
// xhttp.send();
// }
this.changeVolumeIndicator = function (volume) {
document.getElementById('volIndicator').innerHTML = volume;
......@@ -213,38 +213,38 @@ function Page() {
}
}
this.refreshLyric = function (currentSong, currentArtist) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
var data = JSON.parse(this.responseText);
var openLyric = document.getElementsByClassName('lyrics')[0];
if (data.type === 'exact' || data.type === 'aprox') {
var lyric = data.mus[0].text;
document.getElementById('lyric').innerHTML = lyric.replace(/\n/g, '<br />');
openLyric.style.opacity = "1";
openLyric.setAttribute('data-toggle', 'modal');
} else {
openLyric.style.opacity = "0.3";
openLyric.removeAttribute('data-toggle');
var modalLyric = document.getElementById('modalLyrics');
modalLyric.style.display = "none";
modalLyric.setAttribute('aria-hidden', 'true');
(document.getElementsByClassName('modal-backdrop')[0]) ? document.getElementsByClassName('modal-backdrop')[0].remove(): '';
}
} else {
document.getElementsByClassName('lyrics')[0].style.opacity = "0.3";
document.getElementsByClassName('lyrics')[0].removeAttribute('data-toggle');
}
}
xhttp.open('GET', 'https://api.vagalume.com.br/search.php?apikey=' + API_KEY + '&art=' + currentArtist + '&mus=' + currentSong.toLowerCase(), true);
xhttp.setRequestHeader("Content-Type", "audio/mpeg");
xhttp.send()
}
// this.refreshLyric = function (currentSong, currentArtist) {
// var xhttp = new XMLHttpRequest();
// xhttp.onreadystatechange = function () {
// if (this.readyState === 4 && this.status === 200) {
// var data = JSON.parse(this.responseText);
//
// var openLyric = document.getElementsByClassName('lyrics')[0];
//
// if (data.type === 'exact' || data.type === 'aprox') {
// var lyric = data.mus[0].text;
//
// document.getElementById('lyric').innerHTML = lyric.replace(/\n/g, '<br />');
// openLyric.style.opacity = "1";
// openLyric.setAttribute('data-toggle', 'modal');
// } else {
// openLyric.style.opacity = "0.3";
// openLyric.removeAttribute('data-toggle');
//
// var modalLyric = document.getElementById('modalLyrics');
// modalLyric.style.display = "none";
// modalLyric.setAttribute('aria-hidden', 'true');
// (document.getElementsByClassName('modal-backdrop')[0]) ? document.getElementsByClassName('modal-backdrop')[0].remove(): '';
// }
// } else {
// document.getElementsByClassName('lyrics')[0].style.opacity = "0.3";
// document.getElementsByClassName('lyrics')[0].removeAttribute('data-toggle');
// }
// }
// xhttp.open('GET', 'https://api.vagalume.com.br/search.php?apikey=' + API_KEY + '&art=' + currentArtist + '&mus=' + currentSong.toLowerCase(), true);
// xhttp.setRequestHeader("Content-Type", "audio/mpeg");
// xhttp.send()
// }
}
var audio = new Audio(URL_STREAMING + '/;');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment