Переписал уведомления: toast/confirm вместо alert; объединил профиль+инвентарь; починил ленту активности
This commit is contained in:
+32
-24
@@ -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 %}
|
||||
|
||||
@@ -172,6 +172,7 @@ let currentRPU = null;
|
||||
function closeModal(id) { document.getElementById(id).classList.remove('open'); }
|
||||
function openModal(id) { document.getElementById(id).classList.add('open'); }
|
||||
|
||||
<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>
|
||||
// ====== BALANCE ======
|
||||
function openBalanceModal() { openModal('balanceModal'); }
|
||||
async function updateBalance() {
|
||||
@@ -180,8 +181,8 @@ async function updateBalance() {
|
||||
fd.append('operation', document.getElementById('balanceOperation').value);
|
||||
const res = await fetch(`/admin/api/user/${userId}/balance`, { method:'POST', body:fd });
|
||||
const d = await res.json();
|
||||
if (d.success) { alert(d.message); window.location.reload(); }
|
||||
else alert(d.error);
|
||||
if (d.success) { Notify.success(d.message); window.location.reload(); }
|
||||
else Notify.error(d.error);
|
||||
}
|
||||
|
||||
// ====== GIVE ITEM ======
|
||||
@@ -205,31 +206,37 @@ async function giveItem(itemId) {
|
||||
const fd = new FormData(); fd.append('item_id', itemId);
|
||||
const res = await fetch(`/admin/api/user/${userId}/give-item`, { method:'POST', body:fd });
|
||||
const d = await res.json();
|
||||
if (d.success) { alert(d.message); closeModal('giveItemModal'); window.location.reload(); }
|
||||
else alert(d.error);
|
||||
if (d.success) { Notify.success(d.message); closeModal('giveItemModal'); window.location.reload(); }
|
||||
else Notify.error(d.error);
|
||||
}
|
||||
|
||||
// ====== DELETE ITEM ======
|
||||
async function deleteItem(invId) {
|
||||
if (!confirm('Удалить предмет?')) return;
|
||||
const res = await fetch(`/admin/api/user/${userId}/delete-item/${invId}`, { method:'POST' });
|
||||
const d = await res.json();
|
||||
if (d.success) window.location.reload();
|
||||
else alert(d.error);
|
||||
Notify.confirm('Удалить предмет?', 'Подтверждение', async function(ok) {
|
||||
if (!ok) return;
|
||||
const res = await fetch(`/admin/api/user/${userId}/delete-item/${invId}`, { method:'POST' });
|
||||
const d = await res.json();
|
||||
if (d.success) window.location.reload();
|
||||
else Notify.error(d.error);
|
||||
});
|
||||
}
|
||||
|
||||
// ====== TOGGLE ADMIN / BAN ======
|
||||
async function toggleAdmin() {
|
||||
if (!confirm('Изменить статус админа?')) return;
|
||||
const res = await fetch(`/admin/api/user/${userId}/toggle-admin`, { method:'POST' });
|
||||
const d = await res.json();
|
||||
if (d.success) window.location.reload(); else alert(d.error);
|
||||
Notify.confirm('Изменить статус админа?', 'Подтверждение', async function(ok) {
|
||||
if (!ok) return;
|
||||
const res = await fetch(`/admin/api/user/${userId}/toggle-admin`, { method:'POST' });
|
||||
const d = await res.json();
|
||||
if (d.success) window.location.reload(); else Notify.error(d.error);
|
||||
});
|
||||
}
|
||||
async function toggleBan() {
|
||||
if (!confirm('{{ "Забанить" if not target_user.is_banned else "Разбанить" }}?')) return;
|
||||
const res = await fetch(`/admin/api/user/${userId}/toggle-ban`, { method:'POST' });
|
||||
const d = await res.json();
|
||||
if (d.success) window.location.reload(); else alert(d.error);
|
||||
Notify.confirm('{{ "Забанить" if not target_user.is_banned else "Разбанить" }}?', 'Подтверждение', async function(ok) {
|
||||
if (!ok) return;
|
||||
const res = await fetch(`/admin/api/user/${userId}/toggle-ban`, { method:'POST' });
|
||||
const d = await res.json();
|
||||
if (d.success) window.location.reload(); else Notify.error(d.error);
|
||||
});
|
||||
}
|
||||
|
||||
// ====== RPU ======
|
||||
@@ -277,16 +284,18 @@ async function saveRPU() {
|
||||
fd.append('auto_adjust', document.getElementById('rpuAutoAdjust').checked);
|
||||
const res = await fetch(`/admin/api/user/${userId}/rpu/update`, { method:'POST', body:fd });
|
||||
const d = await res.json();
|
||||
if (d.success) { alert(d.message); closeModal('rpuModal'); loadRPU(); }
|
||||
else alert(d.error);
|
||||
if (d.success) { Notify.success(d.message); closeModal('rpuModal'); loadRPU(); }
|
||||
else Notify.error(d.error);
|
||||
}
|
||||
async function setRPUPreset(preset) {
|
||||
const names = { lucky:'🍀 Везучий', normal:'📊 Обычный', unlucky:'🌧️ Невезучий', very_unlucky:'💀 Проклятый' };
|
||||
if (!confirm('Применить "'+names[preset]+'"?')) return;
|
||||
const fd = new FormData(); fd.append('preset', preset);
|
||||
const res = await fetch(`/admin/api/user/${userId}/rpu/preset`, { method:'POST', body:fd });
|
||||
const d = await res.json();
|
||||
if (d.success) { alert(d.message); loadRPU(); } else alert(d.error);
|
||||
Notify.confirm('Применить "'+names[preset]+'"?', 'Подтверждение', async function(ok) {
|
||||
if (!ok) return;
|
||||
const fd = new FormData(); fd.append('preset', preset);
|
||||
const res = await fetch(`/admin/api/user/${userId}/rpu/preset`, { method:'POST', body:fd });
|
||||
const d = await res.json();
|
||||
if (d.success) { Notify.success(d.message); loadRPU(); } else Notify.error(d.error);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', loadRPU);
|
||||
|
||||
Reference in New Issue
Block a user