-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend.js
65 lines (45 loc) · 1.24 KB
/
frontend.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
jQuery(function() {
const proxy_url = "https://cors.io?";
//global. when 0, nothing loads anymore
let stillUnchecked = 0;
function run() { //run, when input event happens
//1) clear #output
jQuery('#output').html('');
//2) start loading animation
startLoading();
//3) get username
const username = getInput();
//4) load portals
const allPortals = window.loadSpace.loadPortals(username);
stillUnchecked = allPortals.length;
//5) check any portal
for(let index=0; index < allPortals.length; index++) {
const url = allPortals[index]['url'];
const on_finish = allPortals[index].accountCheck;
jQuery.get(proxy_url + url, on_finish);
}
}
function getInput() {
return escape(jQuery('#username').val());
};
//====LOADING=FUNCTIONS========
function startLoading() {
jQuery('#submit').addClass('loading');
}
function stopLoading() {
jQuery('#submit').removeClass('loading');
}
//====INPUT=EVENTS==============
//this function will be run when enter is pressed in the #username input
jQuery('#username').keypress(function (e) {
if (e.which == 13) {
run();
}
});
//this function will run when button #submit is clicked
jQuery('#submit').click(function() {
run();
});
//======NO=JS=WARNING==========
jQuery('#no-js-warning').remove();
});