Performance improvement
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
parent
998e30d5b2
commit
35f87f6dbe
@ -2,9 +2,13 @@
|
|||||||
|
|
||||||
var client = new XMLHttpRequest();
|
var client = new XMLHttpRequest();
|
||||||
var channel = findGetParameter('channel');
|
var channel = findGetParameter('channel');
|
||||||
var url = '//somafm.com/songs/' + channel + '.xml';
|
var duration = getInterval('duration');
|
||||||
|
var interval = getInterval('interval');
|
||||||
|
|
||||||
/* Processes response */
|
/**
|
||||||
|
* @function
|
||||||
|
* @description Processes the incoming packet.
|
||||||
|
*/
|
||||||
client.onload = function () {
|
client.onload = function () {
|
||||||
if (client.readyState === client.DONE) {
|
if (client.readyState === client.DONE) {
|
||||||
if (this.status === 200 && this.responseXML !== null) {
|
if (this.status === 200 && this.responseXML !== null) {
|
||||||
@ -29,19 +33,24 @@ client.onload = function () {
|
|||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
/* Removes a pop-up window */
|
/* Removes a pop-up window */
|
||||||
displayElement.style['animation-name'] = 'fadeOut';
|
displayElement.style['animation-name'] = 'fadeOut';
|
||||||
}, getInterval('duration'));
|
}, duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Update cycle */
|
/**
|
||||||
setInterval(function () {
|
* @function
|
||||||
client.open('GET', url);
|
* @description Cyclical sending a request to update the information.
|
||||||
|
*/
|
||||||
|
setInterval(function tick() {
|
||||||
|
client.open('GET', '//somafm.com/songs/' + channel + '.xml');
|
||||||
client.send();
|
client.send();
|
||||||
}, getInterval('interval'));
|
return tick;
|
||||||
|
}(), interval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @function
|
||||||
* @param {String} parameterName - Variable name
|
* @param {String} parameterName - Variable name
|
||||||
* @returns {String} Value of variable
|
* @returns {String} Value of variable
|
||||||
* @description Searches for the value of the GET variable on the page.
|
* @description Searches for the value of the GET variable on the page.
|
||||||
@ -62,6 +71,7 @@ function findGetParameter(parameterName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @function
|
||||||
* @param {String} parameterName - Variable name
|
* @param {String} parameterName - Variable name
|
||||||
* @returns {Number} Timer value, default 10 seconds
|
* @returns {Number} Timer value, default 10 seconds
|
||||||
* @description Gets the settings for the specified timer.
|
* @description Gets the settings for the specified timer.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user