diff --git a/front/index.html b/front/index.html
index 7aa11e8..e20268c 100644
--- a/front/index.html
+++ b/front/index.html
@@ -15,28 +15,29 @@
diff --git a/front/index.js b/front/index.js
index e6c7431..248e6d3 100644
--- a/front/index.js
+++ b/front/index.js
@@ -15,27 +15,23 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementsByClassName("needs-validation")[0].addEventListener('submit', function(event) {
event.preventDefault();
- if (document.getElementById("radioBold").checked) {
+ if (document.getElementById("radioUppercase").checked) {
fetch("http://localhost:8080/uppercase?value=" + document.getElementById("input").value)
.then(resp => {return resp.text()})
.then(resBody => {document.getElementById("result").innerHTML = resBody})
}
- if (document.getElementById("radioCursive").checked) {
- fetch("http://localhost:8080/lovercase?value=" + document.getElementById("input").value)
+ if (document.getElementById("radioLowcase").checked) {
+ fetch("http://localhost:8080/lowercase?value=" + document.getElementById("input").value)
.then(resp => {return resp.text()})
.then(resBody => {document.getElementById("result").innerHTML = resBody})
}
- if (document.getElementById("radioUnderline").checked) {
+ if (document.getElementById("radioSplit").checked) {
fetch("http://localhost:8080/split?value=" + document.getElementById("input").value + "&splitBy=" + document.getElementById("inputSplitBy").value)
.then(resp => {return resp.text()})
- .then(resBody => {
- for (i = 0; i < resBody.length; i++) {
- document.getElementById("result").innerHTML += resBody[i]
- }
- })
+ .then(resBody => {document.getElementById("result").innerHTML = resBody})
}
- if (document.getElementById("radioCrossed").checked) {
- fetch("http://localhost:8080/crossed?value=" + document.getElementById("input").value)
+ 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)
.then(resp => {return resp.text()})
.then(resBody => {document.getElementById("result").innerHTML = resBody})
}
diff --git a/src/main/java/com/kalyshev/yan/ReplaceController.java b/src/main/java/com/kalyshev/yan/ReplaceController.java
index 7fd7ca1..2e41bc0 100644
--- a/src/main/java/com/kalyshev/yan/ReplaceController.java
+++ b/src/main/java/com/kalyshev/yan/ReplaceController.java
@@ -8,8 +8,8 @@ import org.springframework.web.bind.annotation.RestController;
public class ReplaceController {
@GetMapping("/replace")
public String replace(@RequestParam(value = "value", defaultValue = "None") String value,
- @RequestParam(value = "old", defaultValue = " ") char oldChar,
- @RequestParam(value = "new", defaultValue = " ") char newChar) {
+ @RequestParam(value = "old", defaultValue = "") char oldChar,
+ @RequestParam(value = "new", defaultValue = "") char newChar) {
return value.replace(oldChar, newChar);
}
}
diff --git a/src/main/java/com/kalyshev/yan/SplitController.java b/src/main/java/com/kalyshev/yan/SplitController.java
index b1a2ba1..4256c4c 100644
--- a/src/main/java/com/kalyshev/yan/SplitController.java
+++ b/src/main/java/com/kalyshev/yan/SplitController.java
@@ -7,8 +7,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class SplitController {
@GetMapping("/split")
- public String[] split(@RequestParam(value = "value", defaultValue = "None") String value,
+ public String split(@RequestParam(value = "value", defaultValue = "None") String value,
@RequestParam(value = "splitBy", defaultValue = " ") String splitBy) {
- return value.split(splitBy);
+ String[] temp = value.split(splitBy);
+ String res = "";
+ for (int i = 0; i < temp.length; i++) {
+ res += temp[i];
+ res += "; ";
+ }
+ return res;
}
}