From f7cd8783bee41a2d860dbcb00ca0e5ac05a5fc57 Mon Sep 17 00:00:00 2001 From: Arek Date: Wed, 1 Jun 2022 22:23:12 +0200 Subject: [PATCH] feat: :sparkles: adding api adding api connection to registration and tournament making --- frontend/dodawanie turnieju/app.js | 13 +++++++ frontend/dodawanie turnieju/index.html | 17 +++++---- frontend/logowanie/app.js | 18 ++++++++++ frontend/logowanie/index.html | 13 ++++--- frontend/rejestracja/myscript.js | 50 -------------------------- 5 files changed, 49 insertions(+), 62 deletions(-) create mode 100644 frontend/dodawanie turnieju/app.js create mode 100644 frontend/logowanie/app.js diff --git a/frontend/dodawanie turnieju/app.js b/frontend/dodawanie turnieju/app.js new file mode 100644 index 0000000..1a47f50 --- /dev/null +++ b/frontend/dodawanie turnieju/app.js @@ -0,0 +1,13 @@ +document.getElementById("tournamentSubmit").addEventListener("click", function () { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + if (this.readyState == 4 && this.status == 200) { + alert("Dodano turniej"); + } else if (this.readyState == 4) { + alert("something not work :( " + this.status); + } + } + xhttp.open("PUT", "dragonmaster.pl/inz/tournament"); + xhttp.setRequestHeader("Authorization", "Bearer " + token); + xhttp.send('{"name":"' + document.getElementById("tournamentName").value + '","typeOfLadder":"' + document.getElementById("ladderType").value + '","pointsForTournament":"' + document.getElementById("tournamentPoints").value + '","places":"' + document.getElementById("tournamentPlace").value + '","roles":"' + document.getElementById("tournamentRole").value + '","ranked":"' + document.getElementById("isRanked").value + '"}'); +}); \ No newline at end of file diff --git a/frontend/dodawanie turnieju/index.html b/frontend/dodawanie turnieju/index.html index 23c4a97..0833b50 100644 --- a/frontend/dodawanie turnieju/index.html +++ b/frontend/dodawanie turnieju/index.html @@ -12,18 +12,19 @@
- +
- +
.
.
@@ -31,7 +32,7 @@

Nazwa Turnieju

Termin

@@ -41,17 +42,17 @@

Miejsce

Kategorie

Ranga

Wpisowe

@@ -82,6 +83,8 @@
+ + \ No newline at end of file diff --git a/frontend/logowanie/app.js b/frontend/logowanie/app.js new file mode 100644 index 0000000..142b61c --- /dev/null +++ b/frontend/logowanie/app.js @@ -0,0 +1,18 @@ +document.getElementById("loginsubmit").addEventListener("click", function () { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function () { + if (this.readyState == 4 && this.status == 200) { + alert("logged in"); + console.log("dziala"); + } else if (this.readyState == 4) { + alert("something not work :( " + this.status); + console.log("nie dziala"); + } + } + xhttp.open("POST", "https://dragonmaster.pl/inz/user/login"); + xhttp.send('{"username":"' + document.getElementById("loginusername").value + '","password":"' + document.getElementById("loginpassword").value + '"}'); +}); + +function submit() { + ("form").submit(function () { return false; }) +} \ No newline at end of file diff --git a/frontend/logowanie/index.html b/frontend/logowanie/index.html index 66a5347..deb650c 100644 --- a/frontend/logowanie/index.html +++ b/frontend/logowanie/index.html @@ -14,14 +14,16 @@
+ \ No newline at end of file diff --git a/frontend/rejestracja/myscript.js b/frontend/rejestracja/myscript.js index 2b2ec61..24855e7 100644 --- a/frontend/rejestracja/myscript.js +++ b/frontend/rejestracja/myscript.js @@ -17,56 +17,6 @@ form.addEventListener('submit', function (e) { e.preventDefault(); }); -// <<<<<<< HEAD -// var token = ""; -// // document.getElementById("loginButton").addEventListener("click", function () { -// // document.getElementById("login").style.display = "block"; -// // }); -// // ======= -// //REST API -// var token = ""; -// document.getElementById("loginButton").addEventListener("click", function () { -// document.getElementById("login").style.display = "block"; -// }); -// >>>>>>> b44b5f1fc14af7c8da4ca602072af953974b49af - -// // document.getElementById("regButton").addEventListener("click", function () { -// // document.getElementById("reg").style.display = "block"; -// // }); -// document.getElementById("registrationButton").addEventListener("click", function () { -// document.getElementById("registration").style.display = "block"; -// }); -// document.getElementById("checkPaymentButton").addEventListener("click", function () { -// document.getElementById("checkStatus").style.display = "block"; -// }); -// var registartions = []; -// document.getElementById("getRegistartionsButton").addEventListener("click", function () { -// document.getElementById("getRegistartions").style.display = "block"; -// }); -// document.getElementById("getUserDataButton").addEventListener("click", function () { -// var xhttp = new XMLHttpRequest(); -// xhttp.onreadystatechange = function () { -// if (this.readyState == 4 && this.status == 200) { -// var json = JSON.parse(this.response); -// document.getElementById("getUserDataid").innerText = json.id; -// document.getElementById("getUserDataname").innerText = json.name; -// document.getElementById("getUserDatasurname").innerText = json.surname; -// document.getElementById("getUserDatarole").innerText = json.role; -// document.getElementById("getUserDatalogin").innerText = json.login; -// document.getElementById("getUserDataphone").innerText = json.phone; -// document.getElementById("getUserDatamail").innerText = json.mail; -// document.getElementById("getUserData").style.display = "block"; -// } else if (this.readyState == 4) { -// alert("something not work :( " + this.status); -// } -// } -// xhttp.open("GET", "dragonmaster.pl/inz/user"); -// xhttp.setRequestHeader("Authorization", "Bearer " + token); -// xhttp.send(); -// }); -// document.getElementById("updateUserDataButton").addEventListener("click", function () { -// document.getElementById("updateUserData").style.display = "block"; -// }); document.getElementById("regsubmit").addEventListener("click", function () { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () {