mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-15 18:12:08 -05:00
84 lines
2.4 KiB
HTML
84 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>calc</title>
|
|
<link rel="stylesheet" href="/style.css">
|
|
<link rel="stylesheet" href="/themes.css">
|
|
<style>
|
|
input[type="button"] {
|
|
width: 60px;
|
|
height: 50px;
|
|
font-size: 20px;
|
|
}
|
|
center {
|
|
display: block !important;
|
|
margin-left: auto !important;
|
|
margin-right: auto !important;
|
|
text-align: center !important;
|
|
}
|
|
table {
|
|
width: 80%;
|
|
border-collapse: collapse;
|
|
}
|
|
button {
|
|
font-size:30px;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<center>
|
|
<h2>calc</h2>
|
|
<table>
|
|
<tr>
|
|
<td colspan="4"><input type="text" id="display" disabled></td>
|
|
</tr>
|
|
<tr>
|
|
<td><button value="7" onclick="appendToDisplay('7')">7</button></td>
|
|
<td><button value="8" onclick="appendToDisplay('8')">8</button></td>
|
|
<td><button value="9" onclick="appendToDisplay('9')">9</button></td>
|
|
<td><button value="/" onclick="appendToDisplay('/')">/</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td><button value="4" onclick="appendToDisplay('4')">4</button></td>
|
|
<td><button value="5" onclick="appendToDisplay('5')">5</button></td>
|
|
<td><button value="6" onclick="appendToDisplay('6')">6</button></td>
|
|
<td><button value="-" onclick="appendToDisplay('-')">-</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td><button value="1" onclick="appendToDisplay('1')">1</button></td>
|
|
<td><button value="2" onclick="appendToDisplay('2')">2</button></td>
|
|
<td><button value="3" onclick="appendToDisplay('3')">3</button></td>
|
|
<td><button value="+" onclick="appendToDisplay('+')">+</button></td>
|
|
</tr>
|
|
<tr>
|
|
<td><button value="0" onclick="appendToDisplay('0')">0</button></td>
|
|
<td><button value="." onclick="appendToDisplay('.')">.</button></td>
|
|
<td><button value="=" onclick="calculate()">=</button></td>
|
|
<td><button value="C" onclick="clearDisplay()">C</button></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<script>
|
|
function appendToDisplay(value) {
|
|
document.getElementById('display').value += value;
|
|
}
|
|
|
|
function calculate() {
|
|
try {
|
|
document.getElementById('display').value = eval(document.getElementById('display').value);
|
|
} catch (error) {
|
|
document.getElementById('display').value = 'Error';
|
|
}
|
|
}
|
|
|
|
function clearDisplay() {
|
|
document.getElementById('display').value = '';
|
|
}
|
|
</script>
|
|
</center>
|
|
</body>
|
|
</html>
|