first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// ═══════════════════════════════════════════════════════
|
||||
// Number Base Converter
|
||||
// ═══════════════════════════════════════════════════════
|
||||
async function convertNumber() {
|
||||
const v = document.getElementById('numInput').value.trim();
|
||||
if (!v) return setStatus('numStatus','error','Enter a number.');
|
||||
const d = await apiPost('/api/number/convert', { value: v, fromBase: document.getElementById('numBase').value });
|
||||
if (d.success) {
|
||||
document.getElementById('numResults').innerHTML = [
|
||||
['Decimal', d.decimal], ['Binary', d.binary], ['Octal', d.octal], ['Hexadecimal', d.hex]
|
||||
].map(([l, v]) => `<div class="result-row"><div class="label">${l}</div><div class="value" onclick="copyText(this.textContent)">${v}</div></div>`).join('');
|
||||
setStatus('numStatus','success','Converted ✓');
|
||||
} else setStatus('numStatus','error', d.error);
|
||||
}
|
||||
|
||||
// Keyboard shortcut
|
||||
document.getElementById('numInput').addEventListener('keydown', e => { if(e.key==='Enter') convertNumber(); });
|
||||
|
||||
Reference in New Issue
Block a user