Skip to content
Snippets Groups Projects
Commit 01ffdedb authored by Maiken Louise's avatar Maiken Louise
Browse files

Task 3 done

parents 2ed3e11c 794a6583
No related branches found
No related tags found
No related merge requests found
Pipeline #115179 passed
package resources; package resources;
<<<<<<< HEAD
=======
>>>>>>> 794a6583a949557859a601f9399dfb3bbf0def40
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
...@@ -12,7 +15,6 @@ import javax.ws.rs.core.MediaType; ...@@ -12,7 +15,6 @@ import javax.ws.rs.core.MediaType;
*/ */
@Path("/calculator") @Path("/calculator")
public class CalculatorResource { public class CalculatorResource {
/** /**
* Method handling HTTP POST requests. The calculated answer to the expression will be sent to the client as * Method handling HTTP POST requests. The calculated answer to the expression will be sent to the client as
* plain/text. * plain/text.
...@@ -47,7 +49,7 @@ public int calculate(String expression) { ...@@ -47,7 +49,7 @@ public int calculate(String expression) {
return result; return result;
} }
//Multiplication
public int multiplication(String equation) { public int multiplication(String equation) {
String[] split = equation.split("[*]"); String[] split = equation.split("[*]");
int sum = Integer.parseInt(split[0]); int sum = Integer.parseInt(split[0]);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
</div> </div>
<form class="main" id="loginForm" onsubmit="login(event)"> <form class="main" id="loginForm" onsubmit="login(event)">
<input class="loginInput" placeholder="Brukernavn..." id="username" required pattern="([\w]+)"> <input class="loginInput" placeholder="Brukernavn..." id="username" required pattern="([\w]+)">
<input class="loginInput" type="password" placeholder="Passord..." id="password" required pattern="([\w]+)">
<button class="loginBtn">Logg inn</button> <button class="loginBtn">Logg inn</button>
</form> </form>
</div> </div>
......
...@@ -15,7 +15,8 @@ inputfield.addEventListener("input",function () { ...@@ -15,7 +15,8 @@ inputfield.addEventListener("input",function () {
function login(event){ function login(event){
event.preventDefault(); event.preventDefault();
let user = { let user = {
"username": document.getElementById('username').value "username": document.getElementById('username').value,
"password": document.getElementById('password').value
}; };
fetch('../api/user', { fetch('../api/user', {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment