2023-02-13 17:27:49 +04:00
|
|
|
let calculateButton = document.getElementById("calculate");
|
|
|
|
let numberOneInput = document.getElementById("first");
|
|
|
|
let numberTwoInput = document.getElementById("second");
|
|
|
|
let resultInput = document.getElementById("res");
|
2023-02-27 17:00:41 +04:00
|
|
|
let typeInput = document.getElementById("type");
|
2023-02-13 17:27:49 +04:00
|
|
|
|
|
|
|
buttonPlus.onclick = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
let num_1 = numberOneInput.value;
|
|
|
|
let num_2 = numberTwoInput.value;
|
2023-02-27 17:00:41 +04:00
|
|
|
let type = typeInput.value;
|
|
|
|
fetch(`http://localhost:8080/sum?first=${num_1}&second=${num_2}&type=${type}`)
|
2023-02-13 17:27:49 +04:00
|
|
|
.then(response => response.text())
|
2023-02-13 17:45:53 +04:00
|
|
|
.then(res => {
|
2023-02-27 17:00:41 +04:00
|
|
|
resultInput.value = res;
|
2023-02-13 17:45:53 +04:00
|
|
|
});
|
2023-02-13 17:27:49 +04:00
|
|
|
}
|
|
|
|
buttonMinus.onclick = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
let num_1 = numberOneInput.value;
|
|
|
|
let num_2 = numberTwoInput.value;
|
2023-02-27 17:00:41 +04:00
|
|
|
let type = typeInput.value;
|
|
|
|
fetch(`http://localhost:8080/minus?first=${num_1}&second=${num_2}&type=${type}`)
|
2023-02-13 17:27:49 +04:00
|
|
|
.then(response => response.text())
|
2023-02-13 17:45:53 +04:00
|
|
|
.then(res => {
|
2023-02-27 17:00:41 +04:00
|
|
|
resultInput.value = res;
|
2023-02-13 17:45:53 +04:00
|
|
|
});
|
2023-02-13 17:27:49 +04:00
|
|
|
}
|
|
|
|
buttonMulti.onclick = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
let num_1 = numberOneInput.value;
|
|
|
|
let num_2 = numberTwoInput.value;
|
2023-02-27 17:00:41 +04:00
|
|
|
let type = typeInput.value;
|
|
|
|
fetch(`http://localhost:8080/multi?first=${num_1}&second=${num_2}&type=${type}`)
|
2023-02-13 17:27:49 +04:00
|
|
|
.then(response => response.text())
|
2023-02-13 17:45:53 +04:00
|
|
|
.then(res => {
|
2023-02-27 17:00:41 +04:00
|
|
|
resultInput.value = res;
|
2023-02-13 17:45:53 +04:00
|
|
|
});
|
2023-02-13 17:27:49 +04:00
|
|
|
}
|
|
|
|
buttonDiv.onclick = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
let num_1 = numberOneInput.value;
|
|
|
|
let num_2 = numberTwoInput.value;
|
2023-02-27 17:00:41 +04:00
|
|
|
let type = typeInput.value;
|
|
|
|
fetch(`http://localhost:8080/div?first=${num_1}&second=${num_2}&type=${type}`)
|
2023-02-13 17:27:49 +04:00
|
|
|
.then(response => response.text())
|
2023-02-13 17:45:53 +04:00
|
|
|
.then(res =>
|
|
|
|
{
|
2023-02-27 17:00:41 +04:00
|
|
|
resultInput.value = res;
|
2023-02-13 17:45:53 +04:00
|
|
|
});
|
|
|
|
}
|