Created
May 27, 2026 18:14
-
-
Save Tonich333/d3ad5474e90121083cc1518c4c7b9463 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; }\ | |
| '; | |
| document.head.appendChild(style); | |
| console.log('Ящик 1 - стили: ОК'); | |
| Lampa.Component.add('mystic_screen', function(object) { | |
| var self = 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; | |
| }; | |
| 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 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 - меню: ОК'); | |
| 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 - загрузка: ОК'); | |
| 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