-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
219 lines (199 loc) · 9.9 KB
/
Copy pathapp.js
File metadata and controls
219 lines (199 loc) · 9.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
(() => {
'use strict';
const html = document.documentElement;
const languageButtons = [...document.querySelectorAll('[data-set-lang]')];
const translated = [...document.querySelectorAll('[data-ru][data-en]')];
const appShot = document.getElementById('app-shot');
const galleryShot = document.getElementById('gallery-shot');
const queryLanguage = new URLSearchParams(location.search).get('lang');
function setLanguage(language) {
const selected = language === 'en' ? 'en' : 'ru';
html.lang = selected;
translated.forEach(node => { node.textContent = node.dataset[selected]; });
languageButtons.forEach(button => button.classList.toggle('active', button.dataset.setLang === selected));
const shot = selected === 'ru' ? 'assets/app-ru.png' : 'assets/app-en.png';
if (appShot) appShot.src = shot;
if (galleryShot) galleryShot.src = shot;
document.title = selected === 'ru'
? 'PeekMify — оптимизатор Windows для CS2'
: 'PeekMify — Windows optimizer for CS2';
try { localStorage.setItem('peekmify-language', selected); } catch { /* private mode */ }
}
languageButtons.forEach(button => button.addEventListener('click', () => setLanguage(button.dataset.setLang)));
let storedLanguage;
try { storedLanguage = localStorage.getItem('peekmify-language'); } catch { storedLanguage = null; }
const browserLanguage = navigator.language?.toLowerCase().startsWith('ru') ? 'ru' : 'en';
setLanguage(queryLanguage || storedLanguage || browserLanguage);
const revealObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
revealObserver.unobserve(entry.target);
}
});
}, { threshold: 0.12, rootMargin: '0px 0px -30px' });
document.querySelectorAll('.reveal').forEach(element => revealObserver.observe(element));
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', event => {
const target = document.querySelector(anchor.getAttribute('href'));
if (!target) return;
event.preventDefault();
target.scrollIntoView({ behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' });
});
});
document.querySelectorAll('.magnetic').forEach(button => {
button.addEventListener('pointermove', event => {
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const rect = button.getBoundingClientRect();
const x = (event.clientX - rect.left - rect.width / 2) * 0.08;
const y = (event.clientY - rect.top - rect.height / 2) * 0.12;
button.style.transform = `translate(${x}px, ${y}px)`;
});
button.addEventListener('pointerleave', () => { button.style.transform = ''; });
});
const versionElement = document.getElementById('release-version');
fetch('update/latest.json', { cache: 'no-store' })
.then(response => response.ok ? response.json() : null)
.then(manifest => {
if (manifest?.version && versionElement) versionElement.textContent = `v${manifest.version}`;
})
.catch(() => { /* Website remains fully usable offline. */ });
const defenderStatus = document.getElementById('defender-status');
const scanDate = document.getElementById('scan-date');
const virusTotalStatus = document.getElementById('virustotal-status');
const virusTotalLink = document.getElementById('virustotal-link');
const installerHash = document.getElementById('installer-sha');
const copyHash = document.getElementById('copy-hash');
fetch('security/latest.json', { cache: 'no-store' })
.then(response => response.ok ? response.json() : null)
.then(report => {
if (!report) return;
if (defenderStatus && report.microsoftDefender?.status === 'clean') {
defenderStatus.dataset.ru = 'Угроз не обнаружено';
defenderStatus.dataset.en = 'No threats detected';
}
if (defenderStatus && report.microsoftDefender?.status === 'not-run') {
defenderStatus.dataset.ru = 'Новая проверка не запускалась';
defenderStatus.dataset.en = 'New scan not run';
}
if (scanDate && report.generatedUtc && report.microsoftDefender?.status === 'clean') {
const date = new Date(report.generatedUtc).toLocaleDateString(html.lang === 'ru' ? 'ru-RU' : 'en-US');
scanDate.dataset.ru = `Проверено: ${date}`;
scanDate.dataset.en = `Scanned: ${date}`;
} else if (scanDate && report.generatedUtc) {
const date = new Date(report.generatedUtc).toLocaleDateString(html.lang === 'ru' ? 'ru-RU' : 'en-US');
scanDate.dataset.ru = `Отчёт сборки: ${date}`;
scanDate.dataset.en = `Build report: ${date}`;
}
if (installerHash && report.installer?.sha256) installerHash.textContent = report.installer.sha256.toUpperCase();
if (virusTotalStatus && report.virusTotal) {
const detected = Number(report.virusTotal.detections || 0);
const engines = Number(report.virusTotal.engines || 0);
virusTotalStatus.dataset.ru = report.virusTotal.status === 'complete' ? `${detected} из ${engines} обнаружений` : 'Анализ ожидается';
virusTotalStatus.dataset.en = report.virusTotal.status === 'complete' ? `${detected} of ${engines} detections` : 'Analysis pending';
}
if (virusTotalLink && report.virusTotal?.url) {
virusTotalLink.href = report.virusTotal.url;
virusTotalLink.target = '_blank';
virusTotalLink.rel = 'noopener noreferrer';
virusTotalLink.classList.remove('disabled');
virusTotalLink.removeAttribute('aria-disabled');
}
setLanguage(html.lang);
})
.catch(() => { /* Security report is optional while browsing a local copy. */ });
copyHash?.addEventListener('click', async () => {
const value = installerHash?.textContent?.trim();
if (!value || value.length !== 64) return;
try {
await navigator.clipboard.writeText(value);
const ru = 'Скопировано';
const en = 'Copied';
copyHash.textContent = html.lang === 'ru' ? ru : en;
setTimeout(() => { copyHash.textContent = copyHash.dataset[html.lang]; }, 1400);
} catch { /* Clipboard permissions can be denied by the browser. */ }
});
const ratingButtons = [...document.querySelectorAll('[data-rating]')];
const ratingValue = document.getElementById('rating-value');
const ratingSubmit = document.getElementById('rating-submit');
const ratingStatus = document.getElementById('rating-status');
const ratingStorageKey = 'peekmify-rating-v1';
let selectedRating = 5;
function paintRating(value) {
selectedRating = Math.min(5, Math.max(1, Number(value) || 5));
ratingButtons.forEach(button => {
const active = Number(button.dataset.rating) <= selectedRating;
button.classList.toggle('active', active);
button.setAttribute('aria-checked', String(Number(button.dataset.rating) === selectedRating));
});
if (ratingValue) ratingValue.textContent = `${selectedRating}/5`;
}
function lockRating(storedValue) {
paintRating(storedValue);
ratingButtons.forEach(button => { button.disabled = true; });
if (ratingSubmit) {
ratingSubmit.disabled = true;
ratingSubmit.dataset.ru = 'ОЦЕНКА СОХРАНЕНА';
ratingSubmit.dataset.en = 'RATING SAVED';
}
if (ratingStatus) {
ratingStatus.dataset.ru = `Спасибо! Ваша оценка ${selectedRating}/5 сохранена в этом браузере.`;
ratingStatus.dataset.en = `Thank you! Your ${selectedRating}/5 rating is saved in this browser.`;
}
setLanguage(html.lang);
}
let storedRating = null;
try { storedRating = localStorage.getItem(ratingStorageKey); } catch { /* Storage can be disabled. */ }
if (storedRating && /^[1-5]$/.test(storedRating)) lockRating(storedRating);
else paintRating(5);
ratingButtons.forEach(button => button.addEventListener('click', () => paintRating(button.dataset.rating)));
ratingSubmit?.addEventListener('click', () => {
try { localStorage.setItem(ratingStorageKey, String(selectedRating)); } catch { /* Keep the UI usable. */ }
lockRating(selectedRating);
});
document.getElementById('year').textContent = String(new Date().getFullYear());
const canvas = document.getElementById('ambient');
if (!canvas || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const context = canvas.getContext('2d', { alpha: true });
let width = 0;
let height = 0;
let particles = [];
function resize() {
const ratio = Math.min(devicePixelRatio || 1, 2);
width = innerWidth;
height = innerHeight;
canvas.width = Math.round(width * ratio);
canvas.height = Math.round(height * ratio);
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
context.setTransform(ratio, 0, 0, ratio, 0, 0);
particles = Array.from({ length: Math.min(70, Math.max(28, Math.floor(width / 22))) }, () => ({
x: Math.random() * width,
y: Math.random() * height,
vx: .08 + Math.random() * .28,
vy: -.04 - Math.random() * .18,
size: .4 + Math.random() * 1.4,
alpha: .08 + Math.random() * .32
}));
}
function draw() {
context.clearRect(0, 0, width, height);
for (const particle of particles) {
particle.x += particle.vx;
particle.y += particle.vy;
if (particle.x > width + 5 || particle.y < -5) {
particle.x = -5;
particle.y = Math.random() * height;
}
context.beginPath();
context.fillStyle = `rgba(255, 102, 0, ${particle.alpha})`;
context.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2);
context.fill();
}
if (!document.hidden) requestAnimationFrame(draw);
}
addEventListener('resize', resize, { passive: true });
document.addEventListener('visibilitychange', () => { if (!document.hidden) requestAnimationFrame(draw); });
resize();
draw();
})();