Spaces:
Running
Running
| document.addEventListener('DOMContentLoaded', function() { | |
| // UI Elements | |
| const splashScreen = document.getElementById('splashScreen'); | |
| const mainContent = document.getElementById('mainContent'); | |
| const fileModal = document.getElementById('fileModal'); | |
| const modalTitle = document.getElementById('modalTitle'); | |
| const fileInput = document.getElementById('fileInput'); | |
| const cancelBtn = document.getElementById('cancelBtn'); | |
| const confirmBtn = document.getElementById('confirmBtn'); | |
| // Button handlers | |
| document.getElementById('loadConfig').addEventListener('click', () => showFileModal('Настройка')); | |
| document.getElementById('load1C').addEventListener('click', () => showFileModal('1C Data')); | |
| document.getElementById('loadFlight').addEventListener('click', () => showFileModal('Flight Data')); | |
| document.getElementById('loadPosition').addEventListener('click', () => showFileModal('Position Data')); | |
| document.getElementById('continueBtn').addEventListener('click', continueToMain); | |
| document.getElementById('exitBtn').addEventListener('click', exitApp); | |
| cancelBtn.addEventListener('click', closeFileModal); | |
| confirmBtn.addEventListener('click', processFile); | |
| function showFileModal(title) { | |
| modalTitle.textContent = `Загрузка файла ${title}`; | |
| fileInput.value = ''; | |
| fileModal.style.display = 'flex'; | |
| } | |
| function closeFileModal() { | |
| fileModal.style.display = 'none'; | |
| } | |
| function processFile() { | |
| const file = fileInput.files[0]; | |
| if (!file) return; | |
| // Here we would process the file based on the modal title | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| const data = new Uint8Array(e.target.result); | |
| const workbook = XLSX.read(data, { type: 'array' }); | |
| // Process workbook based on file type | |
| // TODO: Add specific processing for each file type | |
| closeFileModal(); | |
| }; | |
| reader.readAsArrayBuffer(file); | |
| } | |
| function continueToMain() { | |
| splashScreen.style.display = 'none'; | |
| mainContent.style.display = 'flex'; | |
| // Load initial data here | |
| } | |
| function exitApp() { | |
| if (confirm('Вы уверены, что хотите выйти?')) { | |
| window.close(); | |
| } | |
| } | |
| // Initialize database | |
| if (!window.localStorage.getItem('employeeDB')) { | |
| window.localStorage.setItem('employeeDB', JSON.stringify({ | |
| employees: [], | |
| lastUpdate: new Date().toISOString() | |
| })); | |
| } | |
| }); |