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

41 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2023-02-14 12:37:40 +04:00
let buttonUpper = document.getElementById("buttonUpper");
let buttonLower = document.getElementById("buttonLower");
let buttonReverse = document.getElementById("buttonReverse");
let buttonCount = document.getElementById("buttonCount");
let buttonDel = document.getElementById("buttonDel");
let stringInput = document.getElementById("string");
let placeInput = document.getElementById("place");
let resultInput = document.getElementById("res");
buttonUpper.onclick = function(event) {
let str = stringInput.value;
fetch(`http://localhost:8080/toUpperCase?string=${str}`)
.then(response => response.text())
.then(res => resultInput.value = res);
}
buttonLower.onclick = function(event) {
let str = stringInput.value;
fetch(`http://localhost:8080/toLowerCase?string=${str}`)
.then(response => response.text())
.then(res => resultInput.value = res);
}
buttonReverse.onclick = function(event) {
let str = stringInput.value;
fetch(`http://localhost:8080/reverse?string=${str}`)
.then(response => response.text())
.then(res => resultInput.value = res);
}
buttonCount.onclick = function(event) {
let str = stringInput.value;
fetch(`http://localhost:8080/count?string=${str}`)
.then(response => response.text())
.then(res => resultInput.value = res);
}
buttonDel.onclick = function(event) {
let str = stringInput.value;
let plc = placeInput.value;
fetch(`http://localhost:8080/del?string=${str}&place=${plc}`)
.then(response => response.text())
.then(res => resultInput.value = res);
}