Created
May 27, 2026 18:18
-
-
Save Tonich333/69a17f8167dd80f0bdedb8e5fa054167 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; | |
| 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; }' | |
| ].join(' '); | |
| document.head.appendChild(style); | |
| console.log('Ящик 1 - стили: ОК'); | |
| Lampa.Component.add('mystic_screen', function(object) { | |
| var self = this; | |
| this.create = function() { | |
| console.log('Экран создан!'); | |
| var wrap = document.createElement('div'); | |
| wrap.className = 'mystic-wrap'; | |
| var loading = document.createElement('div'); | |
| loading.className = 'mystic-loading'; | |
| loading.textContent = 'Загружаем мистику...'; | |
| wrap.appendChild(loading); | |
| self.html = $(wrap); | |
| loadMovies(); | |
| return self.html; | |
| }; | |
| this.start = function() { console.log('Экран запущен!'); }; | |
| this.pause = function() {}; | |
| this.stop = function() {}; | |
| this.destroy = function() { if (self.html) self.html.remove(); }; | |
| this.back = function() { Lampa.Activity.back(); }; | |
| }); | |
| console.log('Ящик 2 - экран: ОК'); | |
| Lampa.Listener.follow('menu', function(e) { | |
| if (e.type === 'start') { | |
| var li = document.createElement('li'); | |
| var a = document.createElement('a'); | |
| a.textContent = 'Мистика'; | |
| li.appendChild(a); | |
| var myButton = $(li); | |
| e.body.append(myButton); | |
| myButton.on('click', function() { | |
| console.log('Открываем Мистику!'); | |
| Lampa.Activity.push({ | |
| component: 'mystic_screen', | |
| title: 'Мистика с 50-х' | |
| }); | |
| }); | |
| } | |
| }); | |
| console.log('Ящик 3 - меню: ОК'); | |
| 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); | |
| var errDiv = document.createElement('div'); | |
| errDiv.style.color = 'red'; | |
| errDiv.style.padding = '40px'; | |
| errDiv.style.fontSize = '18px'; | |
| errDiv.textContent = 'Ошибка загрузки!'; | |
| document.querySelector('.mystic-wrap').appendChild(errDiv); | |
| } | |
| }); | |
| } | |
| console.log('Ящик 4 - загрузка: ОК'); | |
| function showMovies(movies) { | |
| console.log('Рисуем карточки...'); | |
| var container = document.querySelector('.mystic-wrap'); | |
| container.innerHTML = ''; | |
| var title = document.createElement('div'); | |
| title.className = 'mystic-title'; | |
| title.textContent = 'Мистика с 50-х годов'; | |
| container.appendChild(title); | |
| var grid = document.createElement('div'); | |
| grid.className = 'mystic-grid'; | |
| 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 = document.createElement('div'); | |
| card.className = 'mystic-card selector'; | |
| var img = document.createElement('img'); | |
| img.src = poster; | |
| img.alt = movie.title; | |
| var cardTitle = document.createElement('div'); | |
| cardTitle.className = 'mystic-card__title'; | |
| cardTitle.textContent = movie.title; | |
| var cardYear = document.createElement('div'); | |
| cardYear.className = 'mystic-card__year'; | |
| cardYear.textContent = year; | |
| var cardRating = document.createElement('div'); | |
| cardRating.className = 'mystic-card__rating'; | |
| cardRating.textContent = rating; | |
| card.appendChild(img); | |
| card.appendChild(cardTitle); | |
| card.appendChild(cardYear); | |
| card.appendChild(cardRating); | |
| $(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.appendChild(card); | |
| }); | |
| container.appendChild(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