EDUrocks's picture
Add files using upload-large-folder tool
37d6cb3 verified
Raw History Blame Contribute Delete
6.95 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading Game...</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #011627;
overflow: hidden;
font-family: 'Inter', sans-serif;
}
#gameFrame {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
#loadingScreen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #011627 0%, #3C1642 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 9999;
transition: opacity 0.5s ease;
}
#loadingScreen.hidden {
opacity: 0;
pointer-events: none;
}
.loader {
width: 60px;
height: 60px;
border: 4px solid rgba(244, 21, 77, 0.2);
border-top-color: #F4154D;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.loading-text {
margin-top: 20px;
color: #e8d5e0;
font-size: 18px;
font-weight: 600;
}
.loading-info {
margin-top: 10px;
color: #c4a5b8;
font-size: 14px;
}
.sync-status {
margin-top: 5px;
color: #F4154D;
font-size: 12px;
}
</style>
<script src="/assets/js/aws-detection.js"></script>
</head>
<body>
<div id="loadingScreen">
<div class="loader"></div>
<div class="loading-text">Loading Game...</div>
<div class="loading-info" id="gameInfo"></div>
<div class="sync-status" id="syncStatus"></div>
</div>
<iframe id="gameFrame" sandbox="allow-scripts allow-same-origin allow-pointer-lock allow-forms allow-popups allow-modals" allowfullscreen></iframe>
<script type="module" src="/assets/js/game-save-sync.js?v=2.1"></script>
<script>
// Get game info from URL parameters
const urlParams = new URLSearchParams(window.location.search);
const gameUrl = urlParams.get('game');
const gameId = urlParams.get('id');
const gameName = urlParams.get('name') || 'Unknown Game';
if (!gameUrl) {
document.getElementById('loadingScreen').innerHTML = `
<div class="loading-text" style="color: #ff6b6b;">Error: No game URL specified</div>
<div class="loading-info">Please provide a game URL parameter</div>
`;
} else {
// Update loading info
document.getElementById('gameInfo').textContent = gameName;
// Check if user is logged in
const authToken = localStorage.getItem('edurocks_auth_token');
if (authToken) {
document.getElementById('syncStatus').textContent = '✓ Cloud save enabled';
} else {
document.getElementById('syncStatus').textContent = 'ℹ Cloud save disabled (not logged in)';
}
// Store game info for the interceptor and save sync system
window.EDUrocks = {
currentGameId: gameId,
currentGameName: gameName
};
// Listen for save events from iframe
window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'edurocks-save-event') {
console.log('[EDUrocks Wrapper] Received save event:', event.data.action);
// Forward to save sync system if available
if (window.EDUrocksSaveSync) {
// The main save sync system handles these automatically
// This just logs them for debugging
if (event.data.action === 'unity-detected') {
console.log('[EDUrocks Wrapper] Unity game detected, cloud save will track PlayerPrefs');
}
}
}
});
// Load the game in iframe
const iframe = document.getElementById('gameFrame');
iframe.onload = () => {
// Inject the save sync script into the iframe
try {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
// Create script element
const script = iframeDoc.createElement('script');
script.src = '/assets/js/game-save-interceptor.js';
script.onload = () => {
console.log('[EDUrocks Wrapper] Save interceptor injected successfully');
document.getElementById('syncStatus').textContent = '✓ Cloud save active';
};
script.onerror = () => {
console.error('[EDUrocks Wrapper] Failed to inject interceptor');
document.getElementById('syncStatus').textContent = '⚠ Cloud save (limited)';
};
// Inject before any other scripts to catch early saves
const firstScript = iframeDoc.querySelector('script');
if (firstScript) {
firstScript.parentNode.insertBefore(script, firstScript);
} else {
iframeDoc.head.appendChild(script);
}
} catch (error) {
console.error('[EDUrocks Wrapper] Cross-origin iframe - using wrapper-level sync only');
document.getElementById('syncStatus').textContent = '✓ Cloud save (wrapper-level)';
}
// Hide loading screen after a short delay
setTimeout(() => {
document.getElementById('loadingScreen').classList.add('hidden');
}, 1000);
};
// Set iframe src
iframe.src = gameUrl;
}
// Handle fullscreen
document.addEventListener('keydown', (e) => {
if (e.key === 'F11') {
e.preventDefault();
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
document.exitFullscreen();
}
}
});
</script>
</body>
</html>