Переписал уведомления: toast/confirm вместо alert; объединил профиль+инвентарь; починил ленту активности
This commit is contained in:
@@ -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