diff --git a/index.html b/index.html index 01d74e5..c05af09 100644 --- a/index.html +++ b/index.html @@ -137,12 +137,6 @@ const confettiLayer = document.getElementById('confettiLayer'); const basketCountEl = document.getElementById('basketCount'); const quoteEl = document.getElementById('quoteText'); -let quotes = []; -fetch('./quotes.txt') - .then(r => (r.ok ? r.text() : '')) - .then(text => { quotes = text.split('\n').map(s => s.trim()).filter(Boolean); }) - .catch(() => {}); - // ---------- renderer / scene / camera ---------- const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false, powerPreference: 'low-power' }); renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); @@ -591,16 +585,24 @@ function catchInBasket(apple){ if (basketCount >= BASKET_FULL) celebrate(); } -function celebrate(){ +// 명언은 축하 화면이 뜰 때만 그 자리에서 불러와 쓰고, 목록을 어디에도 저장해두지 +// 않는다 — 함수가 끝나면 로컬 변수(list)라 참조가 안 남아 바로 GC 대상이 된다. +async function celebrate(){ celebrateEl.classList.add('show'); - if (quotes.length){ - quoteEl.textContent = quotes[Math.floor(Math.random() * quotes.length)]; - quoteEl.classList.add('show'); - } else { - quoteEl.classList.remove('show'); - } + quoteEl.classList.remove('show'); spawnConfetti(); setTimeout(clearBasket, 2800); + + try { + const res = await fetch('./quotes.txt'); + if (!res.ok) return; + const text = await res.text(); + const list = text.split('\n').map(s => s.trim()).filter(Boolean); + if (list.length){ + quoteEl.textContent = list[Math.floor(Math.random() * list.length)]; + quoteEl.classList.add('show'); + } + } catch {} } function spawnConfetti(){