From 4ead66b576c342dfe2248e23b830974f38b43eb3 Mon Sep 17 00:00:00 2001 From: Eejit <76887639+Eejit43@users.noreply.github.com> Date: Wed, 27 Dec 2023 12:02:10 -0500 Subject: [PATCH] feat(radical-simplifier): put operand input first --- src/public/scripts/pages/tools/radical-simplifier.ts | 8 ++++---- src/views/pages/tools/radical-simplifier.hbs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/public/scripts/pages/tools/radical-simplifier.ts b/src/public/scripts/pages/tools/radical-simplifier.ts index dad5b18..494b75b 100644 --- a/src/public/scripts/pages/tools/radical-simplifier.ts +++ b/src/public/scripts/pages/tools/radical-simplifier.ts @@ -9,18 +9,18 @@ declare global { } } +const operandInput = document.querySelector('#operand') as HTMLInputElement; const indexInput = document.querySelector('#index') as HTMLInputElement; const radicandInput = document.querySelector('#radicand') as HTMLInputElement; -const operandInput = document.querySelector('#operand') as HTMLInputElement; const simplifyButton = document.querySelector('#simplify') as HTMLButtonElement; const resetButton = document.querySelector('#reset') as HTMLButtonElement; const output = document.querySelector('#output') as HTMLSpanElement; const message = document.querySelector('#message') as HTMLSpanElement; for (const event of ['input', 'paste']) { + operandInput.addEventListener(event, () => (operandInput.value = operandInput.value.replaceAll(/\D/g, ''))); indexInput.addEventListener(event, () => (indexInput.value = indexInput.value.replaceAll(/\D/g, ''))); radicandInput.addEventListener(event, () => (radicandInput.value = radicandInput.value.replaceAll(/[^\d-]/g, '').replaceAll(/(? (operandInput.value = operandInput.value.replaceAll(/\D/g, ''))); } for (const input of [indexInput, radicandInput, operandInput]) input.addEventListener('keydown', (event) => (event.key === 'Enter' ? simplifyButton.click() : null)); @@ -35,8 +35,8 @@ simplifyButton.addEventListener('click', () => { message.textContent = ''; output.classList.remove('hidden'); - const index = indexInput.value ? Number.parseInt(indexInput.value) : 2; const operand = operandInput.value ? Number.parseInt(operandInput.value) : 1; + const index = indexInput.value ? Number.parseInt(indexInput.value) : 2; const originalRadicand = Number.parseInt(radicandInput.value); const negativeRadicand = originalRadicand < 0; @@ -85,9 +85,9 @@ simplifyButton.addEventListener('click', () => { resetButton.addEventListener('click', () => { message.textContent = 'Nothing yet!'; output.classList.add('hidden'); + operandInput.value = ''; indexInput.value = ''; radicandInput.value = ''; - operandInput.value = ''; showAlert('Reset!', 'success'); }); diff --git a/src/views/pages/tools/radical-simplifier.hbs b/src/views/pages/tools/radical-simplifier.hbs index 83ffa2c..1224671 100644 --- a/src/views/pages/tools/radical-simplifier.hbs +++ b/src/views/pages/tools/radical-simplifier.hbs @@ -1,5 +1,9 @@

Input (\(operand \cdot \sqrt[index]{radicand}\)):

+
+ Operand: + +
Index: @@ -8,10 +12,6 @@ Radicand:
-
- Operand: - -