|
1 | | -async function fetchNthVideo(index) { |
2 | | - try { |
3 | | - const response = await fetch(); |
4 | | - if (response.ok) { |
5 | | - const blob = await response.blob(); |
6 | | - return URL.createObjectURL(blob); |
7 | | - } |
8 | | - } catch (error) { } |
9 | | - return null; // No more videos |
10 | | -} |
11 | | - |
12 | 1 | function loadVideo(src) { |
13 | 2 | return new Promise((resolve, reject) => { |
14 | 3 | const video = document.createElement('video'); |
@@ -87,9 +76,7 @@ function spawnVideo(video) { |
87 | 76 | console.log('Spawned video:', video.src, 'at', x, y, 'velocity', vx, vy); |
88 | 77 | } |
89 | 78 |
|
90 | | -let currentIndex = 0; |
91 | | - |
92 | | -async function startNextDownload(i) { |
| 79 | +function startNextDownload(i) { |
93 | 80 | loadVideo(`/api/videos/${i}`) |
94 | 81 | .then(spawnVideo) |
95 | 82 | .then(function() { setTimeout(function(){startNextDownload(i+1);},2000);}) |
@@ -225,8 +212,8 @@ function updateBallRadius() { |
225 | 212 | } |
226 | 213 |
|
227 | 214 | // Handle both resize and orientation change events |
228 | | -window.addEventListener('resize', updateBallRadius); |
229 | | -window.addEventListener('orientationchange', function() { |
| 215 | +globalThis.addEventListener('resize', updateBallRadius); |
| 216 | +globalThis.addEventListener('orientationchange', function() { |
230 | 217 | // Delay to allow viewport to settle after orientation change |
231 | 218 | setTimeout(updateBallRadius, 100); |
232 | 219 | }); |
@@ -302,9 +289,9 @@ function initializeMobileHandling() { |
302 | 289 | }, { passive: false }); |
303 | 290 |
|
304 | 291 | // Handle viewport height changes (mobile keyboard, etc.) |
305 | | - let lastViewportHeight = window.innerHeight; |
306 | | - window.addEventListener('resize', function() { |
307 | | - const currentHeight = window.innerHeight; |
| 292 | + let lastViewportHeight = globalThis.innerHeight; |
| 293 | + globalThis.addEventListener('resize', function() { |
| 294 | + const currentHeight = globalThis.innerHeight; |
308 | 295 | if (Math.abs(currentHeight - lastViewportHeight) > 100) { |
309 | 296 | // Significant height change, likely keyboard or orientation |
310 | 297 | setTimeout(function() { |
|
0 commit comments