Blog de Utilidades
Relógio
00:00:00
Calculadora
7
8
9
/
4
5
6
*
1
2
3
-
0
.
=
+
Limpar
Conversor de Moedas
Dólar (USD)
Real (BRL)
Euro (EUR)
para
Real (BRL)
Dólar (USD)
Euro (EUR)
// Relógio em Tempo Real function updateClock() { const now = new Date(); const time = now.toLocaleTimeString(); document.getElementById('clock').textContent = time; } setInterval(updateClock, 1000); updateClock(); // Calculadora let display = document.getElementById('display'); function appendToDisplay(value) { display.value += value; } function clearDisplay() { display.value = ''; } function calculate() { try { display.value = eval(display.value); } catch { display.value = 'Erro'; } } // Conversor de Moedas (simulado - use uma API real) async function convertCurrency() { const amount = document.getElementById('amount').value; const from = document.getElementById('from-currency').value; const to = document.getElementById('to-currency').value; // Simulação (substitua por uma chamada de API real) const fakeRates = { USD: 5.0, BRL: 1, EUR: 6.0 }; // Exemplo: 1 USD = 5 BRL const rate = fakeRates[to] / fakeRates[from]; const result = (amount * rate).toFixed(2); document.getElementById('result').textContent = `${amount} ${from} = ${result} ${to}`; // Para usar uma API real, descomente o código abaixo e insira sua chave: /* const apiKey = 'ad7105d38da3aa9e49a2ff0620493a26e02dfccba199dc34c6041a45d0d94067'; // Ex: ExchangeRate-API const response = await fetch(`https://v6.exchangerate-api.com/v6/${apiKey}/latest/${from}`); const data = await response.json(); const rate = data.conversion_rates[to]; const result = (amount * rate).toFixed(2); document.getElementById('result').textContent = `${amount} ${from} = ${result} ${to}`; */ }