const el = function (id) {
return document.getElementById(id);
};
const dynamicContent = {
loadLabels: function (labels, mode) {
if (typeof labels["voteNumber"] != "undefined" && el("voteNumber")) {
el("voteNumber").innerText = labels["voteNumber"];
}
if (typeof labels["ctaBtnText"] != "undefined" && el("ctaBtnText")) {
el("ctaBtnText").innerText = labels["ctaBtnText"];
}
if (typeof labels["patronCounter"] != "undefined" && el("patronCounter")) {
if (typeof count != "undefined") {
count.update(labels["patronCounter"]);
} else {
el("patronCounter").innerText = labels["patronCounter"];
}
}
},
loadArchive: function (archive, mode) {
if (mode == "top") return;
let tempHtml = "";
archive.forEach((item) => {
const htmlTemplate = `
#${item.no}
${item.date}
`;
tempHtml += htmlTemplate;
});
el("archiveListItems").innerHTML = tempHtml;
el("chartArchive").style.display = "block";
},
loadTracks: function (mode) {
if (mode == "top") return;
const variants = [1, 2, 3, 4, 5]; //, 6, 7, 8, 9, 10];
const set = variants[Math.floor(Math.random() * variants.length)];
const xhr = new XMLHttpRequest();
xhr.open(
"GET",
"https://bocdn.radio357.pl/lp/lista/dynamicContent.php?tracks=" + set,
true
);
xhr.onload = function () {
let response = JSON.parse(this.response);
if (
typeof response != "undefined" &&
typeof response[0] != "undefined" &&
typeof response[0]["song"] != "undefined"
) {
let tempHtml = "";
let index = 1;
response.forEach((item) => {
const selectedClass = item.selected == "1" ? "selected" : "";
const htmlTemplate = `
${item.artist}
${item.song}
`;
index++;
tempHtml += htmlTemplate;
});
el("artistCloud").innerHTML = tempHtml;
el("artistCloud").style.display = "block";
}
};
xhr.onerror = function () {};
xhr.send();
},
};
if (typeof dynamicContent.loadLabels != 'undefined') dynamicContent.loadLabels({"voteNumber":"Notowanie #172","ctaBtnText":"Widzisz co\u015b dla siebie","patronCounter":"49866"}, "");
if (typeof dynamicContent.loadArchive != 'undefined') dynamicContent.loadArchive([{"link":"https:\/\/wyniki.radio357.pl\/lista\/171?ret=https%3A%2F%2Flista.radio357.pl","no":"171","date":"31.01.2025"},{"link":"https:\/\/wyniki.radio357.pl\/lista\/170?ret=https%3A%2F%2Flista.radio357.pl","no":"170","date":"24.01.2025"},{"link":"https:\/\/wyniki.radio357.pl\/lista\/169?ret=https%3A%2F%2Flista.radio357.pl","no":"169","date":"17.01.2025"}], "");
if (typeof dynamicContent.loadTracks != 'undefined') dynamicContent.loadTracks("");