CLICK TO PLAY FULLSCREEN
`.trim(); // IndexedDB setup const dbPromise = indexedDB.open('GameCacheDB', 1); let db; dbPromise.onupgradeneeded = (event) => { db = event.target.result; const store = db.createObjectStore('staticCache', { keyPath: 'id' }); store.createIndex('type', 'type', { unique: false }); }; dbPromise.onsuccess = (event) => { db = event.target.result; cacheStaticContent(); }; dbPromise.onerror = (event) => { console.error('Database error:', event.target.errorCode); }; // Statik içeriği önbelleğe alma function cacheStaticContent() { const staticHTML = document.documentElement.outerHTML; const tx = db.transaction('staticCache', 'readwrite'); const store = tx.objectStore('staticCache'); store.put({ id: 'pageContent', type: 'html', content: staticHTML, timestamp: Date.now() }); tx.oncomplete = () => { console.log('Static content cached'); }; } // Cache'den yükleme ve kontrol async function loadFromCacheOrRender(container) { const tx = db.transaction('staticCache', 'readonly'); const store = tx.objectStore('staticCache'); const cachedData = await store.get('pageContent'); return new Promise((resolve) => { tx.oncomplete = () => { const blob = new Blob([gameHTML], { type: 'text/html' }); // gameHTML cache'e alınmıyor const blobUrl = URL.createObjectURL(blob); while (container.firstChild) { container.removeChild(container.firstChild); } const iframe = document.createElement('iframe'); iframe.src = blobUrl; iframe.style.width = '100%'; iframe.style.height = '100%'; iframe.style.border = 'none'; iframe.style.margin = '0'; iframe.style.padding = '0'; container.appendChild(iframe); iframe.onload = () => { console.log('Oyun yüklendi'); resolve(); }; iframe.onerror = (e) => { console.error('Oyun yüklenirken hata:', e); resolve(); }; }; }); } document.addEventListener('DOMContentLoaded', function() { const playButton = document.getElementById('playButton'); const fullscreenButton = document.getElementById('fullscreenButton'); if (playButton) { playButton.addEventListener('click', showContent); } else { console.error('Play butonu bulunamadı.'); } if (fullscreenButton) { fullscreenButton.addEventListener('click', openFullscreen); } else { console.error('Fullscreen butonu bulunamadı.'); } }); async function showContent() { try { document.getElementById('playButton').style.display = 'none'; const container = document.getElementById('contentContainer'); container.style.display = 'block'; if (db) { await loadFromCacheOrRender(container); } else { dbPromise.onsuccess = async (event) => { db = event.target.result; await loadFromCacheOrRender(container); }; } } catch (error) { console.error('Hata oluştu:', error); alert('Oyun yüklenemedi. Tarayıcı konsolunu kontrol edin.'); } } function openFullscreen() { try { const newWin = window.open("about:blank", "_blank"); if (newWin) { newWin.document.open(); newWin.document.write(gameHTML); newWin.document.close(); setTimeout(() => { if (newWin.document.documentElement.requestFullscreen) { newWin.document.documentElement.requestFullscreen(); } else if (newWin.document.documentElement.mozRequestFullScreen) { newWin.document.documentElement.mozRequestFullScreen(); } else if (newWin.document.documentElement.webkitRequestFullscreen) { newWin.document.documentElement.webkitRequestFullscreen(); } else if (newWin.document.documentElement.msRequestFullscreen) { newWin.document.documentElement.msRequestFullscreen(); } }, 500); } else { alert("Yeni sekme açma engellendi. Lütfen tarayıcı ayarlarını kontrol edin."); } } catch (error) { console.error('Fullscreen hata:', error); alert('Tam ekran modu çalışmadı. Tarayıcı konsolunu kontrol edin.'); } }