File size: 6,949 Bytes
37d6cb3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | <!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>
|