This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home_index.js
297 lines (258 loc) · 14 KB
/
home_index.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
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
window.onload = async function checkServers() {
// kusama server alive check
await fetch('https://web.api.wallety.org/').then(() => {
// active or not
document.getElementById('kusama-status').innerHTML = 'Active';
document.getElementById('kusama-status').style.color = 'green';
// pulse colour
document.getElementById('kusama-blob').style.backgroundColor = 'green';
document.getElementById('kusama-blob').style.boxShadow = 'green';
}).catch(() => {
// active or not
document.getElementById('kusama-status').innerHTML = 'Inactive';
document.getElementById('kusama-status').style.color = 'red';
// // pulse colour
document.getElementById('kusama-blob').style.backgroundColor = 'red';
document.getElementById('kusama-blob').style.boxShadow = 'red';
});
// polkadot server alive check
await fetch('https://web.api.wallety.org/').then(() => {
// active or not
document.getElementById('polkadot-status').innerHTML = 'Active';
document.getElementById('polkadot-status').style.color = 'green';
// pulse colour
document.getElementById('polkadot-blob').style.backgroundColor = 'green';
document.getElementById('polkadot-blob').style.boxShadow = 'green';
}).catch(() => {
// active or not
document.getElementById('polkadot-status').innerHTML = 'Inactive';
document.getElementById('polkadot-status').style.color = 'red';
// // pulse colour
document.getElementById('polkadot-blob').style.backgroundColor = 'red';
document.getElementById('polkadot-blob').style.boxShadow = 'red';
});
servers_alive = false
// main server alive check
await fetch('https://web.api.wallety.org/').then(() => {
servers_alive = true
document.getElementById('serversDown').style.visibility = 'hidden'
document.getElementById('loading-screen').style.visibility = 'hidden'
document.getElementById('loading-screen').style.display = 'none'
document.getElementById('main').style.visibility = 'visible'
document.getElementById('main-bottom').style.display = 'flex'
// active or not
let root = document.querySelector(':root');
root.style.setProperty('--status-color', 'green');
var status = 'Active'
document.getElementById('status').innerHTML = status;
// pulse colour
root.style.setProperty('--pulse-color', 'green');
root.style.setProperty('--pulse-color-light', '#6CB56C');
}).catch(() => {
servers_alive = false
document.getElementById('loading-gif').innerHTML = ''
document.getElementById('loading-screen').style.visibility = 'hidden'
document.getElementById('loading-screen').style.display = 'none'
document.getElementById('main').style.visibility = 'hidden'
document.getElementById('serversDown').style.visibility = 'visible'
document.getElementById('serversDown').style.display = 'flex'
});
}
entryLoading = false
function submit_entry() {
if (servers_alive == true) {
if (entryLoading == false) {
entryLoading = true
var wallet_address = document.getElementById('wallet_address').value;
var option = document.getElementById("network");
var option = option.value;
document.getElementById('loading-gif').innerHTML = ''
if (wallet_address != ''){
if (option == 'kusama'){
async function checkReq(){
var loading_img = document.createElement("img");
loading_img.src = 'images/loading.gif';
var loading_span = document.getElementById("loading-gif");
loading_span.appendChild(loading_img);
var api_url = 'https://web.api.wallety.org/walletcheck/?wallet_address=' + wallet_address + '&specified_network=kusama'
checkNetworkReq = await fetch(api_url)
checkNetworkReqResponce = await checkNetworkReq.json()
if (checkNetworkReqResponce.wallet_network.network == 'kusama') {
var api_url = 'https://wallety.org/kusama?wallet_address=' + checkNetworkReqResponce.wallet_network.wallet_address
location.href = api_url;}
else {
if (checkNetworkReqResponce.wallet_network.network != false) {
var alert_text = 'Kusama wallet address not found, this is a ' + checkNetworkReqResponce.wallet_network.network + ' wallet address'
alert(alert_text)
} else {alert('Kusama wallet address not found or any matching networks we support')}
}
document.getElementById('loading-gif').innerHTML = ''
entryLoading = false
}
checkReq();
}
if (option == 'polkadot'){
async function checkReq(){
var loading_img = document.createElement("img");
loading_img.src = 'images/loading.gif';
var loading_span = document.getElementById("loading-gif");
loading_span.appendChild(loading_img);
var api_url = 'https://web.api.wallety.org/walletcheck/?wallet_address=' + wallet_address + '&specified_network=polkadot'
checkNetworkReq = await fetch(api_url)
checkNetworkReqResponce = await checkNetworkReq.json()
if (checkNetworkReqResponce.wallet_network.network == 'polkadot') {
var api_url = 'https://wallety.org/polkadot?wallet_address=' + checkNetworkReqResponce.wallet_network.wallet_address
location.href = api_url;}
else {
if (checkNetworkReqResponce.wallet_network.network != false) {
var alert_text = 'Polkadot wallet address not found, this is a ' + checkNetworkReqResponce.wallet_network.network + ' wallet address'
alert(alert_text)
} else {alert('Polkadot wallet address not found or any matching networks we support')}
}
document.getElementById('loading-gif').innerHTML = ''
entryLoading = false
}
checkReq();
}
if (option == 'all'){
async function checkReq(){
var loading_img = document.createElement("img");
loading_img.src = 'images/loading.gif';
var loading_span = document.getElementById("loading-gif");
loading_span.appendChild(loading_img);
var api_url = 'https://web.api.wallety.org/walletcheck/?wallet_address=' + wallet_address + '&specified_network=all'
checkNetworkReq = await fetch(api_url)
checkNetworkReqResponce = await checkNetworkReq.json()
if (checkNetworkReqResponce.wallet_network.network == 'polkadot') {
var api_url = 'https://wallety.org/polkadot?wallet_address=' + checkNetworkReqResponce.wallet_network.wallet_address
location.href = api_url;}
else if (checkNetworkReqResponce.wallet_network.network == 'kusama') {
var api_url = 'https://wallety.org/kusama?wallet_address=' + checkNetworkReqResponce.wallet_network.wallet_address
location.href = api_url;}
else {alert('Wallet address not found for the networks we support')}
document.getElementById('loading-gif').innerHTML = ''
entryLoading = false
}
checkReq();
}
} else {alert('Please enter a Wallet address')};
} else {alert('Please wait for the last search to load')}
} else {alert('Our servers are currently down, please try again later')}
}
document.getElementById("wallet_address")
.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode === 13) {
if (entryLoading == false) {
document.getElementById("search-button").click();
} else {alert('Please wait for the last search to load')}
}
});
// join wallety pop up
function joinWpopupOpen() {
document.getElementById("joinWallety").style.display = "block";
document.getElementById('join-w-submit').innerHTML = 'Submit'
}
function joinWpopupClose() {
document.getElementById("joinWallety").style.display = "none";
}
// join wallety form
async function sendJoinForm() {
if (servers_alive == true) {
var form_name = document.getElementById('form_name').value
var form_role = document.getElementById('form_role').value
var form_email = document.getElementById('form_email').value
var form_project = document.getElementById('form_project').value
var form_website = document.getElementById('form_website').value
var form_net = document.getElementById('form_net').value
var form_comments = document.getElementById('form_comments').value
if(form_name && form_role && form_email && form_project && form_website && form_net){
var form_url = 'https://web.api.wallety.org/joinwalletyform/?form_name=' + form_name + '&form_role=' + form_role + '&form_email=' + form_email + '&form_project=' + form_project + '&form_website=' + form_website + '&form_net=' + form_net + '&form_comments=' + form_comments
fetch(form_url);
document.getElementById('form_name').value = ''
document.getElementById('form_role').value = ''
document.getElementById('form_email').value = ''
document.getElementById('form_project').value = ''
document.getElementById('form_website').value = ''
document.getElementById('form_net').value = ''
document.getElementById('form_comments').value = ''
document.getElementById('join-w-submit').innerHTML = 'Sent!'
} else {alert('Some options have been left blank, please complete the form.')}
} else {alert('Our servers are currently down, please try again later')}
}
// suggest pop up
function suggestOpen() {
document.getElementById("suggest").style.display = "block";
document.getElementById('suggest-submit').innerHTML = 'Submit'
}
function suggestClose() {
document.getElementById("suggest").style.display = "none";
}
// suggest form
function sendSuggestForm() {
if (servers_alive == true) {
var suggestion = document.getElementById('suggestion').value
var suggestion_network = 'Home'
var suggest_email = document.getElementById('suggest-email').value
if (suggest_email == '') {suggest_email = false}
var suggest_bug = document.getElementById('bug-bttn')
if (suggest_bug.style.backgroundColor == 'black') {
var suggest_value = 'Bug'
} else var suggest_value = 'Suggestion'
if(suggestion){
var form_url = 'https://web.api.wallety.org/suggestion/?suggestion=' + suggestion + '&network=' + suggestion_network + '&suggest_type=' + suggest_value + '&suggest_email=' + suggest_email
fetch(form_url);
document.getElementById('suggestion').value = ''
document.getElementById('suggest-submit').innerHTML = 'Sent!'
document.getElementById('suggest-email').value = ''
} else {alert('Suggestion left blank, please complete the form')}
} else {alert('Our servers are currently down, please try again later')}
}
function report_req_suggest_bttn() {
document.getElementById('suggest-bttn').style.color = 'black'
document.getElementById('suggest-bttn').style.backgroundColor = 'white'
document.getElementById('bug-bttn').style.color = 'white'
document.getElementById('bug-bttn').style.backgroundColor = 'black'
}
function report_req_bug_bttn() {
document.getElementById('bug-bttn').style.color = 'black'
document.getElementById('bug-bttn').style.backgroundColor = 'white'
document.getElementById('suggest-bttn').style.color = 'white'
document.getElementById('suggest-bttn').style.backgroundColor = 'black'
}
// API pop up
function APIOpen() {
document.getElementById("API").style.display = "block";
document.getElementById('API_submit').innerHTML = 'Submit'
}
function APIClose() {
document.getElementById("API").style.display = "none";
}
// API form
function sendAPIForm() {
if (servers_alive == true) {
var API_name = document.getElementById('API_name').value
var API_email = document.getElementById('API_email').value
var API_comments = document.getElementById('API_comments').value
if(API_name && API_email){
var form_url = 'https://web.api.wallety.org/api_apply/?name=' + API_name + '&email=' + API_email + '&comments=' + API_comments
fetch(form_url);
document.getElementById('API_name').value = ''
document.getElementById('API_email').value = ''
document.getElementById('API_comments').value = ''
document.getElementById('API_submit').innerHTML = 'Sent!'
} else {alert('Input left blank, please complete the form')}
} else {alert('Our servers are currently down, please try again later')}
}
function report_req_suggest_bttn() {
document.getElementById('suggest-bttn').style.color = 'black'
document.getElementById('suggest-bttn').style.backgroundColor = 'white'
document.getElementById('bug-bttn').style.color = 'white'
document.getElementById('bug-bttn').style.backgroundColor = 'black'
}
function report_req_bug_bttn() {
document.getElementById('bug-bttn').style.color = 'black'
document.getElementById('bug-bttn').style.backgroundColor = 'white'
document.getElementById('suggest-bttn').style.color = 'white'
document.getElementById('suggest-bttn').style.backgroundColor = 'black'
}