56 lines
1.7 KiB
JavaScript
Raw Normal View History

const one = document.getElementById('First');
const two = document.getElementById('Second');
2023-02-27 18:01:53 +04:00
const type = document.getElementById('_Type');
const result = document.getElementById('Result');
const check = null;
const button_s = document.getElementById('Sum');
button_s.addEventListener("click", function()
{
2023-02-27 18:01:53 +04:00
console.log("Кнопка нажата. 5");
2023-02-27 18:01:53 +04:00
fetch('http://localhost:8080/sum?num_1=' + one.value + '&num_2=' + two.value + '&type=' + type.value)
.then((response) => response.text())
2023-02-27 18:01:53 +04:00
.then((data) => result.value = data);
result.value = "6";
});
const button_min = document.getElementById('Minus');
button_min.addEventListener("click", function()
{
console.log("Кнопка нажата.");
2023-02-27 18:01:53 +04:00
fetch('http://localhost:8080/minus?num_1=' + one.value + '&num_2=' + two.value + '&type=' + type.value)
.then((response) => response.text())
.then((data) => result.value = data)
});
const button_i = document.getElementById('Implement');
button_i.addEventListener("click", function()
{
console.log("Кнопка нажата.");
if(two.value == 0)
{
result.value = "Error";
}
else
{
2023-02-27 18:01:53 +04:00
fetch('http://localhost:8080/cont?num_1=' + one.value + '&num_2=' + two.value + '&type=' + type.value)
.then((response) => response.text())
.then((data) => result.value = data)
}
});
const button_m = document.getElementById('Multiplication');
button_m.addEventListener("click", function()
{
console.log("Кнопка нажата.");
2023-02-27 18:01:53 +04:00
fetch('http://localhost:8080/mul?num_1=' + one.value + '&num_2=' + two.value + '&type=' + type.value)
.then((response) => response.text())
.then((data) => result.value = data)
});