cosmetic improvements
This commit is contained in:
@@ -33,6 +33,7 @@ const STRINGS = {
|
|||||||
congratulations: 'Congratulations!',
|
congratulations: 'Congratulations!',
|
||||||
pleaseSelect: 'Please select all options',
|
pleaseSelect: 'Please select all options',
|
||||||
installApp: 'Install App',
|
installApp: 'Install App',
|
||||||
|
sec: 'sec',
|
||||||
systemNames: {
|
systemNames: {
|
||||||
binary: 'Binary', octal: 'Octal', hex: 'Hexadecimal',
|
binary: 'Binary', octal: 'Octal', hex: 'Hexadecimal',
|
||||||
ternary: 'Balanced Ternary', braille: 'Braille Decimal',
|
ternary: 'Balanced Ternary', braille: 'Braille Decimal',
|
||||||
@@ -70,6 +71,7 @@ const STRINGS = {
|
|||||||
congratulations: '\u041F\u043E\u0437\u0434\u0440\u0430\u0432\u043B\u044F\u0435\u043C!',
|
congratulations: '\u041F\u043E\u0437\u0434\u0440\u0430\u0432\u043B\u044F\u0435\u043C!',
|
||||||
pleaseSelect: '\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0441\u0435 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B',
|
pleaseSelect: '\u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0432\u0441\u0435 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B',
|
||||||
installApp: '\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435',
|
installApp: '\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435',
|
||||||
|
sec: '\u0441\u0435\u043A',
|
||||||
systemNames: {
|
systemNames: {
|
||||||
binary: '\u0414\u0432\u043E\u0438\u0447\u043D\u0430\u044F',
|
binary: '\u0414\u0432\u043E\u0438\u0447\u043D\u0430\u044F',
|
||||||
octal: '\u0412\u043E\u0441\u044C\u043C\u0435\u0440\u0438\u0447\u043D\u0430\u044F',
|
octal: '\u0412\u043E\u0441\u044C\u043C\u0435\u0440\u0438\u0447\u043D\u0430\u044F',
|
||||||
@@ -171,10 +173,10 @@ const MODES = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const TIMINGS = [
|
const TIMINGS = [
|
||||||
{ label: '60 sec', value: 60 },
|
{ value: 60 },
|
||||||
{ label: '40 sec', value: 40 },
|
{ value: 40 },
|
||||||
{ label: '10 sec', value: 10 },
|
{ value: 10 },
|
||||||
{ label: 'nolimit', value: 0 },
|
{ value: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const ROUNDS = [10, 25, 50, 100];
|
const ROUNDS = [10, 25, 50, 100];
|
||||||
@@ -296,7 +298,7 @@ function renderSetupOptions() {
|
|||||||
TIMINGS.forEach((tm, i) => {
|
TIMINGS.forEach((tm, i) => {
|
||||||
const btn = document.createElement('button');
|
const btn = document.createElement('button');
|
||||||
btn.className = 'option-btn' + (i === defaultTiming ? ' selected' : '');
|
btn.className = 'option-btn' + (i === defaultTiming ? ' selected' : '');
|
||||||
btn.textContent = tm.value === 0 ? t('noLimit') : tm.label;
|
btn.textContent = tm.value === 0 ? t('noLimit') : tm.value + ' ' + t('sec');
|
||||||
btn.addEventListener('click', () => {
|
btn.addEventListener('click', () => {
|
||||||
timingDiv.querySelectorAll('.option-btn').forEach(b => b.classList.remove('selected'));
|
timingDiv.querySelectorAll('.option-btn').forEach(b => b.classList.remove('selected'));
|
||||||
btn.classList.add('selected');
|
btn.classList.add('selected');
|
||||||
@@ -324,6 +326,8 @@ function renderSetupOptions() {
|
|||||||
|
|
||||||
// ---- GAME ----
|
// ---- GAME ----
|
||||||
let lastSetupState = null;
|
let lastSetupState = null;
|
||||||
|
const MARK_CORRECT = '\u2713 ';
|
||||||
|
const MARK_INCORRECT = '\u2717 ';
|
||||||
|
|
||||||
function startGame() {
|
function startGame() {
|
||||||
lastSetupState = { ...setupState };
|
lastSetupState = { ...setupState };
|
||||||
@@ -337,9 +341,10 @@ function startGame() {
|
|||||||
game.mistakes = [];
|
game.mistakes = [];
|
||||||
game.lastAnswer = null;
|
game.lastAnswer = null;
|
||||||
|
|
||||||
document.getElementById('score-correct').textContent = '0';
|
document.getElementById('score-system-range').textContent = systemName(game.system) + ': ' + game.range.label;
|
||||||
document.getElementById('score-total').textContent = '0';
|
document.getElementById('score-round').textContent = '0/' + game.rounds;
|
||||||
document.getElementById('score-system').textContent = systemName(game.system);
|
document.getElementById('score-correct').textContent = MARK_CORRECT + '0';
|
||||||
|
document.getElementById('score-incorrect').textContent = MARK_INCORRECT + '0';
|
||||||
|
|
||||||
showScreen('game');
|
showScreen('game');
|
||||||
nextRound();
|
nextRound();
|
||||||
@@ -360,8 +365,8 @@ function nextRound() {
|
|||||||
game.correctAnswer = num;
|
game.correctAnswer = num;
|
||||||
game.lastAnswer = num;
|
game.lastAnswer = num;
|
||||||
|
|
||||||
document.getElementById('score-total').textContent = game.currentRound;
|
document.getElementById('score-round').textContent = game.currentRound + '/' + game.rounds;
|
||||||
document.getElementById('score-correct').textContent = game.correctCount;
|
document.getElementById('score-correct').textContent = MARK_CORRECT + game.correctCount;
|
||||||
|
|
||||||
const display = SYSTEMS[game.system].toDisplay(game.correctAnswer);
|
const display = SYSTEMS[game.system].toDisplay(game.correctAnswer);
|
||||||
const numEl = document.getElementById('number-display');
|
const numEl = document.getElementById('number-display');
|
||||||
@@ -411,7 +416,7 @@ function handleChoice(idx, val, choices) {
|
|||||||
|
|
||||||
if (val === game.correctAnswer) {
|
if (val === game.correctAnswer) {
|
||||||
game.correctCount++;
|
game.correctCount++;
|
||||||
document.getElementById('score-correct').textContent = game.correctCount;
|
document.getElementById('score-correct').textContent = MARK_CORRECT + game.correctCount;
|
||||||
allBtns[idx].classList.add('correct-choice');
|
allBtns[idx].classList.add('correct-choice');
|
||||||
feedback.textContent = t('correct');
|
feedback.textContent = t('correct');
|
||||||
feedback.className = 'answer-feedback correct';
|
feedback.className = 'answer-feedback correct';
|
||||||
@@ -427,6 +432,7 @@ function handleChoice(idx, val, choices) {
|
|||||||
systemName: systemName(game.system),
|
systemName: systemName(game.system),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
document.getElementById('score-incorrect').textContent = MARK_INCORRECT + (game.currentRound - game.correctCount);
|
||||||
|
|
||||||
document.getElementById('btn-next').classList.remove('hidden');
|
document.getElementById('btn-next').classList.remove('hidden');
|
||||||
}
|
}
|
||||||
@@ -466,7 +472,7 @@ function renderNumpad() {
|
|||||||
const feedback = document.getElementById('answer-feedback');
|
const feedback = document.getElementById('answer-feedback');
|
||||||
if (val === game.correctAnswer) {
|
if (val === game.correctAnswer) {
|
||||||
game.correctCount++;
|
game.correctCount++;
|
||||||
document.getElementById('score-correct').textContent = game.correctCount;
|
document.getElementById('score-correct').textContent = MARK_CORRECT + game.correctCount;
|
||||||
feedback.textContent = t('correct');
|
feedback.textContent = t('correct');
|
||||||
feedback.className = 'answer-feedback correct';
|
feedback.className = 'answer-feedback correct';
|
||||||
} else {
|
} else {
|
||||||
@@ -478,6 +484,7 @@ function renderNumpad() {
|
|||||||
systemName: systemName(game.system),
|
systemName: systemName(game.system),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
document.getElementById('score-incorrect').textContent = MARK_INCORRECT + (game.currentRound - game.correctCount);
|
||||||
|
|
||||||
document.getElementById('btn-next').classList.remove('hidden');
|
document.getElementById('btn-next').classList.remove('hidden');
|
||||||
};
|
};
|
||||||
@@ -518,12 +525,12 @@ function startTimer() {
|
|||||||
|
|
||||||
timerArea.classList.add('visible');
|
timerArea.classList.add('visible');
|
||||||
game.timeLeft = game.timing;
|
game.timeLeft = game.timing;
|
||||||
timerEl.textContent = game.timeLeft + 's';
|
timerEl.textContent = game.timeLeft + ' ' + t('sec');
|
||||||
timerEl.classList.remove('urgent');
|
timerEl.classList.remove('urgent');
|
||||||
|
|
||||||
game.timerInterval = setInterval(() => {
|
game.timerInterval = setInterval(() => {
|
||||||
game.timeLeft--;
|
game.timeLeft--;
|
||||||
timerEl.textContent = game.timeLeft + 's';
|
timerEl.textContent = game.timeLeft + ' ' + t('sec');
|
||||||
|
|
||||||
if (game.timeLeft <= 10) {
|
if (game.timeLeft <= 10) {
|
||||||
timerEl.classList.add('urgent');
|
timerEl.classList.add('urgent');
|
||||||
@@ -541,6 +548,7 @@ function startTimer() {
|
|||||||
decimal: game.correctAnswer,
|
decimal: game.correctAnswer,
|
||||||
systemName: systemName(game.system),
|
systemName: systemName(game.system),
|
||||||
});
|
});
|
||||||
|
document.getElementById('score-incorrect').textContent = MARK_INCORRECT + (game.currentRound - game.correctCount);
|
||||||
|
|
||||||
document.getElementById('btn-next').classList.remove('hidden');
|
document.getElementById('btn-next').classList.remove('hidden');
|
||||||
|
|
||||||
|
|||||||
+8
-5
@@ -10,7 +10,7 @@
|
|||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
<link rel="icon" type="image/svg+xml" href="icon.svg">
|
<link rel="icon" type="image/svg+xml" href="icon.svg">
|
||||||
<link rel="apple-touch-icon" href="icon-192.png">
|
<link rel="apple-touch-icon" href="icon-192.png">
|
||||||
<link rel="stylesheet" href="styles.css?v=41">
|
<link rel="stylesheet" href="styles.css?v=46">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
@@ -93,8 +93,9 @@
|
|||||||
<div id="screen-game" class="screen">
|
<div id="screen-game" class="screen">
|
||||||
<div class="game-header">
|
<div class="game-header">
|
||||||
<div class="score-display">
|
<div class="score-display">
|
||||||
<span id="score-correct">0</span>/<span id="score-total">0</span>
|
<span id="score-round">0/0</span>
|
||||||
<span id="score-system"></span>
|
<span id="score-correct" class="score-correct">0</span>
|
||||||
|
<span id="score-incorrect" class="score-incorrect">0</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="timer-area" id="timer-area">
|
<div class="timer-area" id="timer-area">
|
||||||
<span class="timer-label" data-i18n="timeLeft">Time left</span>
|
<span class="timer-label" data-i18n="timeLeft">Time left</span>
|
||||||
@@ -105,6 +106,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="system-range-label" id="score-system-range"></div>
|
||||||
|
|
||||||
<div class="game-body">
|
<div class="game-body">
|
||||||
<div class="number-display" id="number-display"></div>
|
<div class="number-display" id="number-display"></div>
|
||||||
<div class="answer-feedback" id="answer-feedback"></div>
|
<div class="answer-feedback" id="answer-feedback"></div>
|
||||||
@@ -155,10 +158,10 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module" src="app.js?v=41"></script>
|
<script type="module" src="app.js?v=46"></script>
|
||||||
<script>
|
<script>
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register('/sw.js?v=41').catch(() => {});
|
navigator.serviceWorker.register('/sw.js?v=46').catch(() => {});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+16
-3
@@ -252,14 +252,24 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.score-display {
|
.score-display {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
#score-system {
|
.score-correct {
|
||||||
margin-left: 8px;
|
color: var(--correct);
|
||||||
|
margin-left: 16px;
|
||||||
|
}
|
||||||
|
.score-incorrect { color: var(--incorrect); }
|
||||||
|
|
||||||
|
.system-range-label {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1rem;
|
||||||
color: var(--text-dim);
|
color: var(--text-dim);
|
||||||
font-size: 0.9rem;
|
padding: 8px 20px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timer-area {
|
.timer-area {
|
||||||
@@ -522,6 +532,9 @@ body {
|
|||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--correct);
|
color: var(--correct);
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-congrats:not(:empty) {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
min-height: 48px;
|
min-height: 48px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user