-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
244 lines (212 loc) · 7.9 KB
/
index.html
File metadata and controls
244 lines (212 loc) · 7.9 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minecraft Server Status Checker</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
text-align: center;
}
h1 {
color: #333;
}
#serverForm {
margin: 20px auto;
max-width: 400px;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
}
label {
font-weight: bold;
display: block;
margin-bottom: 10px;
}
input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
transition: border-color 0.3s ease;
}
input[type="text"]:focus {
border-color: #007bff;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
}
button:hover {
background-color: #0056b3;
}
button.clicked {
background-color: #0056b3;
transform: scale(0.95);
}
/* Improved UI styles */
.info-container {
background-color: #fff;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
margin-top: 20px;
opacity: 0;
transform: translateY(10px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.info-container h2 {
color: #007bff;
margin-bottom: 10px;
}
.info-container p {
margin: 5px 0;
}
.info-container.show {
opacity: 1;
transform: translateY(0);
}
#serverIcon {
display: none;
max-width: 64px;
height: auto;
margin-top: 10px;
border-radius: 5px;
transition: opacity 0.3s ease;
}
#debugInfo {
font-size: 16px;
text-align: left;
margin-top: 20px;
opacity: 0;
transform: translateY(10px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
#debugInfo.show {
opacity: 1;
transform: translateY(0);
}
</style>
</head>
<body>
<h1>Minecraft Server Status Checker</h1>
<form id="serverForm">
<label for="serverAddress">Server Address:</label>
<input type="text" id="serverAddress" placeholder="Enter server address (e.g., example.com)" required><br>
<button type="button" id="checkStatus">Check Status</button>
</form>
<!-- Improved UI containers for server information -->
<div class="info-container" id="motdContainer">
<h2>MOTD:</h2>
<p id="motd"></p>
</div>
<div class="info-container" id="playersContainer">
<h2>Players:</h2>
<p id="playerCount"></p>
</div>
<div class="info-container" id="versionContainer">
<h2>Version:</h2>
<p id="serverVersion"></p>
</div>
<img id="serverIcon" src="" alt="Server Icon">
<div id="debugInfo" class="info-container"></div>
<script>
const serverAddressInput = document.getElementById("serverAddress");
const checkStatusButton = document.getElementById("checkStatus");
checkStatusButton.addEventListener("click", function () {
const serverAddress = serverAddressInput.value;
const apiUrl = `https://api.mcsrvstat.us/3/${serverAddress}`;
// Preload the server icon
const iconUrl = `https://api.mcsrvstat.us/icon/${serverAddress}`;
const serverIcon = document.getElementById("serverIcon");
serverIcon.src = iconUrl;
fetch(apiUrl)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.online) {
updateUI(data);
} else {
hideInfoContainers();
document.getElementById("statusMessage").textContent = "Server is offline.";
}
// Display debug info
const debugInfo = document.getElementById("debugInfo");
debugInfo.innerHTML = `
<h2>Debug Info:</h2>
<p>Cache time: ${data.debug.cachetime}</p>
<p>Hostname: ${data.hostname}</p>
<p>IP address: ${data.ip}</p>
<p>Port: ${data.port}</p>
<p>Protocol version: ${data.protocol.version} (${data.protocol.name})</p>
<p>Blocked by Mojang: ${data.eula_blocked ? 'Yes' : 'No'}</p>
<p>SRV record: ${data.debug.srv ? 'Yes' : 'No'}</p>
<p>Ping: ${data.debug.ping ? 'Yes' : 'No'}</p>
<p>Query: ${data.debug.query ? 'Yes' : 'No'}</p>
`;
// Show debug info and server icon with animations
setTimeout(() => {
debugInfo.classList.add("show");
serverIcon.style.display = "block";
serverIcon.style.opacity = "1";
}, 300);
})
.catch(error => {
hideInfoContainers();
document.getElementById("statusMessage").textContent = "Error checking server status.";
});
// Add animation to the button
checkStatusButton.classList.add("clicked");
setTimeout(() => {
checkStatusButton.classList.remove("clicked");
}, 200);
});
// Check for server address in the URL
const url = new URL(window.location.href);
const serverParam = url.searchParams.get("server");
if (serverParam) {
serverAddressInput.value = serverParam;
checkStatusButton.click();
}
// Function to update UI with server information
function updateUI(data) {
// MOTD
const motdContainer = document.getElementById("motdContainer");
motdContainer.style.display = "block";
motdContainer.classList.add("show");
document.getElementById("motd").innerHTML = data.motd.clean.join('<br>');
// Player count
const playersContainer = document.getElementById("playersContainer");
playersContainer.style.display = "block";
playersContainer.classList.add("show");
document.getElementById("playerCount").textContent = `${data.players.online} / ${data.players.max}`;
// Version
const versionContainer = document.getElementById("versionContainer");
versionContainer.style.display = "block";
versionContainer.classList.add("show");
document.getElementById("serverVersion").textContent = data.version;
}
// Function to hide info containers
function hideInfoContainers() {
const infoContainers = document.querySelectorAll(".info-container");
infoContainers.forEach(container => {
container.style.display = "none";
});
}
</script>
</body>
</html>