-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
51 lines (43 loc) · 1.5 KB
/
Copy pathmain.js
File metadata and controls
51 lines (43 loc) · 1.5 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
var url = "https://api.minetools.eu/ping/opencolamod.com";
$.getJSON(url, function(r) {
//data is the JSON string
if (r.error) {
$('#rest').html('Server Offline');
return false;
}
var pl = '';
if (r.players.sample.length > 0) {
pl = '<br>OP: ' + r.players.sample[0].name;
}
$('#rest').html(r.description.replace(/§(.+?)/gi, '') + '<br><b>Players Online:</b> ' + r.players.online + pl);
$('#favicon').attr('src', r.favicon);
});
$(document).ready(function() {
var url = "https://api.minetools.eu/ping/opencolamod.com";
$.getJSON(url, function(r) {
if (r.error) {
$('#rest').html('Server Offline');
return false;
}
var pl = '';
if (r.players.sample.length > 0) {
pl = '<br>OP: ' + r.players.sample[0].name;
}
$('#rest').html(r.description.replace(/§(.+?)/gi, '') + '<br><b>Players Online:</b> ' + r.players.online + pl);
$('#favicon').attr('src', r.favicon);
// Dark mode toggle functionality
const toggleButton = document.getElementById('dark-mode-toggle');
toggleButton.addEventListener('click', function() {
document.body.classList.toggle('dark-mode');
// Save the user's preference in localStorage
if(document.body.classList.contains('dark-mode')) {
localStorage.setItem('theme', 'dark');
} else {
localStorage.setItem('theme', 'light');
}
});
// Check the user's preference on page load
if(localStorage.getItem('theme') === 'dark') {
document.body.classList.add('dark-mode');
}
});