forked from Testanki1/testanki1.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.html
More file actions
150 lines (150 loc) · 4.91 KB
/
status.html
File metadata and controls
150 lines (150 loc) · 4.91 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
147
148
149
150
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;700&display=swap" />
<link href="https://fonts.googleapis.com/css2?family=M+PLUS+1p&display=swap" rel="stylesheet">
<title>3D坦克服务器状态页面</title>
<style>
body {
background: radial-gradient(rgb(32, 48, 64) 0%, rgb(3, 8, 13) 100%);
font-family: 'Rubik', 'M PLUS 1p';
color: white;
margin: 0;
padding: 0;
}
#backButton {
position: absolute;
top: 10px;
left: 10px;
background-color: #76ff33;
padding: 10px;
border: none;
color: #001926;
font-size: 16px;
cursor: pointer;
border-radius: 10px;
transition: background-color 0.3s;
display: none;
}
#backButton:hover {
background-color: #4CAF50;
}
* {
-webkit-tap-highlight-color: transparent;
}
#refreshButton {
position: absolute;
top: 10px;
right: 10px;
background-color: #76ff33;
padding: 10px;
border: none;
color: #001926;
font-size: 16px;
cursor: pointer;
border-radius: 10px;
transition: background-color 0.3s;
}
#refreshButton:hover {
background-color: #4CAF50;
}
#refreshTimer {
position: absolute;
top: 10px;
right: 80px;
font-size: 16px;
}
#updateStatus {
margin-top: 30px;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}
.section {
text-align: center;
}
.section h1 {
font-size: 18px;
margin-bottom: 20px;
}
.section p {
margin-bottom: 10px;
}
a {
color: white;
text-decoration: none;
}
a:hover {
color: #76ff33;
}
</style>
</head>
<body>
<div class="container">
<div class="section">
<h1>国服</h1>
<p>在线:<span id="onlineCount"></span></p>
<p>战斗中:<span id="inbattlesCount"></span></p>
<p>4399:<span id="my4399ComCount"></span></p>
</div>
</div>
<button id="backButton" onclick="goBack()">返回</button>
<button id="refreshButton" onclick="manualRefresh()">刷新</button>
<span id="refreshTimer"><span>0</span></span>
<script>
let refreshInterval;
let refreshTime = 11;
function fetchBalancerStats() {
fetch('https://balancer.3dtank.com/balancer')
.then(response => response.json())
.then(data => {
let totalInbattles = 0;
let totalOnline = 0;
let totalMy4399Com = 0;
Object.values(data.nodes).forEach(node => {
totalInbattles += node.inbattles || 0;
totalOnline += node.online || 0;
totalMy4399Com += node.partners && node.partners.my_4399_com ? node.partners.my_4399_com : 0;
});
const my4399ComCount = totalMy4399Com || 0;
document.getElementById('inbattlesCount').innerText = totalInbattles;
document.getElementById('onlineCount').innerText = totalOnline;
document.getElementById('my4399ComCount').innerText = my4399ComCount;
})
.catch(error => console.error('Error fetching balancer data:', error));
}
function manualRefresh() {
clearInterval(refreshInterval);
refreshTime = 11;
startRefreshTimer();
fetchBalancerStats();
}
function startRefreshTimer() {
refreshInterval = setInterval(() => {
refreshTime--;
document.getElementById('refreshTimer').innerText = refreshTime;
if (refreshTime === 0) {
manualRefresh();
}
}, 1000);
}
function goBack() {
if (document.referrer.includes("testanki1.github.io")) {
window.history.back();
}
}
if (document.referrer.includes("testanki1.github.io")) {
document.getElementById("backButton").style.display = "block";
}
fetchBalancerStats();
startRefreshTimer();
setInterval(fetchBalancerStats, 11000);
</script>
</body>
</html>