-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateUser.html
346 lines (305 loc) · 16.4 KB
/
CreateUser.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<!DOCTYPE html>
<html lang="en">
<head>
<title>Muscle - Free Bootstrap 4 Template by Colorlib</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Barlow+Semi+Condensed:100,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="css/open-iconic-bootstrap.min.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<link rel="stylesheet" href="css/magnific-popup.css">
<link rel="stylesheet" href="css/aos.css">
<link rel="stylesheet" href="css/ionicons.min.css">
<link rel="stylesheet" href="css/bootstrap-datepicker.css">
<link rel="stylesheet" href="css/jquery.timepicker.css">
<link rel="stylesheet" href="css/flaticon.css">
<link rel="stylesheet" href="css/icomoon.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/create_user.css">
<style>
body {
background-image: url("images/login.jpg");
background-position: top right;
/* Center the image */
background-repeat: no-repeat;
/* Do not repeat the image */
background-color: black;
background-size: cover;
}
</style>
</head>
<body>
<div class="container1">
<nav class="navbar navbar-expand-lg navbar-dark ftco_navbar bg-dark ftco-navbar-light" id="ftco-navbar">
<div class="container">
<a class="navbar-brand py-2 px-4" style="font-size: 18px;" href="index.html">CloudFit</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#ftco-nav" aria-controls="ftco-nav" aria-expanded="false" aria-label="Toggle navigation">
<span class="oi oi-menu"></span> Menu
</button>
<div class="collapse navbar-collapse" id="ftco-nav">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a href="index.html" class="nav-link">Home</a></li>
<li class="nav-item active"><a href="loginLucas.html" class="nav-link">Login</a></li>
</ul>
</div>
</div>
</nav>
<!-- END nav -->
<section class="ftco-section contact-section">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4 ftco-animate">
<form action="#" style="background-color:white; padding:5%; display:flex; justify-content: center; flex-direction: column; align-items: center;
" class="contact-form">
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control newname" placeholder="Username">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input type="password" class="form-control newpwd" placeholder="Password">
</div>
</div>
<div class="col-md-6" class="Ginasio">
<div class="form-group">
<input type="text" class="form-control gym" placeholder="Gym (leave blank if you are a gym)">
</div>
</div>
<div class="dropdown">
<input type="radio" name="choice" value="Gym">Gym<br>
<input type="radio" name="choice" value="Personal Trainer">Personal Trainer<br>
<input type="radio" name="choice" value="Atlete">Athlete<br>
</div>
<br>
<div class="row" style="display: flex; flex-direction: column;">
<div class="form-group" style="margin-left: 2%">
<input type="button" value="Create!" class="btn btn-primary py-3 px-5 create">
</div>
</div>
</form>
</div>
<div id="id01" class="w3-modal error">
<div class="w3-modal-content w3-animate-top w3-card-4">
<span onclick="document.getElementById('id01').style.display='none'" class="w3-button w3-display-topright">×</span>
<header class="w3-container w3-teal">
<<<<<<< HEAD
<h2 class="msg" style="color: black"></h2>
=======
<h2 class="msg" style="color: white"></h2>
>>>>>>> cf4c064fa8dbf2809c2389bee6905ff2e9e3558a
</header>
</div>
</div>
<div class="modal" id="exampleModal" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Create New Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<input type="text" class="newname " style="width:90%" placeholder="Username">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row mb-2" style="display: flex;
justify-content:center;">
<div class="col-lg-3 col-md-6 mb-5 mb-md-5">
<div class="ftco-footer-widget mb-4">
<p>Website desenvolvido no âmbito da cadeira Modelação e Análise de Sistemas. <br>Universidade de Aveiro</p>
</div>
</div>
</div>
</div>
</section>
<!-- loader -->
<div id="ftco-loader" class="show fullscreen"><svg class="circular" width="48px" height="48px"><circle class="path-bg" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke="#eeeeee"/><circle class="path" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke-miterlimit="10" stroke="#F96D00"/></svg></div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/jquery-migrate-3.0.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/jquery.waypoints.min.js"></script>
<script src="js/jquery.stellar.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/aos.js"></script>
<script src="js/jquery.animateNumber.min.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/jquery.timepicker.min.js"></script>
<script src="js/scrollax.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBVWaKrjvy3MaE7SQ74_uJiULgl1JY0H2s&sensor=false"></script>
<script src="js/google-map.js"></script>
<script src="js/main.js"></script>
<script>
$(document).ready(function() {
var radiovalue;
$("input[type='radio']").click(function() {
radiovalue = $("input[name='choice']:checked").val()
console.log(radiovalue)
})
$(".curto").hide();
$(".curtop").hide();
$(".erro").hide();
if (window.localStorage.getItem("NumUsers") == null) {
window.localStorage.setItem("NumUsers", 0)
}
if (window.localStorage.getItem("numPersonalT") == null) {
window.localStorage.setItem("numPersonalT", 0)
}
if (window.localStorage.getItem("numAtribuicao") == null) {
window.localStorage.setItem("numAtribuicao", 0)
}
if (window.localStorage.getItem("menor") == null) {
window.localStorage.setItem("menor", 0)
}
var namechecker
var pwdchecker
$(".close").click(function() {
$(".modal").hide();
$(".curto").hide();
$(".curtop").hide();
$(".newname").val('');
$(".newpwd").val('');
});
$(".newaccountbtn").click(function() {
$(".modal").show();
namechecker = true;
pwdchecker = true;
});
$(".create").click(function() {
var nome = $(".newname").val();
var pwd = $(".newpwd").val();
var gym = $(".gym").val();
var user = {};
if (nome.length < 4) {
$(".msg").text("Nome deasiado curto");
$(".error").show();
namechecker = false;
} else {
namechecker = true;
}
if (pwd.length < 8) {
$(".msg").text("Password demasiado curta(Pelo menos 8 caracteres)");
$(".error").show()
pwdchecker = false;
} else {
pwdchecker = true;
}
if (namechecker && pwdchecker) {
if (radiovalue == "Gym") {
user = {
"Name": nome,
"pwd": pwd,
"tipo": radiovalue,
"Pts": []
}
window.localStorage.setItem("user" + window.localStorage.getItem("NumUsers"), JSON.stringify(user));
window.localStorage.setItem("NumUsers", parseInt(window.localStorage.getItem("NumUsers")) + 1);
window.location.href = "loginLucas.html"
} else if (radiovalue == "Personal Trainer") {
var gyms = [];
for (var d = 0; d < parseInt(window.localStorage.getItem("NumUsers")); d++) {
var Da = JSON.parse(window.localStorage.getItem("user" + d));
if (Da.tipo == "Gym") {
gyms.push("user" + d);
}
}
var GymExists = false;
for (var e = 0; e < gyms.length; e++) {
if (JSON.parse(window.localStorage.getItem(gyms[e])).Name == gym) {
GymExists = true
}
}
if (!GymExists) {
$(".msg").text("Ginasio Inexistente")
$(".error").show()
} else {
window.localStorage.setItem("numPersonalT", parseInt(window.localStorage.getItem("numPersonalT")) + 1)
user = {
"Name": nome,
"pwd": pwd,
"tipo": radiovalue,
"Atletas": [],
"Gym": gym
}
window.localStorage.setItem("user" + window.localStorage.getItem("NumUsers"), JSON.stringify(user));
for (var d = 0; d < parseInt(window.localStorage.getItem("NumUsers")); d++) {
var data = JSON.parse(window.localStorage.getItem("user" + d));
if (data.tipo == "Gym") {
if (data.Name == gym) {
data.Pts.push("user" + window.localStorage.getItem("NumUsers"));
window.localStorage.setItem("user" + d, JSON.stringify(data))
}
}
}
window.localStorage.setItem("NumUsers", parseInt(window.localStorage.getItem("NumUsers")) + 1)
window.location.href = "loginLucas.html"
}
} else {
var personalTrainers;
personalTrainers = []
for (var b = 0; b < parseInt(window.localStorage.getItem("NumUsers")); b++) {
var data = JSON.parse(window.localStorage.getItem("user" + b));
if (data.tipo == "Personal Trainer" && data.Gym == gym) {
personalTrainers.push("user" + b);
}
}
if (personalTrainers.length == 0) {
$(".msg").text("Impossivel criar atleta, não existem Pt's ou não existe o Ginasio selecionado")
$(".error").show()
} else if (parseInt(window.localStorage.getItem("menor")) >= personalTrainers.length) {
$(".msg").text("Impossivel criar atleta, não existem Pt's livres")
$(".error").show()
} else {
if (parseInt(window.localStorage.getItem("numAtribuicao")) > parseInt(window.localStorage.getItem("numPersonalT")) - 1) {
window.localStorage.setItem("numAtribuicao", window.localStorage.getItem("menor"))
}
user = {
"Name": nome,
"pwd": pwd,
"tipo": radiovalue,
"PlanoTreinoAtual": [' ', ' ', ' ', ' ', ' ', ' ', ' '],
"PlanosTreinoPassado": {
"1": [],
"2": [],
"3": []
},
"mensagens":[],
"Pt": personalTrainers[window.localStorage.getItem("numAtribuicao")]
}
window.localStorage.setItem("user" + window.localStorage.getItem("NumUsers"), JSON.stringify(user));
var PT = JSON.parse(window.localStorage.getItem(personalTrainers[window.localStorage.getItem("numAtribuicao")]));
PT.Atletas.push("user" + window.localStorage.getItem("NumUsers"))
if (PT.Atletas.length == 7) {
window.localStorage.setItem("menor", parseInt(window.localStorage.getItem("menor")) + 1)
}
window.localStorage.setItem(personalTrainers[window.localStorage.getItem("numAtribuicao")], JSON.stringify(PT))
window.localStorage.setItem("numAtribuicao", parseInt(window.localStorage.getItem("numAtribuicao")) + 1)
window.localStorage.setItem("NumUsers", parseInt(window.localStorage.getItem("NumUsers")) + 1);
window.location.href = "loginLucas.html"
}
}
var ginasio = JSON.parse(window.localStorage.getItem("user0"));
}
});
});
</script>
</body>
</html>