From e4a875c64445b6ae45084376e50de274028e96d1 Mon Sep 17 00:00:00 2001 From: Fovway Date: Sun, 9 Mar 2025 12:36:45 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exit.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ reload.js | 32 ++++++++++++++++++++++++++++++++ source.js | 36 ++++++++++++++++++++++++++++++++++++ vote-color.js | 23 +++++++++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 exit.js create mode 100644 reload.js create mode 100644 source.js create mode 100644 vote-color.js diff --git a/exit.js b/exit.js new file mode 100644 index 0000000..b5881b8 --- /dev/null +++ b/exit.js @@ -0,0 +1,51 @@ +function sourceChange() { + + document.querySelector('.head__actions').insertAdjacentHTML( + 'beforeend', + `
+ +
` + ); + + document.querySelector('.source-btn').addEventListener('click', function() { + if (Lampa.Platform.is('apple_tv')) + window.location.assign('exit://exit'); + if (Lampa.Platform.is("tizen")) + tizen.application.getCurrentApplication().exit(); + if (Lampa.Platform.is("webos")) window.close(); + if (Lampa.Platform.is("android")) Lampa.Android.exit(); + if (Lampa.Platform.is("orsay")) Lampa.Orsay.exit(); + if (Lampa.Platform.is("nw")) nw.Window.get().close(); + }); + document.querySelector('.source-btn').addEventListener('touchend', function() { + if (Lampa.Platform.is('apple_tv')) + window.location.assign('exit://exit'); + if (Lampa.Platform.is("tizen")) + tizen.application.getCurrentApplication().exit(); + if (Lampa.Platform.is("webos")) window.close(); + if (Lampa.Platform.is("android")) Lampa.Android.exit(); + if (Lampa.Platform.is("orsay")) Lampa.Orsay.exit(); + if (Lampa.Platform.is("nw")) nw.Window.get().close(); + }); + document.querySelector('.source-btn').addEventListener('keydown', + function(event) { + if (event.key === 'Enter') { + if (Lampa.Platform.is('apple_tv')) + window.location.assign('exit://exit'); + if (Lampa.Platform.is("tizen")) + tizen.application.getCurrentApplication().exit(); + if (Lampa.Platform.is("webos")) window.close(); + if (Lampa.Platform.is("android")) Lampa.Android.exit(); + if (Lampa.Platform.is("orsay")) Lampa.Orsay.exit(); + if (Lampa.Platform.is("nw")) nw.Window.get().close(); + } + }); +} +if (window.appready) start(); +else { + Lampa.Listener.follow('app', function(e) { + if (e.type == 'ready') { + sourceChange(); + } + }); +} \ No newline at end of file diff --git a/reload.js b/reload.js new file mode 100644 index 0000000..2c967e9 --- /dev/null +++ b/reload.js @@ -0,0 +1,32 @@ +function reloadApp() { + document.querySelector('.head__actions').insertAdjacentHTML( + 'beforeend', + `
+ + + +
` + + ); + + document.querySelector('.reload--btn').addEventListener('click', function() { + location.reload(); + }); + document.querySelector('.reload--btn').addEventListener('touchend', function() { + location.reload(); + }); + document.querySelector('.reload--btn').addEventListener('keydown', + function(event) { + if(event.key === 'Enter') { + location.reload(); + } + }); +} +if (window.appready) start(); +else { + Lampa.Listener.follow('app', function(e) { + if (e.type == 'ready') { + reloadApp(); + } + }); +} \ No newline at end of file diff --git a/source.js b/source.js new file mode 100644 index 0000000..56dd898 --- /dev/null +++ b/source.js @@ -0,0 +1,36 @@ +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(); + } + }); +} \ No newline at end of file diff --git a/vote-color.js b/vote-color.js new file mode 100644 index 0000000..c305926 --- /dev/null +++ b/vote-color.js @@ -0,0 +1,23 @@ +function updateVoteColors() { + document.querySelectorAll(".card__vote").forEach(voteElement => { + const vote = parseFloat(voteElement.textContent.trim()); + + if (vote >= 0 && vote <= 3) { + voteElement.style.color = "red"; + } else if (vote >= 3 && vote <= 5.9) { + voteElement.style.color = "orange"; + } else if (vote >= 6 && vote <= 7.9) { + voteElement.style.color = "cornflowerblue"; + } else if (vote >= 8 && vote <= 10) { + voteElement.style.color = "lawngreen"; + } + }); +} + +document.addEventListener("DOMContentLoaded", function () { + setTimeout(updateVoteColors, 500); +}); + +// Следим за изменениями в контейнере с карточками +const observer = new MutationObserver(updateVoteColors); +observer.observe(document.body, { childList: true, subtree: true });