WebProg/front/main.js
2023-03-07 08:34:30 +04:00

72 lines
2.3 KiB
JavaScript

function sumLab2(type) {
var first = document.getElementById("sum_first_tf").value
var second = document.getElementById("sum_second_tf").value
fetch("http://127.0.0.1:8080/lab2/sum?" + "first=" + first + "&second=" + second + "&type=" + type)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("sum_result").textContent=response
})
}
function makeItBiggerLab2(type) {
var value = document.getElementById("makeitbigger_tf").value
fetch("http://127.0.0.1:8080/lab2/makeitbigger?small="+value + "&type=" + type)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("makeitbigger_tf").value = response
})
}
function reverseLab2(type) {
var value = document.getElementById("reverse_tf").value
fetch("http://127.0.0.1:8080/lab2/reverse?value="+value + "&type=" + type)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("reverse_tf").value = response
})
}
function lenghtLab2(type) {
var value = document.getElementById("lenght_tf").value
fetch("http://127.0.0.1:8080/lab2/lenght?value="+value + "&type=" + type)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("lenght_tf").value = response
})
}
function iloveclick() {
var text = document.getElementById("ilovetextfield").value
fetch ("http://127.0.0.1:8080/ilove?thing=" + text)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("ilovetextfield").value = response
})
}
function askclick() {
var text = document.getElementById("asktextfield").value
fetch ("http://127.0.0.1:8080/ask?question=" + text)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("asktextfield").value = response
})
}
function upperclick() {
var text = document.getElementById("uppertextfield").value
fetch ("http://127.0.0.1:8080/touppercase?content=" + text)
.then(response => response.text())
.then((response) => {
console.log(response)
document.getElementById("uppertextfield").value = response
})
}