Added the ability to use different radio stations

Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
Valentin Popov 2018-05-31 06:02:59 +04:00
parent 7107d7e464
commit ba9dd452f2
Signed by: Valentin Popov
GPG Key ID: 269A00ACA90A8EA3

View File

@ -1,5 +1,25 @@
'use strict';
/**
* @param {String} parameterName - Variable name
* @returns {String} Value of variable
* @description Searches for the value of the GET variable on the page.
*/
function findGetParameter(parameterName) {
var result = null;
var tmp = [];
var items = window.location.search.substr(1).split('&');
for (var index = 0; index < items.length; index++) {
tmp = items[index].split('=');
if (tmp[0] === parameterName) {
result = decodeURIComponent(tmp[1]);
}
}
return result;
}
/**
* @param {String} artistTrack - Artist of the track
* @param {String} titleTrack - Name of the track
@ -14,8 +34,8 @@ function updateData(artistTrack, titleTrack) {
if (artistElement.textContent !== artistTrack || titleElement.textContent !== titleTrack) {
/* Updates text */
artistElement.innerHTML = artistTrack;
titleElement.innerHTML = titleTrack;
artistElement.textContent = artistTrack;
titleElement.textContent = titleTrack;
/* Displays a pop-up window */
displayElement.style['animation-name'] = 'fadeIn';
@ -28,7 +48,8 @@ function updateData(artistTrack, titleTrack) {
}
var client = new XMLHttpRequest();
var url = 'https://somafm.com/songs/defcon.xml';
var radio = findGetParameter('radio');
var url = '//somafm.com/songs/' + radio + '.xml';
/* Processes response */
client.onload = function () {