-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatewayDashboard.html
122 lines (102 loc) · 4.51 KB
/
gatewayDashboard.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
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><title>sh4rp.tech </title>
<link rel="stylesheet" type="text/css" href="gateway.css">
</head>
<div class = "navbar"><li id="home"><img src="https://home.sh4rp.tech/images/gateway_logo.png"></li><li id = "users"><p>Students</p></li><li><p>Blocklist</p></li><li><p>Analytics</p></li><li><p>Server</p></li>
</div>
<div class = "info" id = "info">
<div class="child">
<div class="home"><div><h1>Home</h1><div id="date">Date</div></div><div id="status">Server Status : connecting...</div></div>
</div>
</div>
<script>
n = new Date();
y = n.getFullYear();
m = n.getMonth() + 1;
d = n.getDate();
document.getElementById("date").innerHTML = m + "/" + d + "/" + y;
let wsStatus = "down"
let LSname = "[placeholder]"
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
const userToken = localStorage.getItem("token");
let usergrab = document.getElementById("users");
let socket = new WebSocket("wss://home.sh4rp.tech/ws");
let buffer = 0
socket.onopen = function(e) {
console.log('connected')
wsStatus = "up"
document.getElementById("status").innerHTML = "Server Status : Connected"
buffer = 1
};
socket.onmessage = function(e) {
let message = e.data;
let messageArray = message.split(' ');
let messageArray2 = message.split(";")
if(messageArray[0] == 1014){
drawuserl(messageArray[1]);
}
if(messageArray2[0] == 1016){
drawuserh(messageArray2[1])
}
}
function drawuserh(data){
let info = document.getElementById("info")
info.innerHTML = ""
let child = document.createElement("div")
child.classList.add("child");
info.appendChild(child);
let dataAr = data.split("\n")
let reload = document.createElement("li")
reload.innerHTML= '<div class="reload"><img src="./images/reload.png"></div>';
reload.addEventListener("click", function(event) {
socket.send("1015 " + localStorage.getItem("token") + " " + LSname)
});
child.appendChild(reload);
let name = document.createElement("li");
name.innerHTML = '<li><div class="overide">'+LSname+'</div></li>'
child.appendChild(name)
for(let i = 0; i < dataAr.length; i++){
let eventP = dataAr[i].split(" ")
let event = document.createElement("li")
if(eventP[0].length > 55){
eventP[0] = eventP[0].slice(0,55)
}
event.innerHTML = '<li><div><div>'+ eventP[0] +'</div><div class="date">'+ eventP[1] + '<br>' + eventP[2] +'</div></div></li>'
child.append(event)
}
}
function drawuserl(data){
let info = document.getElementById("info")
info.innerHTML = ""
let child = document.createElement("div")
child.classList.add("child");
info.appendChild(child);
let dataAr = data.split(";")
for(let i = 0; i < dataAr.length ;i ++){
let user = document.createElement("li")
user.innerHTML = '<div><d>' + dataAr[i] + '</d><img src="./images/arrow.png"></div>'
user.addEventListener("click", function (event){
let path = dataAr[i]
let murm = path.split("/")
let username = murm[murm.length - 1]
socket.send("1015 " + localStorage.getItem("token") + " " + username)
LSname = username;
});
child.appendChild(user);
}
}
usergrab.addEventListener("mousedown", function (event) {
console.log(("1013 " + localStorage.getItem("token")))
socket.send(("1013 " + localStorage.getItem("token")))
});
window.addEventListener('resize', () => {
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
});
document.getElementById("home").addEventListener("click", function(event){
location.reload()
})
</script>
</html>