-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjoin.html
139 lines (116 loc) · 4.75 KB
/
join.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>proto-chat</title>
<link rel="stylesheet" type="text/css" href="/CSS/login.css">
<script src="/scripts/initialize.js"></script>
<script src="/scripts/encryption.js"></script>
<script src="https://cdn.jsdelivr.net/npm/idb@8/build/umd.js"></script>
<script>
const ws = new WebSocket(createWSPath());
setInterval(() => { ws.send(JSON.stringify({code: 10})); }, 30000);
function fakeWindowOnload() {
ws.addEventListener('open', () => {
console.log("websocket connection established!");
});
ws.addEventListener('error', (err) => {
alert('Uh oh!\nAn error occured!');
window.location.href = '/';
console.error(err);
});
ws.addEventListener('close', (ev) => console.log(ev));
ws.addEventListener('message', (message) => {
const data = JSON.parse(message.data);
if (data.code == 7) createAndStoreKey(data);
else if (data.code != 0) return; // note this deals with the CODE
else if (data.op == 1) recieveCode(data);
else if (data.op == 2) recieveCodeResponse(data);
else console.log(data);
});
}
function createConfcodeRequest() {
const username = document.getElementById('unameinp').value;
const password = document.getElementById('upassinp').value;
const email = document.getElementById('uemailinp').value;
if (!username || !password || !email) return;
ws.send(JSON.stringify({
code: 0,
op: 1,
data: {
username: username,
password: password,
email: email
}
}));
}
function recieveCode(data) {
if (data.type == 1) return alert('email already exists!');
if (data.type == 2) return alert('username already exists!');
const element = document.getElementById('signupInpWrapper');
element.style.display = 'none';
const confEl = document.getElementById('confCodeInpWrapper');
confEl.style.display = 'block';
}
function sendConfCode() {
const code = document.getElementById('confCode').value;
if (code) {
ws.send(JSON.stringify({
code: 0,
op: 2,
data: {
confCode: code
}
}));
}
}
function recieveCodeResponse(data) {
if (data.type == 1) return alert('incorrect code!');
else if (data.type == 2) return alert('code expired!\nplease refresh the page and try again!');
console.log(data);
window.location.href = '/';
}
fakeWindowOnload();
</script>
</head>
<body class="unselectable">
<div id="signupInpWrapper">
<div class="signupdiv">
<h1 style="text-align: center;">Create an account</h1>
<div>
<label for="uemailinp">email</label>
<input type="email" class="inputField" id="uemailinp">
</div>
<div class="inputDiv">
<label for="unameinp">username</label>
<input type="text" class="inputField" id="unameinp">
</div>
<div class="inputDiv">
<label for="upassinp">password</label>
<input type="password" class="inputField" id="upassinp">
</div>
<div style="margin-top: 20px; text-align: center;">
<a class="submitBtn" onclick="createConfcodeRequest()">SUBMIT</a>
</div>
</div>
<div style="text-align: center; margin-top: 20px;">
<a class="backBtn" href="/">HOME</a>
</div>
</div>
<div id="confCodeInpWrapper" class="signupdiv" style="display: none;">
<h1>Confirmation email sent!</h1>
<label for="confCode">Confirmation Code</label>
<input type="text" class="inputField" id="confCode">
<div style="margin-top: 20px; text-align: center;">
<a class="submitBtn" onclick="sendConfCode()">SUBMIT</a>
</div>
</div>
<br><br>
<div style="text-align: center; color: red;">
<h1>ALL DATA IS UNENCRYPTED DURING THE ALPHA STAGE</h1>
<p>including your passwords</p>
</div>
</body>
</html>