/
efr
/
SmartCity
Обзор
Документация
Войти
/
efr
/
SmartCity
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
static/js/undo.js
32 строки
1 KB
Sergey
add_project
27 фев 2025, 19:33
27 фев 2025, 19:33
7eeda08
Код
Авторство
О чём код?
const manifestUrl = localStorage.getItem('manifestUrl'); if (!manifestUrl) window.location.href = '/manifest.html'; async function undoLastAction() { try { const response = await fetch('/api/tools/undo', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({camera_url: manifestUrl}) }); if (!response.ok) throw new Error('Ошибка при отмене действия'); window.dispatchEvent(new Event('tools-updated')); console.log('Последнее действие отменено'); } catch (error) { console.error('Ошибка:', error); } } document.getElementById('undo-button').addEventListener('click', async () => { if (!document.getElementById('undo-button').classList.contains('disabled')) { await undoLastAction(); } }); document.addEventListener('keydown', e => { if ((e.ctrlKey || e.metaKey) && e.code === 'KeyZ') { e.preventDefault(); undoLastAction(); } });