42 lines
1.7 KiB
JavaScript
42 lines
1.7 KiB
JavaScript
let buttonSum = document.getElementById("buttonSum");
|
|
let buttonMinus = document.getElementById("buttonMinus");
|
|
let buttonReverse = document.getElementById("buttonReverse");
|
|
let buttonComparison = document.getElementById("buttonComparison");
|
|
let numberOneInput = document.getElementById("first");
|
|
let numberTwoInput = document.getElementById("second");
|
|
let typeInput = document.getElementById("type");
|
|
let resultInput = document.getElementById("res");
|
|
|
|
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}`)
|
|
.then(response => response.text())
|
|
.then(res => resultInput.value = res);
|
|
}
|
|
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}`)
|
|
.then(response => response.text())
|
|
.then(res => resultInput.value = res);
|
|
}
|
|
buttonReverse.onclick = function(event) {
|
|
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}`)
|
|
.then(response => response.text())
|
|
.then(res => resultInput.value = res);
|
|
}
|
|
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}`)
|
|
.then(response => response.text())
|
|
.then(res => resultInput.value = res);
|
|
}
|