Переписал уведомления: toast/confirm вместо alert; объединил профиль+инвентарь; починил ленту активности

This commit is contained in:
root
2026-07-05 15:05:04 +00:00
parent fe6bf5cf29
commit 50535ec777
15 changed files with 1523 additions and 1111 deletions
+32 -24
View File
@@ -252,9 +252,11 @@ async function searchCaseItems() {
document.getElementById('caseItemSearchResults').innerHTML = html;
}
<script>if(typeof Notify==="undefined"){window.Notify={toast:function(m){alert(m)},error:function(m){alert(m)},success:function(m){alert(m)},info:function(m){alert(m)},confirm:function(m,t,c){if(c&&confirm(m))c(!0)}}}</script>
<script>
async function saveCase() {
const name = document.getElementById('caseNameInput').value.trim();
if (!name) { alert('Введите название кейса'); return; }
if (!name) { Notify.error('Введите название кейса'); return; }
const fd = new FormData();
fd.append('case_name', name);
fd.append('display_name', document.getElementById('caseDisplayName').value);
@@ -271,16 +273,18 @@ async function saveCase() {
const r = await fetch(url, { method:'POST', body:fd });
const d = await r.json();
if (d.success) { window.location.reload(); }
else alert(d.error || 'Ошибка');
else Notify.error(d.error || 'Ошибка');
}
async function deleteCase(name) {
if (!confirm(`Удалить кейс "${name}"?`)) return;
const fd = new FormData(); fd.append('case_name', name);
const r = await fetch(`/admin/api/cases/delete/${encodeURIComponent(name)}`, { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else alert(d.error);
Notify.confirm(`Удалить кейс "${name}"?`, 'Подтверждение', async function(ok) {
if (!ok) return;
const fd = new FormData(); fd.append('case_name', name);
const r = await fetch(`/admin/api/cases/delete/${encodeURIComponent(name)}`, { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else Notify.error(d.error);
});
}
// ─── All Items Browser ───────────────────────────────────────────────────────
@@ -318,15 +322,17 @@ async function confirmAddSection() {
const r = await fetch('/admin/api/mainpage/section/add', { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else alert(d.error);
else Notify.error(d.error);
}
async function deleteSection(tab) {
if (!confirm(`Удалить секцию "${tab}"?`)) return;
const fd = new FormData(); fd.append('tab', tab);
const r = await fetch('/admin/api/mainpage/section/delete', { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else alert(d.error);
Notify.confirm(`Удалить секцию "${tab}"?`, 'Подтверждение', async function(ok) {
if (!ok) return;
const fd = new FormData(); fd.append('tab', tab);
const r = await fetch('/admin/api/mainpage/section/delete', { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else Notify.error(d.error);
});
}
function openAddCaseModal(tab) {
@@ -345,17 +351,19 @@ async function confirmAddCase() {
const r = await fetch('/admin/api/mainpage/section/add-case', { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else alert(d.error);
else Notify.error(d.error);
}
async function removeCaseFromSection(tab, caseName) {
if (!confirm(`Убрать "${caseName}" из "${tab}"?`)) return;
const fd = new FormData();
fd.append('tab', tab);
fd.append('case_name', caseName);
const r = await fetch('/admin/api/mainpage/section/remove-case', { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else alert(d.error);
Notify.confirm(`Убрать "${caseName}" из "${tab}"?`, 'Подтверждение', async function(ok) {
if (!ok) return;
const fd = new FormData();
fd.append('tab', tab);
fd.append('case_name', caseName);
const r = await fetch('/admin/api/mainpage/section/remove-case', { method:'POST', body:fd });
const d = await r.json();
if (d.success) window.location.reload();
else Notify.error(d.error);
});
}
</script>
{% endblock %}