Spaces:
Running
Running
File size: 2,683 Bytes
8058d85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
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()
}));
}
}); |