function sourceChanger() {
document.querySelector(".head__actions").insertAdjacentHTML(
"beforeend",
`
`
);
const sourceList = ["tmdb", "cub", "MIX", "MIX KIDS", "MIX RUS"];
document.querySelector(".source--btn").addEventListener("click", function () {
const sourceStorage = Lampa.Storage.get("source");
const index = sourceList.indexOf(sourceStorage);
if (index !== -1) {
let nextIndex = index + 1;
if (nextIndex >= sourceList.length) {
nextIndex = 0;
}
Lampa.Storage.set("source", sourceList[nextIndex]);
console.log(`Источник изменен на: ${sourceList[nextIndex]}`);
} else {
// Если текущий источник отсутствует в массиве, ставим первый
Lampa.Storage.set("source", sourceList[0]);
console.log(`Источник сброшен на: ${sourceList[0]}`);
}
});
}
if (window.appready) start();
else {
Lampa.Listener.follow('app', function(e) {
if (e.type == 'ready') {
sourceChanger();
}
});
}