2023-02-07 10:52:36 +04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
2023-02-21 11:20:02 +04:00
|
|
|
<title>Calculator</title>
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/chota@latest">
|
2023-02-07 10:52:36 +04:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2023-02-21 11:20:02 +04:00
|
|
|
<div class="container" style="max-width:600px">
|
|
|
|
<div class="card row is-full-screen is-center">
|
|
|
|
<div class="col">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<input type="text" id="value1">
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<select id="operation">
|
|
|
|
<option value="sum" selected>+</option>
|
|
|
|
<option value="sub">-</option>
|
|
|
|
<option value="mul">*</option>
|
|
|
|
<option value="invert">~</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<input type="text" id="value2">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<button type="button" id="get-int-result" onclick="calculate('intops')">Result for int</button>
|
|
|
|
</div>
|
|
|
|
<div class="col is-right">
|
|
|
|
<button type="button" id="get-string-result" onclick="calculate('stringops')">Result for string</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card row is-center">
|
|
|
|
<h5 class="is-center" id="result"></h5>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2023-02-07 10:52:36 +04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2023-02-21 11:20:02 +04:00
|
|
|
async function calculate(ops) {
|
|
|
|
const value1 = document.getElementById("value1").value
|
|
|
|
const value2 = document.getElementById("value2").value
|
|
|
|
const op = document.getElementById("operation").value
|
|
|
|
if (op == 'sum') {
|
|
|
|
document.getElementById("result").innerHTML = await (await fetch(`http://127.0.0.1:8080/sum?value1=${value1}&value2=${value2}&ops=${ops}`)).text()
|
|
|
|
} else if (op == 'sub') {
|
|
|
|
document.getElementById("result").innerHTML = await (await fetch(`http://127.0.0.1:8080/sub?value1=${value1}&value2=${value2}&ops=${ops}`)).text()
|
|
|
|
} else if (op == 'mul') {
|
|
|
|
document.getElementById("result").innerHTML = await (await fetch(`http://127.0.0.1:8080/mul?value=${value1}&count=${value2}&ops=${ops}`)).text()
|
|
|
|
} else {
|
|
|
|
document.getElementById("result").innerHTML = await (await fetch(`http://127.0.0.1:8080/invert?value=${value1}&ops=${ops}`)).text()
|
|
|
|
}
|
|
|
|
|
2023-02-07 10:52:36 +04:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|