fix(web): remove password from public applications

This commit is contained in:
nyan404 committed 2026-08-21 14:16:01 +03:00
1 parent 0c59d8cb15
commit e5bd31b428
9 files changed
+9 -91

No files matched your search

+2 -5
View File
@@ -21,8 +21,7 @@
</head>
<body><main>
<nav class="topnav"><a class="brand" href="/belki">Беличья нора</a><a href="/belki">Калькулятор отчётов</a></nav>
<section id="auth" class="auth"><h2>Вход</h2><p class="hint">Введите пароль, чтобы подать заявку и приложить скриншоты.</p><form id="authForm"><label>Пароль<input id="password" type="password" autocomplete="current-password" required></label><p id="authError" class="error"></p><button class="primary" type="submit">Войти</button></form></section>
<section id="app" class="hidden"><h1>Новая заявка</h1><p class="intro">Заполните форму — администратор получит структурированную заявку для рассмотрения. Не нужно готовить форумную отпись.</p>
<section id="app"><h1>Новая заявка</h1><p class="intro">Заполните форму — администратор получит структурированную заявку для рассмотрения. Не нужно готовить форумную отпись.</p>
<div class="types" role="radiogroup" aria-label="Тип заявки">
<button class="type active" type="button" data-type="feather_donation">Пожертвовать перо отряду</button><button class="type" type="button" data-type="kitten">Хочу стать бельчонком</button><button class="type" type="button" data-type="flying_squirrel">Хочу стать белкой-летягой</button><button class="type" type="button" data-type="curator">Хочу стать куратором</button>
</div>
@@ -36,9 +35,7 @@
</div><p id="error" class="error" role="alert"></p><div class="actions"><button class="primary" type="submit">Отправить заявку</button></div></form><div id="success" class="success hidden"></div>
</section>
</main><script>
const auth=document.querySelector('#auth'), app=document.querySelector('#app'), form=document.querySelector('#form'), error=document.querySelector('#error'); let active='feather_donation';
function activate(){auth.classList.add('hidden');app.classList.remove('hidden')} async function session(){const r=await fetch('/api/web/session');const d=await r.json();if(d.authenticated)activate()}
document.querySelector('#authForm').addEventListener('submit',async e=>{e.preventDefault();const r=await fetch('/api/web/auth',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({password:document.querySelector('#password').value})});const d=await r.json();if(!r.ok){document.querySelector('#authError').textContent=d.error||'Не удалось войти';return}activate()});session().catch(()=>{});
const form=document.querySelector('#form'), error=document.querySelector('#error'); let active='feather_donation';
function addFeather(data={}){const row=document.createElement('div');row.className='feather';row.innerHTML='<label>Количество<input data-field="amount" type="number" min="1" required></label><label>Цвет<input data-field="color" placeholder="например, синие" required></label><label>Источник добычи<input data-field="source" placeholder="личные запасы, осмотр дупла…" required></label><button class="remove" type="button">Убрать</button>';Object.entries(data).forEach(([k,v])=>{const el=row.querySelector(`[data-field="${k}"]`);if(el)el.value=v});row.querySelector('.remove').onclick=()=>row.remove();document.querySelector('#feathers').append(row)} addFeather();document.querySelector('#addFeather').onclick=()=>addFeather();
function sync(){document.querySelector('#featherFields').classList.toggle('hidden',active!=='feather_donation');document.querySelector('#kittenFields').classList.toggle('hidden',active!=='kitten');document.querySelector('#curatorFields').classList.toggle('hidden',active!=='curator');document.querySelector('#flyingFields').classList.toggle('hidden',active!=='flying_squirrel');document.querySelector('#vkField').classList.toggle('hidden',active!=='flying_squirrel');document.querySelectorAll('.type').forEach(x=>x.classList.toggle('active',x.dataset.type===active))} document.querySelectorAll('.type').forEach(b=>b.onclick=()=>{active=b.dataset.type;sync()});sync();
document.querySelector('[name="practiced_before"]').onchange=e=>document.querySelector('#practiceLink').classList.toggle('hidden',e.target.value!=='yes');