59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
|
// let text1 = document.getElementById("text");
|
||
|
// let button = document.getElementById("button");
|
||
|
// let result = document.getElementById("result");
|
||
|
|
||
|
// button.onclick = function(){
|
||
|
// method();
|
||
|
// }
|
||
|
// function method() {
|
||
|
// console.log("получилось");
|
||
|
// let text = text1.value;
|
||
|
// console.log(text);
|
||
|
// fetch(`http://localhost:8080/hello?name=${text}`)
|
||
|
// .then(response => response.text())
|
||
|
// .then(res => result.value = res);
|
||
|
// }
|
||
|
|
||
|
|
||
|
let firstDig = document.getElementById("firstDig");
|
||
|
let secondDig = document.getElementById("secondDig");
|
||
|
let operation = document.getElementById("operation");
|
||
|
let calcButton = document.getElementById("startCalc");
|
||
|
let result = document.getElementById("result");
|
||
|
|
||
|
calcButton.onclick = function(){
|
||
|
let adress = "";
|
||
|
operationValue = operation.value;
|
||
|
if (operationValue == 'Умножение'){
|
||
|
adress = 'mult'
|
||
|
}
|
||
|
else if (operationValue == 'Деление'){
|
||
|
adress = 'div'
|
||
|
}
|
||
|
else if (operationValue == 'Сложение'){
|
||
|
adress = 'sum'
|
||
|
}
|
||
|
else if (operationValue == 'Вычитание'){
|
||
|
adress = 'sub'
|
||
|
}
|
||
|
calc(adress);
|
||
|
}
|
||
|
function calc(adress) {
|
||
|
console.log(firstDig, secondDig)
|
||
|
fetch(`http://localhost:8080/${adress}?firstDig=${firstDig.value}&secondDig=${secondDig.value}`)
|
||
|
.then(response => response.text())
|
||
|
.then(res => result.value = res);
|
||
|
}
|
||
|
|
||
|
|
||
|
let text = document.getElementById("text");
|
||
|
let start = document.getElementById("start");
|
||
|
|
||
|
start.onclick = function(){
|
||
|
let result1 = '';
|
||
|
|
||
|
fetch(`http://localhost:8080/text?text=${text.value}`)
|
||
|
.then(response => response.text())
|
||
|
.then(res => alert(res));
|
||
|
|
||
|
}
|