-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
146 lines (125 loc) · 4.65 KB
/
script.js
File metadata and controls
146 lines (125 loc) · 4.65 KB
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
// --- GLOBAL CONFIG & STATE ---
let currentReview = 0;
const reviews = [
{ text: '"The infection system is terrifyingly efficient. System management at its peak."', user: "- Staff_Member_X" },
{ text: '"The most aesthetic bot interface I have ever used. Total immersion."', user: "- Neural_Link_7" },
{ text: '"GhostNet simplified our server security protocols overnight. Essential."', user: "- Root_Admin" }
];
// --- MAIN INITIALIZATION ---
document.addEventListener('DOMContentLoaded', () => {
const loader = document.getElementById('loading-screen');
const content = document.getElementById('main-content');
// 1. Check Login Status (If on Login Page)
if (window.location.pathname.includes('login')) {
if (localStorage.getItem('ghostnet_session') === 'true') {
window.location.href = '/dashboard';
return;
}
}
// 2. Initial Status Check
updateBotStatus();
setInterval(updateBotStatus, 30000);
// 3. Smart Loading Logic
const navEntries = performance.getEntriesByType("navigation");
const navType = navEntries.length > 0 ? navEntries[0].type : "";
const isFirstVisit = !sessionStorage.getItem('session_started');
const isReload = navType === 'reload';
if (isFirstVisit || isReload) {
sessionStorage.setItem('session_started', 'true');
if (loader && content) {
content.style.display = 'none';
content.style.opacity = '0';
startBoot();
}
} else {
if(loader) loader.style.display = 'none';
if(content) {
content.style.display = 'block';
content.style.opacity = '1';
}
}
updateHeaderUI();
});
// --- UI HELPERS ---
function updateHeaderUI() {
const guestLinks = document.getElementById('guest-links');
const userLinks = document.getElementById('user-links');
const isLoggedIn = localStorage.getItem('ghostnet_session') === 'true';
if (isLoggedIn && userLinks && guestLinks) {
guestLinks.style.display = 'none';
userLinks.style.display = 'inline';
}
}
// --- LOGIN LOGIC ---
function simulateDiscordLogin(e) {
const eventObj = e || window.event;
if (eventObj && eventObj.preventDefault) eventObj.preventDefault();
const btn = eventObj.currentTarget || document.activeElement;
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> AUTHORIZING...';
setTimeout(() => {
localStorage.setItem('ghostnet_session', 'true');
window.location.href = '/dashboard';
}, 1500);
}
function logout() {
localStorage.removeItem('ghostnet_session');
window.location.href = '/';
}
// --- BOT STATUS LOGIC ---
async function updateBotStatus() {
const dot = document.getElementById('status-dot');
const text = document.getElementById('status-text');
if (!dot || !text) return;
try {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);
await fetch('https://ghostnet-0p4u.onrender.com', {
mode: 'no-cors',
signal: controller.signal
});
clearTimeout(timeoutId);
dot.style.background = '#00ff41';
dot.style.boxShadow = '0 0 10px #00ff41';
text.style.color = '#00ff41';
text.innerText = 'SYSTEM_ONLINE';
} catch (e) {
dot.style.background = '#ff4444';
dot.style.boxShadow = '0 0 10px #ff4444';
text.style.color = '#ff4444';
text.innerText = 'SYSTEM_OFFLINE';
}
}
// --- BOOT SEQUENCE ---
function startBoot() {
const fill = document.getElementById('fill');
let w = 0;
const interval = setInterval(() => {
w += Math.random() * 15;
if (w >= 100) {
w = 100;
clearInterval(interval);
finishLoading();
}
if(fill) fill.style.width = w + '%';
}, 200);
}
function finishLoading() {
const loader = document.getElementById('loading-screen');
const content = document.getElementById('main-content');
if(loader) loader.style.opacity = '0';
setTimeout(() => {
if(loader) loader.style.display = 'none';
if(content) {
content.style.display = 'block';
setTimeout(() => { content.style.opacity = '1'; }, 50);
}
}, 500);
}
// --- REVIEW SLIDER ---
function moveReview(dir) {
currentReview += dir;
if (currentReview < 0) currentReview = reviews.length - 1;
if (currentReview >= reviews.length) currentReview = 0;
document.getElementById('review-text').innerText = reviews[currentReview].text;
document.getElementById('review-user').innerText = reviews[currentReview].user;
}