-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
108 lines (88 loc) · 3.32 KB
/
script.js
File metadata and controls
108 lines (88 loc) · 3.32 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
// API FETCH-Start
const SERVER_IP = '185.97.255.17:1215'; // Soyuz
const API_URL = `http://${SERVER_IP}/status`;
const REFRESH_INTERVAL = 5000;
// Элементы
const playersCount = document.getElementById('players-current');
const serverStatus = document.getElementById('server-status');
const serverRound = document.getElementById('server-round');
const serverMap = document.getElementById('server-map');
const serverIp = document.getElementById('server-ip');
const serverPreset = document.getElementById('server-preset');
async function fetchServerStatus() {
try {
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(API_URL)}`;
const response = await fetch(proxyUrl, {
method: 'GET'
});
if (!response.ok)
throw new Error(`HTTP ${response.status}`);
const data = await response.json();
if (!data.contents)
throw new Error('Нет полученной информации от прокси');
const serverData = JSON.parse(data.contents);
// Обновляем интерфейс
playersCount.textContent = `${serverData.players} из ${serverData.soft_max_players}` || '—';
serverRound.textContent = serverData.round_id || '—';
serverMap.textContent = serverData.map || '—';
serverPreset.textContent = serverData.preset || '—';
serverIp.textContent = SERVER_IP;
serverStatus.textContent = 'Онлайн';
serverStatus.style.color = '#03da39';
} catch (error) {
console.error('Ошибка запроса:', error);
updateOfflineState();
}
}
function updateOfflineState() {
playersCount.textContent = '—';
serverRound.textContent = '—';
serverMap.textContent = '—';
serverPreset.textContent = '—';
serverIp.textContent = SERVER_IP;
serverStatus.textContent = 'Недоступен';
serverStatus.style.color = '#eb2e51';
}
// API FETCH-End
// FOOTER-Start
async function updateFooter() {
const footer = document.querySelector('footer.footer');
const files = [];
// HTML
files.push({ type: 'HTML', url: window.location.href });
// CSS
document.querySelectorAll('link[rel="stylesheet"][href]').forEach(link => {
files.push({ type: 'CSS', url: link.href });
});
// JS
document.querySelectorAll('script[src]').forEach(script => {
files.push({ type: 'JS', url: script.src });
});
const results = {};
for (const file of files) {
try {
const response = await fetch(file.url, { method: 'HEAD' });
const lastModified = response.headers.get('Last-Modified');
if (lastModified) {
const date = new Date(lastModified);
const formatted = date.toLocaleDateString('ru-RU'); // 18.01.2026
results[file.type] = formatted;
} else {
results[file.type] = 'н/д';
}
} catch (err) {
results[file.type] = 'ошибка';
}
}
const htmlDate = results.HTML || 'н/д';
const cssDate = results.CSS || 'н/д';
const jsDate = results.JS || 'н/д';
footer.textContent = `HTML: ${htmlDate} | CSS: ${cssDate} | JS: ${jsDate} © botcott`
}
// FOOTER-End
// Запуск
document.addEventListener('DOMContentLoaded', () => {
fetchServerStatus();
updateFooter()
setInterval(fetchServerStatus, REFRESH_INTERVAL);
});