-
Notifications
You must be signed in to change notification settings - Fork 0
/
rooms.html
121 lines (108 loc) · 3.12 KB
/
rooms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<html>
<head>
<meta charset="UTF-8" />
<script src="xm.js"></script>
<script src="xmeffects.js"></script>
<script src="network.js"></script>
<script src="index.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Fascinate&display=swap"
rel="stylesheet"
/>
<style>
body {
font-family: roboto, sans-serif;
color: white;
line-height: 1.4;
background-color: black;
}
h1 {
text-align: center;
margin-top: 50px;
font-family: "Fascinate", cursive;
letter-spacing: 5px;
font-size: 70px;
}
input {
border: 1px solid chartreuse;
border-radius: 4px;
padding: 2px;
}
.flex-box {
display: flex;
flex-wrap: wrap;
align-items: center;
height: 100%;
padding: 0;
margin: 0;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
justify-content: center;
flex-direction: column;
}
button {
background-color: chartreuse;
border: 0px;
border-radius: 4px;
padding: 5px;
}
.join-button {
margin-left: 10px;
}
.room-list-item {
margin-top: 20px;
display: flex;
}
</style>
</head>
<body>
<div class="flex-box" id="firstDiv">
<div>
<div>
<h1>Rooms</h1>
<input type="text" id="newroom" />
<button onclick="createRoom()">Raum erstellen</button>
</div>
</div>
</div>
<script>
if (!sessionStorage.getItem("user")) {
window.location.href = "/index.html";
}
function createRoom() {
var roomname = document.getElementById("newroom");
sessionStorage.setItem("roomId", roomname.value);
window.location.href = "/game.html";
}
function addElement(rooms) {
console.log("addElement");
for (let i = 0; i < rooms.length; i++) {
var newDiv = document.createElement("div");
var newButton = document.createElement("button");
var secondDiv = document.createElement("div");
var firstDiv = document.createElement("div");
var nextDiv = document.createElement("div");
newDiv.className = "room-list-item";
newButton.innerHTML = "Raum beitreten";
newButton.className = "join-button";
secondDiv.innerHTML = rooms[i];
newDiv.appendChild(secondDiv);
newDiv.appendChild(newButton);
firstDiv.appendChild(newDiv);
nextDiv.appendChild(firstDiv);
var currentDiv = document.getElementById("firstDiv");
currentDiv.appendChild(nextDiv);
newButton.addEventListener("click", function () {
sessionStorage.setItem("roomId", rooms[i]);
window.location.href = "/game.html";
});
}
}
</script>
</body>
</html>