Skip to content
This repository was archived by the owner on Nov 1, 2025. It is now read-only.

Commit bfae6ba

Browse files
authored
Menambahkan pemain online di index.html
menampilkan jumlah pemain yang online di server
1 parent 07de966 commit bfae6ba

File tree

2 files changed

+114
-2
lines changed

2 files changed

+114
-2
lines changed

index.html

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,48 @@
1616
}
1717
</script>
1818
</head>
19+
<script>
20+
const serverIP = "leftycraft.my.id";
21+
22+
async function updateStatusButton() {
23+
const btn = document.getElementById("status-btn");
24+
if (!btn) return;
25+
26+
try {
27+
const response = await fetch(`https://api.mcsrvstat.us/2/${serverIP}`);
28+
const data = await response.json();
29+
30+
if (data.online) {
31+
btn.innerHTML = `<i class="fa-solid fa-signal"></i> Pemain Online: ${data.players.online}/${data.players.max}`;
32+
btn.classList.remove("btn-yellow");
33+
btn.classList.add("btn-green");
34+
} else {
35+
btn.innerHTML = `<i class="fa-solid fa-signal"></i> Offline`;
36+
btn.classList.remove("btn-yellow", "btn-green");
37+
btn.style.backgroundColor = "#e53935";
38+
btn.style.color = "#fff";
39+
}
40+
} catch (e) {
41+
console.error("Gagal ambil status:", e);
42+
btn.innerHTML = `<i class="fa-solid fa-signal"></i> Tidak dapat terhubung`;
43+
btn.classList.remove("btn-yellow", "btn-green");
44+
btn.style.backgroundColor = "#999";
45+
btn.style.color = "#000";
46+
}
47+
}
48+
49+
50+
function copyIP() {
51+
navigator.clipboard.writeText(serverIP).then(() => {
52+
alert("IP berhasil disalin: " + serverIP);
53+
});
54+
}
55+
56+
// Jalankan hanya setelah DOM siap
57+
document.addEventListener("DOMContentLoaded", updateStatusButton);
58+
</script>
59+
60+
1961
<body>
2062
<header class="header">
2163
<div class="logo">
@@ -36,7 +78,10 @@
3678
<section class="hero">
3779
<h1>Selamat Datang di LeftyCraft</h1>
3880
<p>Temukan informasi lengkap dan dukung server dengan membeli rank!</p>
39-
<a href="https://discord.gg/pY6QrjEshm" class="btn-yellow" target="_blank"><i class="fa-brands fa-discord"></i> Join Server</a>
81+
<button id="status-btn" class="btn-yellow" onclick="copyIP()">
82+
<i class="fa-solid fa-signal"></i> Mengecek status...
83+
</button>
84+
4085
</section>
4186

4287
<section class="fitur">
@@ -71,6 +116,12 @@ <h2>Informasi Server</h2>
71116
<div class="link-card"><i class="fa-brands fa-whatsapp"></i> Group Wa: <a href="https://chat.whatsapp.com/BQBZzXMyPVoDP5NZ6NvYUf" target="_blank">chat.whatsapp.com/BQBZzXMyPVoDP5NZ6NvYUf</a></div>
72117
</div>
73118
</section>
119+
<section class="server-status">
120+
<h2>Status Server</h2>
121+
<div id="status">
122+
<p>Mengecek status server...</p>
123+
</div>
124+
</section>
74125

75126
<section class="tutorial">
76127
<h2>Sosial Media</h2>

style.css

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ nav a.btn-yellow:hover,
118118
}
119119
}
120120

121-
}
122121
/* TRANSISI HALAMAN */
123122
.page-content {
124123
animation: fadeSlideIn 0.7s ease-out;
@@ -134,6 +133,40 @@ nav a.btn-yellow:hover,
134133
transform: translateY(0);
135134
}
136135
}
136+
.server-status {
137+
background: #121212;
138+
padding: 50px 20px;
139+
text-align: center;
140+
}
141+
142+
.server-status h2 {
143+
color: #ffcc00;
144+
font-size: 2rem;
145+
margin-bottom: 20px;
146+
}
147+
148+
#status {
149+
background: #1f1f1f;
150+
padding: 20px;
151+
border-radius: 10px;
152+
display: inline-block;
153+
color: white;
154+
font-size: 1.1rem;
155+
}
156+
#status-btn {
157+
font-size: 1.1rem;
158+
padding: 12px 20px;
159+
border: none;
160+
border-radius: 8px;
161+
cursor: pointer;
162+
font-weight: bold;
163+
transition: transform 0.2s, box-shadow 0.2s;
164+
}
165+
166+
#status-btn:hover {
167+
transform: translateY(-2px);
168+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
169+
}
137170

138171

139172
/* khusus untuk tombol di dalam rank-card */
@@ -157,6 +190,34 @@ nav a.btn-yellow {
157190
nav a.btn-yellow:hover {
158191
background: #e6b800;
159192
}
193+
/* Tombol status online dengan glow hijau */
194+
.btn-green {
195+
background: #4caf50;
196+
color: #fff;
197+
padding: 12px 20px;
198+
border-radius: 8px;
199+
font-weight: bold;
200+
border: none;
201+
cursor: pointer;
202+
transition: background 0.3s, box-shadow 0.3s;
203+
text-align: center;
204+
font-size: 1.1rem;
205+
}
206+
207+
.btn-green:hover {
208+
background: #66bb6a;
209+
box-shadow: 0 0 8px #4caf50, 0 0 16px #4caf50, 0 0 32px #4caf50;
210+
animation: pulseGreen 1.2s infinite alternate;
211+
}
212+
213+
@keyframes pulseGreen {
214+
from {
215+
box-shadow: 0 0 6px #4caf50, 0 0 12px #4caf50;
216+
}
217+
to {
218+
box-shadow: 0 0 12px #4caf50, 0 0 24px #4caf50;
219+
}
220+
}
160221

161222
@media (max-width: 768px) {
162223
.header {

0 commit comments

Comments
 (0)