2023-02-20 22:25:28 +04:00
|
|
|
function setResult(result) {
|
|
|
|
let lbl = `<label class="bg-success">Ответ:${result}</label>`;
|
|
|
|
document.getElementById("result").innerHTML = lbl;
|
|
|
|
}
|
2023-03-07 10:42:01 +04:00
|
|
|
|
|
|
|
|
2023-02-20 22:25:28 +04:00
|
|
|
function add(){
|
2023-03-07 10:42:01 +04:00
|
|
|
executeRequest("add");
|
2023-02-20 22:25:28 +04:00
|
|
|
}
|
2023-03-07 10:42:01 +04:00
|
|
|
|
2023-02-20 22:25:28 +04:00
|
|
|
function sub(){
|
2023-03-07 10:42:01 +04:00
|
|
|
executeRequest("sub");
|
2023-02-20 22:25:28 +04:00
|
|
|
}
|
2023-03-07 10:42:01 +04:00
|
|
|
|
2023-02-20 22:25:28 +04:00
|
|
|
function mul(){
|
2023-03-07 10:42:01 +04:00
|
|
|
executeRequest("mul");
|
2023-02-20 22:25:28 +04:00
|
|
|
}
|
|
|
|
|
2023-03-07 10:42:01 +04:00
|
|
|
function del(){
|
|
|
|
executeRequest("del");
|
2023-02-20 22:25:28 +04:00
|
|
|
}
|
|
|
|
|
2023-03-07 10:42:01 +04:00
|
|
|
function enterArray(){
|
|
|
|
executeRequestArray("array");
|
|
|
|
}
|
2023-02-20 22:25:28 +04:00
|
|
|
|
2023-03-07 10:42:01 +04:00
|
|
|
function executeRequest(address) {
|
|
|
|
let num1 = document.getElementById("addNum1").value;
|
|
|
|
let num2 = document.getElementById("addNum2").value;
|
|
|
|
let type = document.getElementById("type").value;
|
2023-02-20 22:25:28 +04:00
|
|
|
console.log("a" + num1 + "b" + num2)
|
2023-03-07 10:42:01 +04:00
|
|
|
fetch(`http://localhost:8080/${address}?a=${num1}&b=${num2}&type=${type}`)
|
2023-02-20 22:25:28 +04:00
|
|
|
.then(response => {
|
2023-03-07 10:42:01 +04:00
|
|
|
return response.text();
|
2023-02-20 22:25:28 +04:00
|
|
|
})
|
|
|
|
.then(result => {
|
|
|
|
setResult(result);
|
|
|
|
})
|
2023-03-07 10:42:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function executeRequestArray(address) {
|
|
|
|
let array = document.getElementById("enterArray").value;
|
|
|
|
fetch(`http://localhost:8080/${address}?InputNumbers=${array}&type=${type}`)
|
|
|
|
.then(response => {
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then(result => {
|
|
|
|
setResult(result);
|
|
|
|
})
|
2023-02-20 22:25:28 +04:00
|
|
|
}
|