done
This commit is contained in:
parent
1b02121e6b
commit
c734c15635
@ -13,26 +13,29 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementsByClassName("needs-validation")[0].addEventListener('submit', function(event) {
|
document.getElementsByClassName("needs-validation")[0].addEventListener('submit', async function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
url = ""
|
||||||
if (document.getElementById("radioUppercase").checked) {
|
if (document.getElementById("radioUppercase").checked) {
|
||||||
fetch("http://localhost:8080/uppercase?value=" + document.getElementById("input").value)
|
url = "http://localhost:8080/uppercase?value=" + document.getElementById("input").value
|
||||||
.then(resp => {return resp.text()})
|
|
||||||
.then(resBody => {document.getElementById("result").innerHTML = resBody})
|
|
||||||
}
|
}
|
||||||
if (document.getElementById("radioLowcase").checked) {
|
if (document.getElementById("radioLowcase").checked) {
|
||||||
fetch("http://localhost:8080/lowercase?value=" + document.getElementById("input").value)
|
url = "http://localhost:8080/lowercase?value=" + document.getElementById("input").value
|
||||||
.then(resp => {return resp.text()})
|
|
||||||
.then(resBody => {document.getElementById("result").innerHTML = resBody})
|
|
||||||
}
|
}
|
||||||
if (document.getElementById("radioSplit").checked) {
|
if (document.getElementById("radioSplit").checked) {
|
||||||
fetch("http://localhost:8080/split?value=" + document.getElementById("input").value + "&splitBy=" + document.getElementById("inputSplitBy").value)
|
url = "http://localhost:8080/split?value=" + document.getElementById("input").value + "&splitBy=" + document.getElementById("inputSplitBy").value
|
||||||
.then(resp => {return resp.text()})
|
|
||||||
.then(resBody => {document.getElementById("result").innerHTML = resBody})
|
|
||||||
}
|
}
|
||||||
if (document.getElementById("radioReplace").checked) {
|
if (document.getElementById("radioReplace").checked) {
|
||||||
fetch("http://localhost:8080/replace?value=" + document.getElementById("input").value + "&old=" + document.getElementById("inputReplaceOld").value + "&new=" + document.getElementById("inputReplaceNew").value)
|
url = "http://localhost:8080/replace?value=" + document.getElementById("input").value + "&old=" + document.getElementById("inputReplaceOld").value + "&new=" + document.getElementById("inputReplaceNew").value
|
||||||
.then(resp => {return resp.text()})
|
|
||||||
.then(resBody => {document.getElementById("result").innerHTML = resBody})
|
|
||||||
}
|
}
|
||||||
|
if (url == "") {
|
||||||
|
document.getElementById("result").innerHTML = "Выберите действие!"
|
||||||
|
}
|
||||||
|
// performFetch(url).then(data => {document.getElementById("result").innerHTML = data})
|
||||||
|
document.getElementById("result").innerHTML = await performFetch(url)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function performFetch(url) {
|
||||||
|
let resp = await fetch(url)
|
||||||
|
return await resp.text()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user