PIbd-22_Turner_I.A._IP/Frontend/script.js

42 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-02-28 10:16:20 +04:00
let buttonSum = document.getElementById("buttonSum");
let buttonMinus = document.getElementById("buttonMinus");
2023-02-14 12:37:40 +04:00
let buttonReverse = document.getElementById("buttonReverse");
2023-02-28 10:16:20 +04:00
let buttonComparison = document.getElementById("buttonComparison");
let numberOneInput = document.getElementById("first");
let numberTwoInput = document.getElementById("second");
let typeInput = document.getElementById("type");
2023-02-14 12:37:40 +04:00
let resultInput = document.getElementById("res");
2023-02-28 10:16:20 +04:00
buttonSum.onclick = function(event) {
let num_1 = numberOneInput.value;
let num_2 = numberTwoInput.value;
let type = typeInput.value;
fetch(`http://localhost:8080/sum?first=${num_1}&second=${num_2}&type=${type}`)
2023-02-14 12:37:40 +04:00
.then(response => response.text())
.then(res => resultInput.value = res);
}
2023-02-28 10:16:20 +04:00
buttonMinus.onclick = function(event) {
let num_1 = numberOneInput.value;
let num_2 = numberTwoInput.value;
let type = typeInput.value;
fetch(`http://localhost:8080/minus?first=${num_1}&second=${num_2}&type=${type}`)
2023-02-14 12:37:40 +04:00
.then(response => response.text())
.then(res => resultInput.value = res);
}
buttonReverse.onclick = function(event) {
2023-02-28 10:16:20 +04:00
let num_1 = numberOneInput.value;
let num_2 = numberTwoInput.value;
let type = typeInput.value;
fetch(`http://localhost:8080/reverse?first=${num_1}&second=${num_2}&type=${type}`)
2023-02-14 12:37:40 +04:00
.then(response => response.text())
.then(res => resultInput.value = res);
}
2023-02-28 10:16:20 +04:00
buttonComparison.onclick = function(event) {
let num_1 = numberOneInput.value;
let num_2 = numberTwoInput.value;
let type = typeInput.value;
fetch(`http://localhost:8080/comparison?first=${num_1}&second=${num_2}&type=${type}`)
2023-02-14 12:37:40 +04:00
.then(response => response.text())
.then(res => resultInput.value = res);
}