Joywork/js/admin/clean_cache.js

34 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
document.addEventListener('DOMContentLoaded', function () {
const btn = document.getElementById('clear-cache-btn');
const notification = document.getElementById('cache-notification');
btn.addEventListener('click', function () {
notification.style.display = 'block';
notification.style.background = '#fff3cd';
notification.style.color = '#856404';
notification.innerHTML = 'Обновляем кэш...';
fetch('/admin/ajax/build-assets.php')
.then(response => {
if (!response.ok) {
throw new Error('Ошибка сети');
}
return response.json();
})
.then(data => {
notification.style.background = data.success ? '#d4edda' : '#f8d7da';
notification.style.color = data.success ? '#155724' : '#721c24';
notification.innerHTML = data.message;
setTimeout(() => {
notification.style.display = 'none';
}, 5000);
})
.catch(error => {
console.error('Ошибка:', error);
notification.style.display = 'block';
notification.style.background = '#f8d7da';
notification.style.color = '#721c24';
notification.innerHTML = 'Ошибка соединения';
});
});
});