Upload index.html
Browse files- index.html +193 -13
index.html
CHANGED
|
@@ -1,19 +1,199 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
<head>
|
| 4 |
-
<meta charset="utf-8"
|
| 5 |
-
<meta name="viewport" content="width=device-width"
|
| 6 |
-
<title>
|
| 7 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
</head>
|
| 9 |
<body>
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
</body>
|
| 19 |
</html>
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">
|
| 6 |
+
<title>Godot-groq-moa</title>
|
| 7 |
+
<style>
|
| 8 |
+
html, body, #canvas {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
border: 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
color: white;
|
| 16 |
+
background-color: black;
|
| 17 |
+
overflow: hidden;
|
| 18 |
+
touch-action: none;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
#canvas {
|
| 22 |
+
display: block;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
#canvas:focus {
|
| 26 |
+
outline: none;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
#status, #status-splash, #status-progress {
|
| 30 |
+
position: absolute;
|
| 31 |
+
left: 0;
|
| 32 |
+
right: 0;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
#status, #status-splash {
|
| 36 |
+
top: 0;
|
| 37 |
+
bottom: 0;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
#status {
|
| 41 |
+
background-color: #242424;
|
| 42 |
+
display: flex;
|
| 43 |
+
flex-direction: column;
|
| 44 |
+
justify-content: center;
|
| 45 |
+
align-items: center;
|
| 46 |
+
visibility: hidden;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
#status-splash {
|
| 50 |
+
max-height: 100%;
|
| 51 |
+
max-width: 100%;
|
| 52 |
+
margin: auto;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
#status-progress, #status-notice {
|
| 56 |
+
display: none;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
#status-progress {
|
| 60 |
+
bottom: 10%;
|
| 61 |
+
width: 50%;
|
| 62 |
+
margin: 0 auto;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
#status-notice {
|
| 66 |
+
background-color: #5b3943;
|
| 67 |
+
border-radius: 0.5rem;
|
| 68 |
+
border: 1px solid #9b3943;
|
| 69 |
+
color: #e0e0e0;
|
| 70 |
+
font-family: 'Noto Sans', 'Droid Sans', Arial, sans-serif;
|
| 71 |
+
line-height: 1.3;
|
| 72 |
+
margin: 0 2rem;
|
| 73 |
+
overflow: hidden;
|
| 74 |
+
padding: 1rem;
|
| 75 |
+
text-align: center;
|
| 76 |
+
z-index: 1;
|
| 77 |
+
}
|
| 78 |
+
</style>
|
| 79 |
+
<link id="-gd-engine-icon" rel="icon" type="image/png" href="Godot-simple-groq-api.icon.png" />
|
| 80 |
+
<link rel="apple-touch-icon" href="Godot-simple-groq-api.apple-touch-icon.png"/>
|
| 81 |
+
|
| 82 |
</head>
|
| 83 |
<body>
|
| 84 |
+
<canvas id="canvas">
|
| 85 |
+
Your browser does not support the canvas tag.
|
| 86 |
+
</canvas>
|
| 87 |
+
|
| 88 |
+
<noscript>
|
| 89 |
+
Your browser does not support JavaScript.
|
| 90 |
+
</noscript>
|
| 91 |
+
|
| 92 |
+
<div id="status">
|
| 93 |
+
<img id="status-splash" src="Godot-simple-groq-api.png" alt="">
|
| 94 |
+
<progress id="status-progress"></progress>
|
| 95 |
+
<div id="status-notice"></div>
|
| 96 |
</div>
|
| 97 |
+
|
| 98 |
+
<script src="Godot-simple-groq-api.js"></script>
|
| 99 |
+
<script>
|
| 100 |
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":true,"executable":"Godot-simple-groq-api","experimentalVK":false,"fileSizes":{"Godot-simple-groq-api.pck":4365936,"Godot-simple-groq-api.wasm":35372023},"focusCanvas":true,"gdextensionLibs":[]};
|
| 101 |
+
const GODOT_THREADS_ENABLED = false;
|
| 102 |
+
const engine = new Engine(GODOT_CONFIG);
|
| 103 |
+
|
| 104 |
+
(function () {
|
| 105 |
+
const statusOverlay = document.getElementById('status');
|
| 106 |
+
const statusProgress = document.getElementById('status-progress');
|
| 107 |
+
const statusNotice = document.getElementById('status-notice');
|
| 108 |
+
|
| 109 |
+
let initializing = true;
|
| 110 |
+
let statusMode = '';
|
| 111 |
+
|
| 112 |
+
function setStatusMode(mode) {
|
| 113 |
+
if (statusMode === mode || !initializing) {
|
| 114 |
+
return;
|
| 115 |
+
}
|
| 116 |
+
if (mode === 'hidden') {
|
| 117 |
+
statusOverlay.remove();
|
| 118 |
+
initializing = false;
|
| 119 |
+
return;
|
| 120 |
+
}
|
| 121 |
+
statusOverlay.style.visibility = 'visible';
|
| 122 |
+
statusProgress.style.display = mode === 'progress' ? 'block' : 'none';
|
| 123 |
+
statusNotice.style.display = mode === 'notice' ? 'block' : 'none';
|
| 124 |
+
statusMode = mode;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function setStatusNotice(text) {
|
| 128 |
+
while (statusNotice.lastChild) {
|
| 129 |
+
statusNotice.removeChild(statusNotice.lastChild);
|
| 130 |
+
}
|
| 131 |
+
const lines = text.split('\n');
|
| 132 |
+
lines.forEach((line) => {
|
| 133 |
+
statusNotice.appendChild(document.createTextNode(line));
|
| 134 |
+
statusNotice.appendChild(document.createElement('br'));
|
| 135 |
+
});
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function displayFailureNotice(err) {
|
| 139 |
+
console.error(err);
|
| 140 |
+
if (err instanceof Error) {
|
| 141 |
+
setStatusNotice(err.message);
|
| 142 |
+
} else if (typeof err === 'string') {
|
| 143 |
+
setStatusNotice(err);
|
| 144 |
+
} else {
|
| 145 |
+
setStatusNotice('An unknown error occured');
|
| 146 |
+
}
|
| 147 |
+
setStatusMode('notice');
|
| 148 |
+
initializing = false;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
const missing = Engine.getMissingFeatures({
|
| 152 |
+
threads: GODOT_THREADS_ENABLED,
|
| 153 |
+
});
|
| 154 |
+
|
| 155 |
+
if (missing.length !== 0) {
|
| 156 |
+
if (GODOT_CONFIG['serviceWorker'] && GODOT_CONFIG['ensureCrossOriginIsolationHeaders'] && 'serviceWorker' in navigator) {
|
| 157 |
+
// There's a chance that installing the service worker would fix the issue
|
| 158 |
+
Promise.race([
|
| 159 |
+
navigator.serviceWorker.getRegistration().then((registration) => {
|
| 160 |
+
if (registration != null) {
|
| 161 |
+
return Promise.reject(new Error('Service worker already exists.'));
|
| 162 |
+
}
|
| 163 |
+
return registration;
|
| 164 |
+
}).then(() => engine.installServiceWorker()),
|
| 165 |
+
// For some reason, `getRegistration()` can stall
|
| 166 |
+
new Promise((resolve) => {
|
| 167 |
+
setTimeout(() => resolve(), 2000);
|
| 168 |
+
}),
|
| 169 |
+
]).catch((err) => {
|
| 170 |
+
console.error('Error while registering service worker:', err);
|
| 171 |
+
}).then(() => {
|
| 172 |
+
window.location.reload();
|
| 173 |
+
});
|
| 174 |
+
} else {
|
| 175 |
+
// Display the message as usual
|
| 176 |
+
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
|
| 177 |
+
displayFailureNotice(missingMsg + missing.join('\n'));
|
| 178 |
+
}
|
| 179 |
+
} else {
|
| 180 |
+
setStatusMode('progress');
|
| 181 |
+
engine.startGame({
|
| 182 |
+
'onProgress': function (current, total) {
|
| 183 |
+
if (current > 0 && total > 0) {
|
| 184 |
+
statusProgress.value = current;
|
| 185 |
+
statusProgress.max = total;
|
| 186 |
+
} else {
|
| 187 |
+
statusProgress.removeAttribute('value');
|
| 188 |
+
statusProgress.removeAttribute('max');
|
| 189 |
+
}
|
| 190 |
+
},
|
| 191 |
+
}).then(() => {
|
| 192 |
+
setStatusMode('hidden');
|
| 193 |
+
}, displayFailureNotice);
|
| 194 |
+
}
|
| 195 |
+
}());
|
| 196 |
+
</script>
|
| 197 |
</body>
|
| 198 |
</html>
|
| 199 |
+
|