fix(web): make calculator available without login

This commit is contained in:
nyan404 committed 2026-08-21 14:02:28 +03:00
1 parent 111623994e
commit f73f99068a
4 files changed
+3 -30

No files matched your search

-29
View File
@@ -45,13 +45,6 @@
</head>
<body>
<main>
<section class="panel auth-panel" id="webAuth">
<h2>Вход в калькулятор</h2>
<p class="muted">Введите пароль, чтобы создавать отчёты и загружать скриншоты.</p>
<form id="webAuthForm"><label>Пароль<input id="webPassword" type="password" autocomplete="current-password" required></label><button class="primary" type="submit">Войти</button></form>
<p class="error" id="webAuthError"></p>
</section>
<div id="webApp" class="hidden">
<h1>Беличья нора — калькулятор отчётов</h1>
<p class="muted">Один заход — один отчёт. Скриншоты к готовому отчёту нужно приложить вручную.</p>
@@ -135,7 +128,6 @@
<div class="result hidden" id="result"><h2>Сообщение</h2><textarea id="message" readonly></textarea><p class="muted" id="summary"></p></div>
<p class="error" id="error"></p>
</section>
</div>
</main>
<dialog id="identityDialog">
<p id="identityDialogText"></p>
@@ -145,11 +137,6 @@
<button type="button" id="closeIdentityDialog">Понятно</button>
</dialog>
<script>
const webAuth = document.querySelector('#webAuth');
const webApp = document.querySelector('#webApp');
const webAuthForm = document.querySelector('#webAuthForm');
const webPassword = document.querySelector('#webPassword');
const webAuthError = document.querySelector('#webAuthError');
const form = document.querySelector('#form');
const error = document.querySelector('#error');
const result = document.querySelector('#result');
@@ -165,22 +152,6 @@
const identityMissingLabel = document.querySelector('#identityMissingLabel');
const identityMissingValue = document.querySelector('#identityMissingValue');
let mode = 'coaching';
function showWebApp() { webAuth.classList.add('hidden'); webApp.classList.remove('hidden'); }
async function checkWebSession() {
const response = await fetch('/api/web/session');
const data = await response.json();
if (data.authenticated) showWebApp();
}
webAuthForm.addEventListener('submit', async event => {
event.preventDefault(); webAuthError.textContent = '';
try {
const response = await fetch('/api/web/auth', {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({password: webPassword.value})});
const data = await response.json();
if (!response.ok) throw new Error(data.error || 'Не удалось войти');
showWebApp();
} catch (err) { webAuthError.textContent = err.message; }
});
checkWebSession().catch(err => { webAuthError.textContent = err.message; });
const extraKittens = document.querySelector('#extraKittens');
const statusHelp = document.querySelector('#statusHelp');
function addExtraKitten(values = {}) {