introduce prettierrc formatting
This commit is contained in:
@@ -7,83 +7,94 @@ const resizeCheckbox = document.getElementById('resize');
|
||||
const pointerLockCheckbox = document.getElementById('pointerLock');
|
||||
|
||||
if (outputElement) {
|
||||
outputElement.value = '';
|
||||
outputElement.value = '';
|
||||
}
|
||||
|
||||
canvasElement.addEventListener('webglcontextlost', (event) => {
|
||||
canvasElement.addEventListener(
|
||||
'webglcontextlost',
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
setStatus('WebGL context lost. Reload the page to restart the game.');
|
||||
}, false);
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
function setStatus(text) {
|
||||
if (!setStatus.last) {
|
||||
setStatus.last = { time: Date.now(), text: '' };
|
||||
}
|
||||
|
||||
if (text === setStatus.last.text) {
|
||||
return;
|
||||
}
|
||||
|
||||
const match = text?.match(/([^(]+)\((\d+(?:\.\d+)?)\/(\d+)\)/);
|
||||
const now = Date.now();
|
||||
|
||||
if (match && now - setStatus.last.time < 30) {
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus.last.time = now;
|
||||
setStatus.last.text = text;
|
||||
|
||||
if (match) {
|
||||
statusElement.textContent = match[1].trim();
|
||||
progressElement.value = Number.parseInt(match[2], 10) * 100;
|
||||
progressElement.max = Number.parseInt(match[3], 10) * 100;
|
||||
progressElement.hidden = false;
|
||||
} else {
|
||||
statusElement.textContent = text || '';
|
||||
progressElement.hidden = !text;
|
||||
if (!text) {
|
||||
progressElement.removeAttribute('value');
|
||||
}
|
||||
if (!setStatus.last) {
|
||||
setStatus.last = { time: Date.now(), text: '' };
|
||||
}
|
||||
|
||||
if (text === setStatus.last.text) {
|
||||
return;
|
||||
}
|
||||
|
||||
const match = text?.match(/([^(]+)\((\d+(?:\.\d+)?)\/(\d+)\)/);
|
||||
const now = Date.now();
|
||||
|
||||
if (match && now - setStatus.last.time < 30) {
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus.last.time = now;
|
||||
setStatus.last.text = text;
|
||||
|
||||
if (match) {
|
||||
statusElement.textContent = match[1].trim();
|
||||
progressElement.value = Number.parseInt(match[2], 10) * 100;
|
||||
progressElement.max = Number.parseInt(match[3], 10) * 100;
|
||||
progressElement.hidden = false;
|
||||
} else {
|
||||
statusElement.textContent = text || '';
|
||||
progressElement.hidden = !text;
|
||||
if (!text) {
|
||||
progressElement.removeAttribute('value');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.Module = globalThis.Module || {};
|
||||
globalThis.Module.canvas = canvasElement;
|
||||
globalThis.Module.print = (...args) => {
|
||||
console.log(...args);
|
||||
if (!outputElement) {
|
||||
return;
|
||||
}
|
||||
outputElement.value += `${args.join(' ')}\n`;
|
||||
outputElement.scrollTop = outputElement.scrollHeight;
|
||||
console.log(...args);
|
||||
if (!outputElement) {
|
||||
return;
|
||||
}
|
||||
outputElement.value += `${args.join(' ')}\n`;
|
||||
outputElement.scrollTop = outputElement.scrollHeight;
|
||||
};
|
||||
globalThis.Module.printErr = (...args) => {
|
||||
console.error(...args);
|
||||
if (!outputElement) {
|
||||
return;
|
||||
}
|
||||
outputElement.value += `[err] ${args.join(' ')}\n`;
|
||||
outputElement.scrollTop = outputElement.scrollHeight;
|
||||
console.error(...args);
|
||||
if (!outputElement) {
|
||||
return;
|
||||
}
|
||||
outputElement.value += `[err] ${args.join(' ')}\n`;
|
||||
outputElement.scrollTop = outputElement.scrollHeight;
|
||||
};
|
||||
globalThis.Module.setStatus = setStatus;
|
||||
globalThis.Module.totalDependencies = 0;
|
||||
globalThis.Module.monitorRunDependencies = function (left) {
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
setStatus(left ? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})` : 'Running...');
|
||||
if (!left) {
|
||||
setTimeout(() => setStatus(''), 250);
|
||||
}
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
setStatus(
|
||||
left
|
||||
? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})`
|
||||
: 'Running...'
|
||||
);
|
||||
if (!left) {
|
||||
setTimeout(() => setStatus(''), 250);
|
||||
}
|
||||
};
|
||||
|
||||
fullscreenButton.addEventListener('click', () => {
|
||||
if (typeof globalThis.Module.requestFullscreen === 'function') {
|
||||
globalThis.Module.requestFullscreen(pointerLockCheckbox.checked, resizeCheckbox.checked);
|
||||
}
|
||||
if (typeof globalThis.Module.requestFullscreen === 'function') {
|
||||
globalThis.Module.requestFullscreen(
|
||||
pointerLockCheckbox.checked,
|
||||
resizeCheckbox.checked
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
setStatus('Downloading...');
|
||||
|
||||
globalThis.onerror = () => {
|
||||
setStatus('Exception thrown, see JavaScript console');
|
||||
setStatus('Exception thrown, see JavaScript console');
|
||||
};
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--bg: #fffdf7;
|
||||
--text: #0f172a;
|
||||
--muted: #475569;
|
||||
--border: #0f172a;
|
||||
--panel: #dff4ff;
|
||||
--panel-2: #ffffff;
|
||||
--accent: #00a6fb;
|
||||
--accent-strong: #0077b6;
|
||||
--highlight: #ffd23f;
|
||||
--danger: #ff5d73;
|
||||
--bg: #fffdf7;
|
||||
--text: #0f172a;
|
||||
--muted: #475569;
|
||||
--border: #0f172a;
|
||||
--panel: #dff4ff;
|
||||
--panel-2: #ffffff;
|
||||
--accent: #00a6fb;
|
||||
--accent-strong: #0077b6;
|
||||
--highlight: #ffd23f;
|
||||
--danger: #ff5d73;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 18px;
|
||||
line-height: 1.6;
|
||||
padding: 20px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-size: 18px;
|
||||
line-height: 1.6;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 920px;
|
||||
margin: 0 auto;
|
||||
max-width: 920px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
header {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 3px solid var(--border);
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 3px solid var(--border);
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
h1,
|
||||
@@ -44,216 +44,216 @@ h3,
|
||||
button,
|
||||
summary,
|
||||
.back-button {
|
||||
font-family: "Arial Black", Arial, Helvetica, sans-serif;
|
||||
font-weight: 900;
|
||||
letter-spacing: 0.02em;
|
||||
font-family: 'Arial Black', Arial, Helvetica, sans-serif;
|
||||
font-weight: 900;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: clamp(2.4rem, 5vw, 3.6rem);
|
||||
margin-bottom: 10px;
|
||||
line-height: 1;
|
||||
text-transform: uppercase;
|
||||
font-size: clamp(2.4rem, 5vw, 3.6rem);
|
||||
margin-bottom: 10px;
|
||||
line-height: 1;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.8rem;
|
||||
margin: 0 0 16px;
|
||||
font-size: 1.8rem;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.35rem;
|
||||
margin: 0 0 14px;
|
||||
font-size: 1.35rem;
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
|
||||
p,
|
||||
ul {
|
||||
margin-bottom: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: var(--accent-strong);
|
||||
font-size: 1rem;
|
||||
color: var(--accent-strong);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.back-button {
|
||||
display: inline-block;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px 15px;
|
||||
background: var(--highlight);
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
border: 3px solid var(--border);
|
||||
display: inline-block;
|
||||
margin-bottom: 20px;
|
||||
padding: 10px 15px;
|
||||
background: var(--highlight);
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
border: 3px solid var(--border);
|
||||
}
|
||||
|
||||
.back-button:hover,
|
||||
.action-button:hover {
|
||||
background: var(--text);
|
||||
color: #fff;
|
||||
background: var(--text);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
background: var(--highlight);
|
||||
border: 3px solid var(--border);
|
||||
padding: 16px;
|
||||
margin: 20px 0;
|
||||
background: var(--highlight);
|
||||
border: 3px solid var(--border);
|
||||
padding: 16px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.canvas-container {
|
||||
background: var(--panel);
|
||||
border: 3px solid var(--border);
|
||||
padding: 20px;
|
||||
margin: 30px 0;
|
||||
background: var(--panel);
|
||||
border: 3px solid var(--border);
|
||||
padding: 20px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
.canvas-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 15px;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 15px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.canvas-toolbar p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.95rem;
|
||||
text-transform: uppercase;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 0.95rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
padding: 10px 14px;
|
||||
background: var(--danger);
|
||||
color: white;
|
||||
border: 3px solid var(--border);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
padding: 10px 14px;
|
||||
background: var(--danger);
|
||||
color: white;
|
||||
border: 3px solid var(--border);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.canvas-shell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 520px;
|
||||
overflow: auto;
|
||||
background: var(--panel-2);
|
||||
border: 3px solid var(--border);
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 520px;
|
||||
overflow: auto;
|
||||
background: var(--panel-2);
|
||||
border: 3px solid var(--border);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
#canvas {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
background: #000;
|
||||
outline: none;
|
||||
image-rendering: pixelated;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
background: #000;
|
||||
outline: none;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
|
||||
.canvas-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14px;
|
||||
margin-top: 15px;
|
||||
font-size: 0.95rem;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14px;
|
||||
margin-top: 15px;
|
||||
font-size: 0.95rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.canvas-options label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.canvas-options input {
|
||||
accent-color: var(--accent-strong);
|
||||
accent-color: var(--accent-strong);
|
||||
}
|
||||
|
||||
.status {
|
||||
margin-top: 15px;
|
||||
min-height: 24px;
|
||||
color: var(--accent-strong);
|
||||
font-weight: 700;
|
||||
margin-top: 15px;
|
||||
min-height: 24px;
|
||||
color: var(--accent-strong);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
progress {
|
||||
width: 100%;
|
||||
height: 18px;
|
||||
margin-top: 10px;
|
||||
border: 3px solid var(--border);
|
||||
width: 100%;
|
||||
height: 18px;
|
||||
margin-top: 10px;
|
||||
border: 3px solid var(--border);
|
||||
}
|
||||
|
||||
progress[hidden] {
|
||||
display: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
details {
|
||||
margin-top: 15px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
summary {
|
||||
cursor: pointer;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.feature-list {
|
||||
padding-left: 24px;
|
||||
padding-left: 24px;
|
||||
}
|
||||
|
||||
.feature-list li {
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-height: 120px;
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
border: 3px solid var(--border);
|
||||
font-family: "Courier New", monospace;
|
||||
font-size: 0.9rem;
|
||||
resize: vertical;
|
||||
background: white;
|
||||
color: var(--text);
|
||||
width: 100%;
|
||||
min-height: 120px;
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
border: 3px solid var(--border);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.9rem;
|
||||
resize: vertical;
|
||||
background: white;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
padding-top: 20px;
|
||||
border-top: 3px solid var(--border);
|
||||
font-size: 0.9rem;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
padding-top: 20px;
|
||||
border-top: 3px solid var(--border);
|
||||
font-size: 0.9rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
body {
|
||||
padding: 16px;
|
||||
font-size: 16px;
|
||||
}
|
||||
body {
|
||||
padding: 16px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.2rem;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.2rem;
|
||||
}
|
||||
|
||||
.canvas-container {
|
||||
padding: 15px;
|
||||
}
|
||||
.canvas-container {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.canvas-shell {
|
||||
min-height: 360px;
|
||||
}
|
||||
.canvas-shell {
|
||||
min-height: 360px;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user