Conversor de Dados
Entrar
Cadastrar
U
Usuario
Minha Conta
Meus Links
Sair
Conversor de Dados
Converta unidades de armazenamento de dados entre bits, bytes, KB, MB, GB, TB e PB
Valor
Unidade
Bits
Bytes
Kilobytes (KB)
Megabytes (MB)
Gigabytes (GB)
Terabytes (TB)
Petabytes (PB)
Binario (1024)
Decimal (1000)
Unidade
Binario (1024)
Decimal (1000)
Limpar
Copiar Resultados
`; resultsGrid.appendChild(resultCard); }); // Populate comparison table const tableBody = document.getElementById('tableBody'); tableBody.innerHTML = ''; units.forEach(unit => { const convertedValue = valueInBits / factors[unit]; const row = document.createElement('tr'); row.innerHTML = `
${unitLabels[unit]}
${formatNumber(convertedValue)}
`; tableBody.appendChild(row); }); document.getElementById('copyBtn').disabled = false; } // Switch between binary and decimal modes function switchMode(mode) { currentMode = mode; document.querySelectorAll('.mode-btn').forEach(btn => { btn.classList.toggle('active', btn.dataset.mode === mode); }); const binaryHeader = document.getElementById('binaryHeader'); const decimalHeader = document.getElementById('decimalHeader'); if (mode === 'binary') { binaryHeader.style.display = ''; decimalHeader.style.display = 'none'; } else { binaryHeader.style.display = 'none'; decimalHeader.style.display = ''; } convert(); } // Clear all fields function clearFields() { document.getElementById('inputValue').value = ''; document.getElementById('inputUnit').value = 'byte'; document.getElementById('resultsGrid').innerHTML = ''; document.getElementById('tableBody').innerHTML = ''; document.getElementById('copyBtn').disabled = true; } // Copy all results function copyAllResults() { const inputValue = document.getElementById('inputValue').value; const inputUnit = document.getElementById('inputUnit').value; if (!inputValue) { showToast('Nenhum valor para copiar', 'error'); return; } const factors = currentMode === 'binary' ? binaryFactors : decimalFactors; const valueInBits = parseFloat(inputValue) * factors[inputUnit]; let copyText = `Conversor de Dados - ${currentMode === 'binary' ? 'Binario (1024)' : 'Decimal (1000)'}\n\n`; copyText += `Entrada: ${inputValue} ${unitLabels[inputUnit]}\n\n`; copyText += 'Conversoes:\n'; units.forEach(unit => { const convertedValue = valueInBits / factors[unit]; copyText += `${unitLabels[unit]}: ${formatNumber(convertedValue)}\n`; }); try { navigator.clipboard.writeText(copyText); showToast('Resultados copiados!', 'success'); } catch (e) { showToast('Erro ao copiar', 'error'); } } // Allow Enter key to convert document.getElementById('inputValue').addEventListener('keypress', function(e) { if (e.key === 'Enter') convert(); }); // Initialize with default values convert();