PageSourceSearch

https://majestic-mods.ru/js/global_notification.js

js majestic-mods.ru collected 2026-10-08 14:34:59 UTC 3,218 bytes, 78 lines download raw bytes

1function showPersistentGlobalNotify() {
2 const shownKey = "shownGlobalNotify";
3
4 fetch("https://majesticredux.ru/cache/global_notification.json?ts=" + Date.now())
5 .then(r => r.json())
6 .then(data => {
7 const lastShown = localStorage.getItem(shownKey);
8 if (data.message && String(data.timestamp) !== lastShown) {
9 createGlobalNotification(data.type, data.message, data.sound || null, data.timestamp, data.style || "admin");
10
11 }
12 })
13 .catch(e => console.warn("❌ Не удалось загрузить глобальное уведомление", e));
14}
15
16showPersistentGlobalNotify();
17
18function createGlobalNotification(type, message, sound = null, timestamp = null, style = "admin") {
19 const config = {
20 success: { icon: "https://majestic-mods.ru/images/icons_popup/succes.png", color: "#28a745", sound: "success.mp3" },
21 error: { icon: "https://majestic-mods.ru/images/icons_popup/error.png", color: "#dc3545", sound: "error.mp3" },
22 warn: { icon: "https://majestic-mods.ru/images/icons_popup/warning.png", color: "#ffc107", sound: "warning.mp3" },
23 info: { icon: "https://majestic-mods.ru/images/icons_popup/info.png", color: "#17a2b8", sound: "info.mp3" },
24 mmc: { icon: "https://majestic-mods.ru/images/icons_popup/mmc.png", color: "#e81c5a", sound: "kassa.mp3" }
25 };
26
27 const { icon, color, sound: defaultSound } = config[type] || config.info;
28 let finalSound = sound || defaultSound;
29
30// Если стиль "admin" — использовать специальный звук
31if (style === "admin") {
32 finalSound = "notification.mp3";
33}
34
35
36 if (timestamp && localStorage.getItem("shownGlobalNotify") === String(timestamp)) return;
37
38 let popup = document.getElementById("global-notify-box");
39 if (popup) popup.remove();
40
41 popup = document.createElement("div");
42 popup.id = "global-notify-box";
43 popup.className = "site-notification";
44 popup.classList.add("type-" + type);
45 popup.classList.add("style-" + style);
46 popup.style.borderRight = `3px solid ${color}`;
47
48 // Вариант оформления
49 popup.innerHTML = style === "admin" ? `
50 <div class="site-notification-icon"><img src="${icon}" alt="${type}"></div>
51 <div class="site-notification-wrapper">
52 <div class="site-notification-title">📢 Сообщение от администратора</div>
53 <div class="site-notification-text"></div>
54 </div>
55 <div class="site-notification-close" title="Закрыть">✖</div>
56 ` : `
57 <div class="site-notification-icon"><img src="${icon}" alt="${type}"></div>
58 <div class="site-notification-text"></div>
59 <div class="site-notification-close" title="Закрыть">✖</div>
60 `;
61
62 popup.querySelector(".site-notification-text").innerHTML = message;
63
64 document.body.appendChild(popup);
65 requestAnimationFrame(() => popup.classList.add("notify-show"));
66
67 const audio = new Audio(`https://majestic-mods.ru/audio/${finalSound}`);
68 audio.play().catch(err => console.warn("🔇 Звук не воспроизводится:", err));
69
70 popup.querySelector(".site-notification-close").onclick = () => {
71 popup.classList.remove("notify-show");
72 popup.classList.add("notify-hide");
73 setTimeout(() => popup.remove(), 500);
74 if (timestamp) {
75 localStorage.setItem("shownGlobalNotify", String(timestamp));
76 }
77 };
78}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.