PageSourceSearch

https://sol.vin/js/game_player.js

js sol.vin collected 2026-10-09 21:58:41 UTC 7,021 bytes, 192 lines download raw bytes

1(function() {
2  function initGamePlayer() {
3    const overlay = document.getElementById('game-player-modal-overlay');
4    const windowFrame = document.getElementById('game-player-window');
5    const iframe = document.getElementById('game-player-iframe');
6    const closeBtn = document.getElementById('game-player-close-btn');
7    const maximizeBtn = document.getElementById('game-player-maximize-btn');
8    const fullscreenBtn = document.getElementById('game-player-fullscreen-btn');
9
10    if (overlay && iframe) {
11      let isMaximized = false;
12      let currentOrientation = 'landscape';
13
14      function isSmallScreen() {
15        return window.innerWidth <= 600 || window.innerHeight <= 500;
16      }
17
18      async function applyOrientationLock(orientation) {
19        if (screen && screen.orientation && typeof screen.orientation.lock === 'function') {
20          try {
21            const lockType = (orientation === 'portrait') ? 'portrait' : 'landscape';
22            await screen.orientation.lock(lockType);
23          } catch (err) {
24            // Orientation locking might not be supported or allowed by user agent permissions
25          }
26        }
27      }
28
29      function releaseOrientationLock() {
30        if (screen && screen.orientation && typeof screen.orientation.unlock === 'function') {
31          try {
32            screen.orientation.unlock();
33          } catch (err) {}
34        }
35      }
36
37      function updateMaximizeText() {
38        const textEl = document.getElementById('maximize-btn-text');
39        if (textEl) {
40          textEl.textContent = isMaximized ? '[ RESTORE ]' : '[ MAXIMIZE ]';
41        }
42      }
43
44      function requestFullscreenMode(orientation) {
45        const targetOrientation = orientation || currentOrientation;
46        const elem = iframe;
47        if (!document.fullscreenElement && !document.webkitFullscreenElement) {
48          const req = elem.requestFullscreen ? elem.requestFullscreen() :
49                      elem.webkitRequestFullscreen ? elem.webkitRequestFullscreen() :
50                      elem.msRequestFullscreen ? elem.msRequestFullscreen() : null;
51
52          if (req && typeof req.then === 'function') {
53            req.then(function() {
54              applyOrientationLock(targetOrientation);
55            }).catch(function() {
56              applyOrientationLock(targetOrientation);
57            });
58          } else {
59            applyOrientationLock(targetOrientation);
60          }
61        }
62      }
63
64      function openPlayer(gameUrl, gameTitle, gameOrientation) {
65        currentOrientation = (gameOrientation === 'portrait') ? 'portrait' : 'landscape';
66        const titleEl = document.getElementById('game-player-modal-title');
67        if (titleEl) {
68          titleEl.textContent = gameTitle ? '[ GAME PLAYER // ' + gameTitle.toUpperCase() + ' ]' : '[ GAME PLAYER ]';
69        }
70        const src = gameUrl || iframe.getAttribute('data-src') || './shell.html';
71        iframe.src = src;
72        overlay.style.display = 'flex';
73        document.body.style.overflow = 'hidden';
74
75        if (isSmallScreen()) {
76          requestFullscreenMode(currentOrientation);
77        }
78
79        setTimeout(function() {
80          try { iframe.focus(); } catch(e) {}
81        }, 300);
82      }
83
84      function closePlayer() {
85        releaseOrientationLock();
86        if (document.fullscreenElement || document.webkitFullscreenElement) {
87          if (document.exitFullscreen) {
88            document.exitFullscreen().catch(function() {});
89          } else if (document.webkitExitFullscreen) {
90            document.webkitExitFullscreen();
91          }
92        }
93        overlay.style.display = 'none';
94        document.body.style.overflow = '';
95        iframe.src = 'about:blank';
96        if (isMaximized && windowFrame) {
97          windowFrame.classList.remove('maximized-window');
98          isMaximized = false;
99          updateMaximizeText();
100        }
101      }
102
103      function toggleMaximize() {
104        if (!windowFrame) return;
105        isMaximized = !isMaximized;
106        if (isMaximized) {
107          windowFrame.classList.add('maximized-window');
108        } else {
109          windowFrame.classList.remove('maximized-window');
110        }
111        updateMaximizeText();
112      }
113
114      function toggleFullscreen() {
115        if (!document.fullscreenElement && !document.webkitFullscreenElement) {
116          requestFullscreenMode(currentOrientation);
117        } else {
118          releaseOrientationLock();
119          if (document.exitFullscreen) {
120            document.exitFullscreen();
121          } else if (document.webkitExitFullscreen) {
122            document.webkitExitFullscreen();
123          }
124        }
125      }
126
127      document.addEventListener('fullscreenchange', function() {
128        if (!document.fullscreenElement && !document.webkitFullscreenElement) {
129          releaseOrientationLock();
130          if (isSmallScreen() && overlay.style.display !== 'none' && overlay.style.display !== '') {
131            closePlayer();
132          }
133        }
134      });
135
136      document.addEventListener('webkitfullscreenchange', function() {
137        if (!document.fullscreenElement && !document.webkitFullscreenElement) {
138          releaseOrientationLock();
139          if (isSmallScreen() && overlay.style.display !== 'none' && overlay.style.display !== '') {
140            closePlayer();
141          }
142        }
143      });
144
145      document.addEventListener('click', function(e) {
146        const trigger = e.target.closest('#launch-game-btn, .game-player
146-trigger');
147        if (trigger) {
148          e.preventDefault();
149          e.stopPropagation();
150          const gameUrl = trigger.getAttribute('data-game-url');
151          const gameTitle = trigger.getAttribute('data-game-title');
152          const gameOrientation = trigger.getAttribute('data-game-orientation') || 'landscape';
153          openPlayer(gameUrl, gameTitle, gameOrientation);
154        }
155      });
156
157      if (closeBtn) closeBtn.addEventListener('click', closePlayer);
158      if (maximizeBtn) maximizeBtn.addEventListener('click', toggleMaximize);
159      if (fullscreenBtn) fullscreenBtn.addEventListener('click', toggleFullscreen);
160
161      overlay.addEventListener('click', function(e) {
162        if (e.target === overlay) {
163          closePlayer();
164        }
165      });
166
167      document.addEventListener('keydown', function(e) {
168        if (e.key === 'Escape' && overlay.style.display !== 'none' && overlay.style.display !== '') {
169          if (document.fullscreenElement) {
170            // Browser handles exiting fullscreen on ESC
171          } else if (isMaximized) {
172            toggleMaximize();
173          } else {
174            closePlayer();
175          }
176        }
177      });
178    }
179
180    if (typeof window.PhotoCarousel === 'function') {
181      document.querySelectorAll('.game-carousel-wrapper, .photo-carousel-wrapper').forEach(wrapper => {
182        new window.PhotoCarousel(wrapper);
183      });
184    }
185  }
186
187  if (document.readyState === 'loading') {
188    document.addEventListener('DOMContentLoaded', initGamePlayer);
189  } else {
190    initGamePlayer();
191  }
192})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.