Client changes

This commit is contained in:
nannal
2020-03-08 15:10:10 +02:00
parent 8708bac1a2
commit 9ef945e575
5 changed files with 428 additions and 45 deletions

18
client/Old/index.html Normal file
View File

@@ -0,0 +1,18 @@
<head>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous">
</script>
<script src="./index.js"></script>
</head>
<body>
<title>Embezzle</title>
<input type="text" id="location" /> <input type="button" value="send" onclick="send()" /><input type="button" value="get" onclick="get()" />
</br>
<input type="text" id="name" value="Name" />
<input type="text" id="ownerID" value="ownerID" />
<input type="text" id="gameID" value="gameID" />
<input type="text" id="seats" value="seats" />
</body>

30
client/Old/index.js Normal file
View File

@@ -0,0 +1,30 @@
url="http://127.0.0.1:3000"
function send() {
data = {name: $('#name').val(), ownerID: $("#ownerID").val(), gameID: $("#gameID").val(), seats: $("#seats").val()}
console.log(JSON.stringify(data))
let xhr = new XMLHttpRequest();
xhr.open("POST", url + "/" + $('#location').val(), true)
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(JSON.parse(xhr.responseText))
}
}
xhr.send(JSON.stringify(data))
}
function get() {
let xhr = new XMLHttpRequest();
xhr.open("GET", url + "/" + $('#location').val(), true)
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(JSON.parse(xhr.responseText))
}
}
xhr.send()
}