-
Notifications
You must be signed in to change notification settings - Fork 0
/
subcount.js
66 lines (53 loc) · 1.8 KB
/
subcount.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
//Made by JonBot415 ;)
var sub_count = "";
var user_name = "Vidlii";
setInterval(function(){
$.get("fetch.php?username="+user_name, function(data) {
if (data == "not_found") {
document.getElementById("avatar").src = "error.png";
document.getElementById("username").innerHTML = "";
document.getElementById("subs").innerHTML = "";
document.getElementById("error").innerHTML = "User does not exist.";
} else {
document.getElementById("error").innerHTML = "";
user_data = data.split("|");
if (sub_count !== user_data[0]) {
var sub_element = document.getElementById("subs");
sub_element.innerHTML = user_data[0]+" Subscribers";
sub_element.className = "fadeInUp animated";
setTimeout(function(){ sub_element.className = "done"; }, 800)
}
sub_count = user_data[0];
}
});
}, 3000);
function set_username() {
user_name = document.getElementById("user").value;
$.get("fetch.php?username="+user_name, function(data) {
if (data == "not_found") {
document.getElementById("avatar").src = "error.png";
document.getElementById("username").innerHTML = "";
document.getElementById("subs").innerHTML = "";
document.getElementById("error").innerHTML = "User does not exist.";
} else {
document.getElementById("error").innerHTML = "";
user_data = data.split("|");
sub_count = user_data[0];
var sub_element = document.getElementById("subs");
sub_element.innerHTML = user_data[0]+" Subscribers";
sub_element.className = "fadeInUp animated";
setTimeout(function(){ sub_element.className = "done"; }, 800)
document.getElementById("username").innerHTML = user_data[2];
document.getElementById("avatar").src = user_data[1];
}
});
}
function enter_username(e){
e=e||window.event;
var key = e.keyCode;
if(key==13) //Enter
{
set_username();
return false; //return true to submit, false to do nothing
}
}