test-simple-calculator/index.html
viet-anh.n e976e0cb4b [TSC-10] Implement calculation engine with arithmetic operations
Add calculator.js with a pure calculate(a, b, operation) engine returning
{result} or {error}, wired to the existing HTML UI via an IIFE. Update
index.html to load the script and CLAUDE.md to document the new module.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-08 07:56:54 +00:00

57 lines
1.9 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<main>
<h1>Simple Calculator</h1>
<form id="calculator-form" novalidate>
<fieldset>
<legend>Operands</legend>
<div>
<label for="operand1">First Number</label>
<input type="number" id="operand1" name="operand1" step="any" required aria-required="true" autocomplete="off">
</div>
<div>
<label for="operand2">Second Number</label>
<input type="number" id="operand2" name="operand2" step="any" required aria-required="true" autocomplete="off">
</div>
</fieldset>
<fieldset>
<legend>Operation</legend>
<div role="group" aria-label="Select operation">
<button type="button" name="operation" value="add" aria-pressed="false">Add (+)</button>
<button type="button" name="operation" value="subtract" aria-pressed="false">Subtract ()</button>
<button type="button" name="operation" value="multiply" aria-pressed="false">Multiply (×)</button>
<button type="button" name="operation" value="divide" aria-pressed="false">Divide (÷)</button>
</div>
</fieldset>
<div>
<button type="submit" id="calculate-btn">Calculate</button>
<button type="reset" id="clear-btn">Clear</button>
</div>
</form>
<section aria-live="polite" aria-atomic="true">
<h2>Result</h2>
<output id="result" for="operand1 operand2" aria-label="Calculation result"></output>
</section>
<section aria-live="assertive" aria-atomic="true">
<p id="error-message" role="alert" aria-label="Error message"></p>
</section>
</main>
<script src="calculator.js"></script>
</body>
</html>