-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
221 lines (157 loc) · 8.82 KB
/
signup.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
<!DOCTYPE HTML>
<html>
<head>
<title>The Nova League</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://bootswatch.com/superhero/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">The Nova League</span></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><div class="btn-nav"><a type="button" class="btn btn-default btn-sm navbar-btn" href="index.php">BACK TO HOME</a></div></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container theme-showcase" role="main">
<div class="row">
<div class="panel panel-default col-md-3" style="margin: 0 auto">
<form name="signup" role="form" action="signup.php" method="post">
<span class="alert-1"></span>
<div class="input-group" style="width:100%;">
<input type="text" class="form-control" name="username" id="username" value="" placeholder="Username" onblur="checkUsername()">
</div>
<div class="input-group" style="width:100%;">
<input type="password" class="form-control" name="password" id="password" value="" placeholder="Password" onblur="checkPassword()">
</div>
<div class="input-group" style="width:100%;">
<input type="password" class="form-control" name="password-repeat" id="password-repeat" value="" placeholder="Repeat Password" onblur="checkPasswordRepeat()">
</div>
<br>
<span class="ogs-userid-alert"></span>
<div class="input-group">
<input type="text" class="form-control" name="ogs-userid" id="ogs-userid" placeholder="Your OGS User ID" aria-describedby="ogs-import" onblur="checkID()">
<span class="input-group-btn"><button type="button" class="btn btn-success" id="ogs-import" data-toggle="tooltip" data-placement="right" title="" data-original-title="Import" onclick="fetchRank()"><i class="glyphicon glyphicon-import"></i></button></span>
</div>
<br>
<div class="input-group" style="width:100%;">
<input type="text" class="form-control" name="rating" id="rating" value="" placeholder="Rating" readonly>
</div>
<div class="input-group" style="width:100%;">
<input type="text" class="form-control" name="rank" id="rank" value="" placeholder="Rank" readonly>
</div>
<div class="input-group" style="width:100%;">
<textarea type="text" class="form-control" name="about" id="about" value="" rows="5" placeholder="About yourself..."></textarea>
</div>
<button type="submit" class="btn btn-primary" style="width:100%;" name="submit" value="Submit">SIGN UP</button>
</form>
</div>
</div>
<!-- Optional theme -->
<!-- Latest compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
<script type="text/javascript">
var c_username = 0;
var c_password_entered = 0;
var c_password_length = 0;
var c_password_repeat_entered = 0;
var c_password_check = 0;
var c_ogs = 0;
var c_id = 0;
$(document).ready(function() {
$("body").tooltip({ selector: '[data-toggle=tooltip]' });
});
function checkUsername(){
var username = document.getElementById("username").value;
if (username == ""){
c_username++;
if (c_username < 2){
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> You have not chosen a username!</strong></div>").insertAfter('.alert-1');
}
}
}
function checkPassword(){
var password = document.getElementById("password").value;
if (password == ""){
c_password_entered++;
if (c_password_entered < 2){
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> You have not chosen a password!</strong></div>").insertAfter('.alert-1');
}
}
if (password.length < 6 || password.length > 30){
c_password_length++;
if (c_password_length < 2){
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> Password must be between 6 and 30 characters!</strong></div>").insertAfter('.alert-1');
}
}
}
function checkPasswordRepeat(){
var password_repeat = document.getElementById("password-repeat").value;
if (password_repeat == ""){
c_password_repeat_entered++;
if (c_password_repeat_entered < 2){
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> You have not retyped the password!</strong></div>").insertAfter('.alert-1');
}
}
if (password_repeat !== document.getElementById("password")){
c_password_match++;
if (c_password_match < 2){
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> The passwords don't match!").insertAfter('.alert-1');
}
}
}
function checkID(){
var id = document.getElementById("ogs-userid").value;
if (id == ""){
c_ogs++;
if (c_ogs < 2){
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> You have not entered an OGS ID!</strong></div>").insertAfter('.alert-1');
}
}
}
function fetchRank(){
var head = "https://online-go.com/api/v1/players/";
var user_id_value = document.getElementById("ogs-userid").value;
var theURL = head.concat(user_id_value);
var xmlHTTP = new XMLHttpRequest();
xmlHTTP.open("GET", theURL, false);
xmlHTTP.send(null);
if (xmlHTTP.status === 404) {
c_id++;
if (c_id < 2) {
$("<div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span></button><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><strong> User ID not found!</strong></div>").insertAfter('.ogs-userid-alert');
}
document.getElementById("ogs-userid").value = "";
}
var r = JSON.parse(xmlHTTP.responseText);
var rank = "";
if (r.ranking < 30) {
rank = (30 - r.ranking) + "k";
}
else {
rank = ((r.ranking - 30) + 1) + "d";
}
var rating_value = document.getElementById("rating");
rating_value.value = r.rating;
var rank_value = document.getElementById("rank");
rank_value.value = rank;
var about_value = document.getElementById("about");
about_value.value = r.about;
}
</script>
</html>