34 lines
1.4 KiB
JavaScript
34 lines
1.4 KiB
JavaScript
|
|
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 = 'Ошибка соединения';
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|