Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
192 lines (158 loc) · 5.91 KB
/
Copy pathscript.js
File metadata and controls
192 lines (158 loc) · 5.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
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
const newsData = [
{
title: "Tuff Client 1.1 In Development!",
preview:
"Tuff Client 1.1 wil include revamps, significant preformance improvements, ability to go under y0, ViaBlocks, and 1.21 entity support!",
badge: "Article",
badgeColor: "#4CAF50",
},
{
title: "Astra 2 is in development",
preview:
"A sucessors which will be rewritted from the ground up to be faster, more stable, and more secure.",
badge: "Article",
badgeColor: "#4CAF50",
}
];
function populateNews() {
const container = document.getElementById("news-container");
container.innerHTML = "";
newsData.forEach((item, index) => {
const newsItem = document.createElement("div");
newsItem.className = "news-item";
newsItem.innerHTML = `
<div class="news-item-header">
<span class="news-badge" style="background: linear-gradient(45deg, ${item.badgeColor}, ${item.badgeColor}aa);">${item.badge}</span>
</div>
<div class="news-title-text">${item.title}</div>
<div class="news-preview">${item.preview}</div>
`;
newsItem.addEventListener("click", () => {
alert(`Opening: ${item.title}\n\n${item.preview}`);
});
container.appendChild(newsItem);
});
}
let currentVersion = "tuff-wasm";
function handleVersionChange() {
const versionSelect = document.getElementById("version-select");
const versionDisplay = document.getElementById("version-display");
if (!versionSelect || !versionDisplay) {
console.error("Version selector elements not found");
return;
}
const selectedVersion = versionSelect.value;
currentVersion = selectedVersion;
const versionText = versionSelect.options[versionSelect.selectedIndex].text;
versionDisplay.textContent = `Lunar Client ${versionText}`;
const currentUrl = window.location.href.split("?")[0].split("#")[0];
const urlParams = new URLSearchParams(window.location.search);
urlParams.set("version", selectedVersion);
const newUrl = `${currentUrl}?${urlParams.toString()}`;
window.history.pushState({}, "", newUrl);
versionSelect.style.transform = "scale(1.05)";
versionSelect.style.borderColor = "#00ff88";
versionSelect.style.boxShadow = "0 0 20px rgba(0, 255, 136, 0.6)";
setTimeout(() => {
versionSelect.style.transform = "";
versionSelect.style.borderColor = "#00ff88";
versionSelect.style.boxShadow = "";
}, 200);
showVersionNotification(versionText);
console.log("Version changed to:", selectedVersion, versionText);
}
function showVersionNotification(versionText) {
const existingNotifications = document.querySelectorAll(
".version-notification"
);
existingNotifications.forEach((n) => n.remove());
const notification = document.createElement("div");
notification.className = "version-notification";
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: linear-gradient(45deg, #00ff88, #00cc6a);
color: white;
padding: 15px 20px;
border-radius: 12px;
font-weight: bold;
z-index: 1000;
transform: translateX(100%);
opacity: 0;
transition: all 0.3s ease-out;
box-shadow: 0 10px 25px rgba(0, 255, 136, 0.3);
`;
notification.innerHTML = `✅ Version switched to ${versionText}`;
document.body.appendChild(notification);
setTimeout(() => {
notification.style.transform = "translateX(0)";
notification.style.opacity = "1";
}, 50);
setTimeout(() => {
notification.style.transform = "translateX(100%)";
notification.style.opacity = "0";
setTimeout(() => {
if (notification.parentNode) {
notification.parentNode.removeChild(notification);
}
}, 300);
}, 3000);
}
function launch() {
const btn = event.target.closest(".launch-btn");
const versionSelect = document.getElementById("version-select");
if (!btn || !versionSelect) {
console.error("Launch elements not found");
return;
}
const selectedVersion = versionSelect.value || "tuff-wasm";
const selectedOption = Array.from(versionSelect.options).find(
(opt) => opt.value === selectedVersion
);
const versionText = selectedOption ? selectedOption.text : "tuff-wasm";
btn.innerHTML = "Loading...";
btn.disabled = true;
const urlParams = new URLSearchParams(window.location.search);
setTimeout(() => {
window.location.href = `versions/${selectedVersion}`;
}, 2000);
}
document.addEventListener("DOMContentLoaded", () => {
populateNews();
setInterval(updateOnlineCount, 10000);
setTimeout(() => {
const versionSelect = document.getElementById("version-select");
const versionDisplay = document.getElementById("version-display");
if (versionSelect && versionDisplay) {
versionSelect.removeEventListener("change", handleVersionChange);
versionSelect.addEventListener("change", function (e) {
console.log("Dropdown changed to:", e.target.value);
handleVersionChange();
});
const urlParams = new URLSearchParams(window.location.search);
const versionParam = urlParams.get("version");
if (
versionParam &&
Array.from(versionSelect.options).some(
(opt) => opt.value === versionParam
)
) {
versionSelect.value = versionParam;
currentVersion = versionParam;
const selectedOption =
versionSelect.options[versionSelect.selectedIndex];
versionDisplay.textContent = `Lunar Client ${selectedOption.text}`;
} else {
}
}
}, 100);
});
document.querySelectorAll(".game-btn").forEach((btn) => {
btn.addEventListener("mouseenter", () => {
btn.style.boxShadow = "0 10px 25px rgba(0, 255, 136, 0.3)";
});
btn.addEventListener("mouseleave", () => {
btn.style.boxShadow = "";
});
});