diff options
author | Valentin Popov <info@valentineus.link> | 2018-05-31 05:02:59 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2018-05-31 05:02:59 +0300 |
commit | ba9dd452f2b6675a1065b2ca08354b026958b1ab (patch) | |
tree | bff259ce13dafca99b2be42797d18418c391f821 /assets/javascript | |
parent | 7107d7e464d7bd33c8c27e7719da9dc1c630b663 (diff) | |
download | obs-somafm_current_track-ba9dd452f2b6675a1065b2ca08354b026958b1ab.tar.xz obs-somafm_current_track-ba9dd452f2b6675a1065b2ca08354b026958b1ab.zip |
Added the ability to use different radio stations
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'assets/javascript')
-rw-r--r-- | assets/javascript/script.js | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/assets/javascript/script.js b/assets/javascript/script.js index f2eb794..c955567 100644 --- a/assets/javascript/script.js +++ b/assets/javascript/script.js @@ -1,6 +1,26 @@ '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 * @description Updates the data on the page. Displays a pop-up window if the @@ -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 () { |