Created
May 27, 2026 18:00
-
-
Save Tonich333/646e279d0aa6bede9b6865aee591fa9d to your computer and use it in GitHub Desktop.
Mystic Cinema Plugin for Lampa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| // Защита от двойной загрузки | |
| if (window.mysticLoaded) return; | |
| window.mysticLoaded = true; | |
| //================================ | |
| // 🗃️ ЯЩИК 1 — Стили CSS | |
| //================================ | |
| var style = document.createElement('style'); | |
| style.innerHTML = ` | |
| .mystic-wrap { | |
| padding: 20px; | |
| background: #0d0d1a; | |
| min-height: 100%; | |
| } | |
| .mystic-title { | |
| color: #b388ff; | |
| font-size: 26px; | |
| margin-bottom: 20px; | |
| } | |
| .mystic-grid { | |
| display: flex; | |
| flex-wrap: wrap; | |
| gap: 15px; | |
| } | |
| .mystic-card { | |
| width: 150px; | |
| background: #1a1a2e; | |
| border-radius: 8px; | |
| overflow: hidden; | |
| cursor: pointer; | |
| border: 2px solid transparent; | |
| } | |
| .mystic-card:hover { | |
| border-color: #b388ff; | |
| } | |
| .mystic-card img { | |
| width: 100%; | |
| height: 220px; | |
| object-fit: cover; | |
| } | |
| .mystic-card__title { | |
| color: white; | |
| font-size: 12px; | |
| padding: 5px; | |
| } | |
| .mystic-card__year { | |
| color: #aaa; | |
| font-size: 11px; | |
| padding: 0 5px; | |
| } | |
| .mystic-card__rating { | |
| color: gold; | |
| font-size: 12px; | |
| padding: 5px; | |
| } | |
| .mystic-loading { | |
| color: #b388ff; | |
| font-size: 22px; | |
| text-align: center; | |
| padding: 60px; | |
| } | |
| `; | |
| document.head.appendChild(style); | |
| console.log('🗃️ Ящик 1 - стили: ОК'); | |
| //================================ | |
| // 🗃️ ЯЩИК 2 — Регистрируем экран | |
| //================================ | |
| Lampa.Component.add('mystic_screen', function(object) { | |
| var self = this; // ← сохраняем правильный this! | |
| this.create = function() { | |
| console.log('👻 Экран создан!'); | |
| // Создаём контейнер с загрузкой | |
| self.html = $('<div class="mystic-wrap"></div>'); | |
| self.html.html( | |
| '<div class="mystic-loading">🔮 Загружаем мистику...</div>' | |
| ); | |
| loadMovies(); // запускаем загрузку фильмов | |
| return self.html; // ← ВАЖНО! Lampa ждёт это! | |
| }; | |
| this.start = function() { | |
| console.log('▶️ Экран запущен!'); | |
| // Lampa сама вызывает start() — не трогаем! | |
| }; | |
| this.pause = function() {}; // ← Lampa требует | |
| this.stop = function() {}; // ← Lampa требует | |
| this.destroy = function() { | |
| console.log('🗑️ Экран закрыт'); | |
| if (self.html) self.html.remove(); // ← безопасно | |
| }; | |
| this.back = function() { | |
| Lampa.Activity.back(); // ← кнопка назад | |
| }; | |
| }); | |
| console.log('🗃️ Ящик 2 - экран: ОК'); | |
| //================================ | |
| // 🗃️ ЯЩИК 3 — Кнопка в меню | |
| //================================ | |
| Lampa.Listener.follow('menu', function(e) { | |
| if (e.type === 'start') { | |
| var myButton = $('<li></li>'); | |
| myButton.html('<a>👻 Мистика</a>'); | |
| e.body.append(myButton); | |
| myButton.on('click', function() { | |
| console.log('🖱️ Открываем Мистику!'); | |
| Lampa.Activity.push({ | |
| component: 'mystic_screen', | |
| title: '👻 Мистика с 50-х' | |
| }); | |
| }); | |
| } | |
| }); | |
| console.log('🗃️ Ящик 3 - меню: ОК'); | |
| //================================ | |
| // 🗃️ ЯЩИК 4 — Загрузка фильмов | |
| //================================ | |
| function loadMovies() { | |
| console.log('📡 Запрос в TMDB...'); | |
| var url = Lampa.TMDB.api('discover/movie', { | |
| with_genres: '27,9648', | |
| 'primary_release_date.gte': '1950-01-01', | |
| 'vote_average.gte': '7', | |
| 'vote_count.gte': '200', | |
| sort_by: 'vote_average.desc', | |
| language: 'ru-RU', | |
| page: 1 | |
| }); | |
| $.ajax({ | |
| url: url, | |
| success: function(data) { | |
| console.log('✅ Фильмов найдено:', data.results.length); | |
| showMovies(data.results); | |
| }, | |
| error: function(err) { | |
| console.log('❌ Ошибка запроса:', err); | |
| $('.mystic-wrap').html( | |
| '<div style="color:red;padding:40px;font-size:18px">❌ Ошибка загрузки!</div>' | |
| ); | |
| } | |
| }); | |
| } | |
| console.log('🗃️ Ящик 4 - загрузка: ОК'); | |
| //================================ | |
| // 🗃️ ЯЩИК 5 — Рисуем карточки | |
| //================================ | |
| function showMovies(movies) { | |
| console.log('🎨 Рисуем карточки...'); | |
| var container = $('.mystic-wrap'); | |
| container.html(''); // очищаем загрузку | |
| // Заголовок | |
| container.append( | |
| '<div class="mystic-title">👻 Мистика с 50-х годов</div>' | |
| ); | |
| // Сетка | |
| var grid = $('<div class="mystic-grid"></div>'); | |
| movies.forEach(function(movie) { | |
| var poster = movie.poster_path | |
| ? 'https://image.tmdb.org/t/p/w300' + movie.poster_path | |
| : ''; | |
| var year = movie.release_date | |
| ? movie.release_date.substring(0, 4) | |
| : '—'; | |
| var rating = movie.vote_average | |
| ? movie.vote_average.toFixed(1) | |
| : '?'; | |
| var card = $('<div class="mystic-card selector"></div>'); | |
| card.html(` | |
| <img src="${poster}" alt="${movie.title}"> | |
| <div class="mystic-card__title">${movie.title}</div> | |
| <div class="mystic-card__year">📅 ${year}</div> | |
| <div class="mystic-card__rating">⭐ ${rating}</div> | |
| `); | |
| // Клик — открываем страницу фильма | |
| card.on('click', function() { | |
| console.log('🎬 Открываем:', movie.title); | |
| Lampa.Activity.push({ | |
| url: Lampa.TMDB.api('movie/' + movie.id), | |
| component: 'full', | |
| id: movie.id, | |
| method: 'movie', | |
| media_type: 'movie', | |
| title: movie.title | |
| }); | |
| }); | |
| grid.append(card); | |
| }); | |
| container.append(grid); | |
| console.log('✅ Карточки нарисованы!'); | |
| } | |
| console.log('🗃️ Ящик 5 - карточки: ОК'); | |
| //================================ | |
| // 🚀 ЗАПУСК | |
| //================================ | |
| function startPlugin() { | |
| console.log('🔮 Плагин МИСТИКА запускается...'); | |
| console.log('✅ Готов к работе!'); | |
| } | |
| if (window.appready) { | |
| startPlugin(); | |
| } else { | |
| Lampa.Listener.follow('app', function(e) { | |
| if (e.type === 'ready') startPlugin(); | |
| }); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment