/
register.js
78 lines (63 loc) · 1.98 KB
/
register.js
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
function proceed_toAccountForm() {
$("#registration").hide();
$("#enter_code").hide();
$("#code_success").hide();
$("#player_details").show(); // <----------
$("#registration").hide();
}
function go_back_to_PlayerList() {
$("#enter_code").hide();
$("#code_success").hide();
$("#player_details").hide();
$("#play_as").show(); // <----------
$("#registration").hide();
}
function go_to_RegisterNewAccount() {
$("#enter_code").hide();
$("#code_success").hide();
$("#player_details").hide();
$("#play_as").hide();
$("#registration").show(); // <----------
}
function registerPlayer(emailaddress, outputDivID) { /* register account */
console.log("registerPlayer("+emailaddress+","+outputDivID+")");
if (/\S+@\S+\.\S+/.test(emailaddress)) {
$.ajax( {
"url" : "http://www.tigrisgames.com/player/REGISTER_account.php",
"type" : "POST",
"data" : { "email" : emailaddress },
success : function(msg) {
$(outputDivID).text(msg);
if (msg == "+") { // Email was sent
$("#registration").hide();
$("#enter_code").show();
$(outputDivID).text("Activation code was emailed.");
}
}});
} else {
$(outputDivID).text("Please enter correct email address.");
}
}
function confirmPlayer(emailaddress, code, outputDivID) { /* activate account */
console.log("confirmPlayer("+emailaddress+","+code+")");
if (/\S+@\S+\.\S+/.test(emailaddress)) {
$.ajax( {
"url" : "http://www.tigrisgames.com/player/ACTIVATE_account.php",
"type" : "POST",
"data" : { "email" : emailaddress,
"conf_Code" : code },
success : function(msg) {
if (msg == "+") { // Email was sent
$("#registration").hide();
$("#enter_code").hide();
$("#code_success").show();
$(outputDivID).text("Your account has been verified.");
$("#player_emailAddress").val( emailaddress );
} else {
$(outputDivID).text(msg);//"Incorrect code. Try again.");
}
}});
} else {
$(outputDivID).text("Invalid email address.");
}
}