Spaces:
Running
Running
remova mais funções desnecessarias
Browse files831 unmodified lines832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908240 unmodified lines11491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258831 unmodified lines};reader.readAsArrayBuffer(file);}// Analyze column types (date, number, text)function analyzeColumnTypes() {console.log('Analyzing column types for auto chart generation...');columnTypes = [];if (columns.length === 0 || rawData.length === 0) return;// Check first 20 rows to determine typeconst sampleRows = rawData.slice(0, Math.min(20, rawData.length));columns.forEach((col, colIndex) => {let dateCount = 0;let numberCount = 0;let emptyCount = 0;sampleRows.forEach(row => {const value = row[colIndex];if (value === null || value === undefined || value === '') {emptyCount++;return;}// Check if it's a date (Excel date or string date)if (value instanceof Date) {dateCount++;} else if (typeof value === 'string') {// Try to parse as dateconst dateFormats = ['YYYY-MM-DD', 'MM/DD/YYYY', 'DD/MM/YYYY','YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY'];for (const format of dateFormats) {if (moment(value, format, true).isValid()) {dateCount++;return;}}// Check if it's a numberif (!isNaN(value) && value.trim() !== '') {numberCount++;}} else if (typeof value === 'number') {// Excel stores dates as numbers (days since 1900)// If the number is between 0 and 100,000, it might be a dateif (value > 0 && value < 100000) {dateCount++;} else {numberCount++;}}});// Determine the most likely typeconst total = sampleRows.length - emptyCount;if (total === 0) {columnTypes[colIndex] = 'text';} else if (dateCount / total > 0.7) {columnTypes[colIndex] = 'date';} else if (numberCount / total > 0.7) {columnTypes[colIndex] = 'number';} else {columnTypes[colIndex] = 'text';}});}// Format file sizefunction formatFileSize(bytes) {if (bytes === 0) return '0 Bytes';const k = 1024;240 unmodified linescolumnStats.appendChild(row);});}// Initialize multiselect componentfunction initMultiselect(id) {const container = document.getElementById(id);const selectedContainer = container.querySelector('.multiselect-selected');const input = container.querySelector('.multiselect-input');const dropdown = container.querySelector('.dropdown-content');const optionsContainer = container.querySelector('.multiselect-options');// Toggle dropdown on input focusinput.addEventListener('focus', function() {dropdown.classList.remove('hidden');input.placeholder = 'Type to search...';});// Close dropdown when clicking outsidedocument.addEventListener('click', function(e) {if (!container.contains(e.target)) {dropdown.classList.add('hidden');input.placeholder = 'Select columns...';}});// Search within optionsinput.addEventListener('input', function(e) {const searchTerm = e.target.value.toLowerCase();const options = optionsContainer.querySelectorAll('.multiselect-option-item');options.forEach(option => {const text = option.textContent.toLowerCase();if (text.includes(searchTerm)) {option.classList.remove('hidden');} else {option.classList.add('hidden');}});});}// Update multiselect optionsfunction updateMultiselectOptions(id, options) {const container = document.getElementById(id);const optionsContainer = container.querySelector('.multiselect-options');optionsContainer.innerHTML = '';options.forEach((option, index) => {const optionItem = document.createElement('div');optionItem.className = 'multiselect-option-item px-4 py-2 hover:bg-gray-700 cursor-pointer flex justify-between items-center';optionItem.innerHTML = `<span>${option}</span><span class="text-xs ${getTypeColorClass(columnTypes[index])}">${columnTypes[index]}</span>`;optionItem.dataset.value = index;optionItem.addEventListener('click', function() {addSelectedOption(id, option, index);});optionsContainer.appendChild(optionItem);});}// Add selected option to multiselectfunction addSelectedOption(id, option, index) {const container = document.getElementById(id);const selectedContainer = container.querySelector('.multiselect-selected');// Check if option is already selectedconst existingOption = selectedContainer.querySelector(`[data-value="${index}"]`);if (existingOption) return;// Create selected option tagconst selectedOption = document.createElement('div');selectedOption.className = 'multiselect-option bg-indigo-900 text-indigo-100 flex items-center';selectedOption.dataset.value = index;selectedOption.dataset.type = columnTypes[index];const optionText = document.createElement('span');optionText.textContent = option;const typeBadge = document.createElement('span');typeBadge.className = `ml-2 text-xs ${getTypeColorClass(columnTypes[index])}`;typeBadge.textContent = columnTypes[index];const removeButton = document.createElement('span');removeButton.className = 'multiselect-option-remove ml-2';removeButton.innerHTML = '×';removeButton.addEventListener('click', function(e) {e.stopPropagation();selectedOption.remove();});selectedOption.appendChild(optionText);selectedOption.appendChild(typeBadge);selectedOption.appendChild(removeButton);selectedContainer.appendChild(selectedOption);// Clear input and hide dropdowncontainer.querySelector('.multiselect-input').value = '';container.querySelector('.dropdown-content').classList.add('hidden');}// Get selected options from multiselectfunction getSelectedOptions(id) {const container = document.getElementById(id);const selectedOptions = container.querySelectorAll('.multiselect-selected [data-value]');831 unmodified lines832833834835836837838839840841842843844845846847848240 unmodified lines1089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128831 unmodified lines};reader.readAsArrayBuffer(file);}// Simplified column type analysisfunction analyzeColumnTypes() {columnTypes = [];if (columns.length === 0 || rawData.length === 0) return;columns.forEach((col, colIndex) => {// Default to text for simplicitycolumnTypes[colIndex] = 'text';});}// Format file sizefunction formatFileSize(bytes) {if (bytes === 0) return '0 Bytes';const k = 1024;240 unmodified linescolumnStats.appendChild(row);});}// Simplified multiselect initfunction initMultiselect(id) {const container = document.getElementById(id);const input = container.querySelector('.multiselect-input');const dropdown = container.querySelector('.dropdown-content');input.addEventListener('focus', () => dropdown.classList.remove('hidden'));input.addEventListener('blur', () => dropdown.classList.add('hidden'));}// Simplified update multiselect optionsfunction updateMultiselectOptions(id, options) {const optionsContainer = document.querySelector(`#${id} .multiselect-options`);optionsContainer.innerHTML = options.map((option, index) => `<div class="multiselect-option-item px-4 py-2 hover:bg-gray-700 cursor-pointer"data-value="${index}"onclick="addSelectedOption('${id}', '${option}', ${index})">${option}</div>`).join('');}// Simplified add selected optionfunction addSelectedOption(id, option, index) {const selectedContainer = document.querySelector(`#${id} .multiselect-selected`);if (selectedContainer.querySelector(`[data-value="${index}"]`)) return;selectedContainer.innerHTML += `<div class="multiselect-option bg-indigo-900 text-indigo-100 p-1 m-1 rounded">${option}<span class="ml-2 cursor-pointer" onclick="this.parentNode.remove()">×</span></div>`;}// Get selected options from multiselectfunction getSelectedOptions(id) {const container = document.getElementById(id);const selectedOptions = container.querySelectorAll('.multiselect-selected [data-value]');
index.html+28-158