Add compact router effects menu

This commit is contained in:
kzolotarev95 committed 2026-11-04 03:06:37 +04:00
1 parent 607837ef1f
commit d92257edd6
5 files changed
+1240 -3

No files matched your search

+69 -3
View File
@@ -510,14 +510,20 @@ render_page() {
http_html http_html
cat <<EOF cat <<EOF
<!doctype html> <!doctype html>
<html lang="ru"> <html lang="ru" data-hub-shared-effects="1">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="owrt-remote-ui-version" content="$OWRT_REMOTE_UI_VERSION"> <meta name="owrt-remote-ui-version" content="$OWRT_REMOTE_UI_VERSION">
<title>OpenWrt Remote Hub v120</title> <title>OpenWrt Remote Hub v120</title>
<script>
try {
const design = localStorage.getItem('owrtRemote:hubDesign');
document.documentElement.dataset.hubDesign = ['winter', 'lite'].includes(design) ? design : 'default';
} catch (error) { document.documentElement.dataset.hubDesign = 'default'; }
</script>
<style> <style>
:root{color-scheme:dark;--bg:#07040f;--panel:rgba(19,14,32,.88);--text:#f7f2ff;--muted:#b9adc9;--line:rgba(169,126,255,.24);--blue:#7c3aed;--green:#22c55e;--red:#fb7185;--amber:#f59e0b;--teal:#a855f7;--grid:rgba(168,85,247,.16)} :root{color-scheme:dark;--bg:#07040f;--panel:rgba(19,14,32,.88);--panel2:rgba(255,255,255,.07);--text:#f7f2ff;--muted:#b9adc9;--line:rgba(169,126,255,.24);--blue:#7c3aed;--green:#22c55e;--red:#fb7185;--amber:#f59e0b;--teal:#a855f7;--grid:rgba(168,85,247,.16)}
*{box-sizing:border-box}body{position:relative;min-height:100vh;margin:0;overflow-x:hidden;background-color:var(--bg);background-image:radial-gradient(circle at 12% 8%,rgba(168,85,247,.46),transparent 31%),radial-gradient(circle at 82% 12%,rgba(79,70,229,.38),transparent 30%),radial-gradient(circle at 50% 105%,rgba(236,72,153,.26),transparent 35%),linear-gradient(145deg,#07040f,#120a24 48%,#05030a),repeating-linear-gradient(0deg,transparent 0 30px,var(--grid) 31px),repeating-linear-gradient(90deg,transparent 0 30px,var(--grid) 31px);background-size:130% 130%,140% 140%,135% 135%,100% 100%,31px 31px,31px 31px;background-attachment:fixed;color:var(--text);font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;animation:bgFlow 22s ease-in-out infinite alternate} *{box-sizing:border-box}body{position:relative;min-height:100vh;margin:0;overflow-x:hidden;background-color:var(--bg);background-image:radial-gradient(circle at 12% 8%,rgba(168,85,247,.46),transparent 31%),radial-gradient(circle at 82% 12%,rgba(79,70,229,.38),transparent 30%),radial-gradient(circle at 50% 105%,rgba(236,72,153,.26),transparent 35%),linear-gradient(145deg,#07040f,#120a24 48%,#05030a),repeating-linear-gradient(0deg,transparent 0 30px,var(--grid) 31px),repeating-linear-gradient(90deg,transparent 0 30px,var(--grid) 31px);background-size:130% 130%,140% 140%,135% 135%,100% 100%,31px 31px,31px 31px;background-attachment:fixed;color:var(--text);font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;animation:bgFlow 22s ease-in-out infinite alternate}
body::before{content:"";position:fixed;inset:-25%;z-index:0;pointer-events:none;background:conic-gradient(from 0deg at 50% 50%,rgba(168,85,247,.05),rgba(236,72,153,.38),rgba(59,130,246,.24),rgba(245,158,11,.16),rgba(168,85,247,.05));filter:blur(52px);opacity:.72;animation:auraSpin 32s linear infinite} body::before{content:"";position:fixed;inset:-25%;z-index:0;pointer-events:none;background:conic-gradient(from 0deg at 50% 50%,rgba(168,85,247,.05),rgba(236,72,153,.38),rgba(59,130,246,.24),rgba(245,158,11,.16),rgba(168,85,247,.05));filter:blur(52px);opacity:.72;animation:auraSpin 32s linear infinite}
@keyframes bgFlow{0%{background-position:0% 0%,100% 0%,50% 100%,0 0,0 0,0 0}50%{background-position:28% 18%,62% 26%,38% 82%,0 0,15px 24px,24px 15px}100%{background-position:48% 28%,42% 42%,74% 62%,0 0,30px 0,0 30px}} @keyframes bgFlow{0%{background-position:0% 0%,100% 0%,50% 100%,0 0,0 0,0 0}50%{background-position:28% 18%,62% 26%,38% 82%,0 0,15px 24px,24px 15px}100%{background-position:48% 28%,42% 42%,74% 62%,0 0,30px 0,0 30px}}
@@ -536,15 +542,23 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
.helperText{margin:0 0 12px;color:var(--muted)}.xrayApply{margin-top:14px;padding:16px;border:1px solid rgba(34,211,238,.42);border-radius:8px;background:linear-gradient(135deg,rgba(34,211,238,.16),rgba(124,58,237,.20),rgba(236,72,153,.11));box-shadow:0 18px 42px rgba(34,211,238,.10)}.xrayApply h3{margin:0 0 8px;font-size:16px;color:#a5f3fc}.scriptBox{width:100%;min-height:260px;resize:vertical;border:1px solid rgba(34,211,238,.28);border-radius:8px;background:rgba(255,255,255,.07);padding:12px;color:var(--text);font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre;overflow:auto} .helperText{margin:0 0 12px;color:var(--muted)}.xrayApply{margin-top:14px;padding:16px;border:1px solid rgba(34,211,238,.42);border-radius:8px;background:linear-gradient(135deg,rgba(34,211,238,.16),rgba(124,58,237,.20),rgba(236,72,153,.11));box-shadow:0 18px 42px rgba(34,211,238,.10)}.xrayApply h3{margin:0 0 8px;font-size:16px;color:#a5f3fc}.scriptBox{width:100%;min-height:260px;resize:vertical;border:1px solid rgba(34,211,238,.28);border-radius:8px;background:rgba(255,255,255,.07);padding:12px;color:var(--text);font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre;overflow:auto}
.brandPanel{display:grid;grid-template-columns:repeat(2,minmax(0,132px));gap:8px}.brandPanel .titleRow,.brandPanel .links{grid-column:1/-1}.brandPanel .appBanner{width:100%;min-width:0}.brandPanel .links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:0}.brandPanel .links a{width:100%;min-width:0} .brandPanel{display:grid;grid-template-columns:repeat(2,minmax(0,132px));gap:8px}.brandPanel .titleRow,.brandPanel .links{grid-column:1/-1}.brandPanel .appBanner{width:100%;min-width:0}.brandPanel .links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:0}.brandPanel .links a{width:100%;min-width:0}
.wanPicker{border:1px solid var(--line);border-radius:8px;background:rgba(8,5,18,.72)}.wanPicker summary{display:flex;align-items:center;justify-content:center;gap:5px;min-height:40px;padding:10px 11px;cursor:pointer;list-style:none;font-weight:700}.wanPicker summary::-webkit-details-marker{display:none}.wanPicker summary::after{content:"▾";margin-left:auto;color:var(--muted)}.wanPicker[open] summary::after{content:"▴"}.wanPickerList{display:flex;flex-direction:column;gap:4px;max-height:240px;overflow:auto;padding:6px;border-top:1px solid var(--line)}.wanChoice{display:flex;align-items:center;gap:10px;min-height:40px;padding:8px;border-radius:6px;cursor:pointer;overflow-wrap:anywhere}.wanChoice:hover{background:rgba(255,255,255,.08)}.wanChoice input{width:18px;height:18px;min-width:18px;padding:0;margin:0;accent-color:var(--blue)}.wanPicked{margin-top:6px;font-size:12px;color:var(--muted);overflow-wrap:anywhere} .wanPicker{border:1px solid var(--line);border-radius:8px;background:rgba(8,5,18,.72)}.wanPicker summary{display:flex;align-items:center;justify-content:center;gap:5px;min-height:40px;padding:10px 11px;cursor:pointer;list-style:none;font-weight:700}.wanPicker summary::-webkit-details-marker{display:none}.wanPicker summary::after{content:"▾";margin-left:auto;color:var(--muted)}.wanPicker[open] summary::after{content:"▴"}.wanPickerList{display:flex;flex-direction:column;gap:4px;max-height:240px;overflow:auto;padding:6px;border-top:1px solid var(--line)}.wanChoice{display:flex;align-items:center;gap:10px;min-height:40px;padding:8px;border-radius:6px;cursor:pointer;overflow-wrap:anywhere}.wanChoice:hover{background:rgba(255,255,255,.08)}.wanChoice input{width:18px;height:18px;min-width:18px;padding:0;margin:0;accent-color:var(--blue)}.wanPicked{margin-top:6px;font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.globalLogsPanel[hidden]{display:none}.globalLogsPanel{margin-top:16px}.globalLogsPanel .actions{justify-content:flex-start;margin:0 0 12px}.globalLogsText{margin:12px 0 0;max-height:55vh;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace;background:rgba(8,5,18,.72);border:1px solid var(--line);border-radius:8px;padding:12px;min-height:150px}.globalLogsStatus{color:var(--muted);overflow-wrap:anywhere}.globalLogsToggle{cursor:pointer;font-family:inherit;border-color:rgba(34,197,94,.65);background:var(--green);color:#07120a;box-shadow:0 10px 22px rgba(34,197,94,.22)} .seasonPanel[hidden],.globalLogsPanel[hidden]{display:none!important}.routerEffectsDock{position:relative;display:block;width:132px;min-width:132px}.routerEffectsToggle{cursor:pointer;font-family:inherit}.routerEffectsToggle[aria-expanded="true"]{border-color:var(--line);background:rgba(255,255,255,.11);box-shadow:inset 0 1px 0 rgba(255,255,255,.08)}.seasonPanel{position:absolute;top:calc(100% + 10px);left:0;z-index:56;width:min(320px,calc(100vw - 24px))}.seasonCard{display:grid;gap:8px;width:100%;padding:12px;border:1px solid rgba(251,191,36,.18);border-radius:18px;background:linear-gradient(180deg,rgba(255,255,255,.08),rgba(255,255,255,.035)),rgba(19,14,32,.95);box-shadow:0 18px 42px rgba(0,0,0,.22),inset 0 1px 0 rgba(255,255,255,.06);backdrop-filter:blur(12px)}.seasonLabel{display:flex;align-items:center;justify-content:center;text-align:center;gap:8px;color:#fde68a;font-size:11px;font-weight:900;line-height:1.1;text-transform:uppercase;letter-spacing:.04em}.seasonCard .seasonSwitch{grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}.seasonCard .hubDesignSection{margin-top:16px;padding-top:14px;border-top:1px solid var(--line)}.seasonCard .hubDesignChoices{display:grid;grid-template-columns:1fr;gap:7px;margin-top:8px}.seasonCard .hubDesignChoice{display:flex;align-items:center;gap:10px;width:100%;min-width:0;min-height:0;padding:9px;text-align:left;border:1px solid var(--line);border-radius:10px;background:var(--panel2);color:var(--text);font:inherit;white-space:normal}.seasonCard .hubDesignChoice>span:last-child{min-width:0;flex:1}.seasonCard .hubDesignChoice strong,.seasonCard .hubDesignChoice small{display:block;line-height:1.4;overflow-wrap:anywhere}.seasonCard .hubDesignChoice strong{font-size:12px}.seasonCard .hubDesignChoice small{margin-top:2px;font-size:10px;font-weight:500;color:var(--muted)}.seasonCard .hubDesignChoice[aria-pressed="true"]{border-color:var(--cyan);background:color-mix(in srgb,var(--cyan) 12%,var(--panel))}.seasonCard .hubDesignSwatch{display:grid;place-items:center;flex:0 0 32px;width:32px;height:32px;border:1px solid var(--line);border-radius:8px;font-size:22px}.seasonCard .hubDesignHint{margin:10px 0 0;color:var(--muted);font-size:10px;line-height:1.6;overflow-wrap:anywhere}.globalLogsPanel{margin-top:16px}.globalLogsPanel .actions{justify-content:flex-start;margin:0 0 12px}.globalLogsText{margin:12px 0 0;max-height:55vh;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace;background:rgba(8,5,18,.72);border:1px solid var(--line);border-radius:8px;padding:12px;min-height:150px}.globalLogsStatus{color:var(--muted);overflow-wrap:anywhere}.globalLogsToggle{cursor:pointer;font-family:inherit;border-color:rgba(34,197,94,.65);background:var(--green);color:#07120a;box-shadow:0 10px 22px rgba(34,197,94,.22)}
.globalLogsNote{margin:0 0 12px;padding:10px 12px;border:1px solid rgba(245,158,11,.35);border-left:3px solid var(--amber);border-radius:8px;background:rgba(245,158,11,.10);color:#fde68a;font-size:12px;line-height:1.5;overflow-wrap:anywhere} .globalLogsNote{margin:0 0 12px;padding:10px 12px;border:1px solid rgba(245,158,11,.35);border-left:3px solid var(--amber);border-radius:8px;background:rgba(245,158,11,.10);color:#fde68a;font-size:12px;line-height:1.5;overflow-wrap:anywhere}
.globalLogsLegend{display:flex;gap:8px 14px;flex-wrap:wrap;margin:0 0 12px;font-size:12px;font-weight:700}.globalLogLine{display:block}.globalLogOk{color:#86efac}.globalLogWarn{color:#fde68a}.globalLogError{color:#f87171} .globalLogsLegend{display:flex;gap:8px 14px;flex-wrap:wrap;margin:0 0 12px;font-size:12px;font-weight:700}.globalLogLine{display:block}.globalLogOk{color:#86efac}.globalLogWarn{color:#fde68a}.globalLogError{color:#f87171}
@media(max-width:820px){.grid,.formgrid,.metrics{grid-template-columns:1fr}.linkMetric{grid-column:span 1}.metricLine{align-items:center;justify-content:center}.miniGo{width:auto;justify-content:center;display:inline-flex}.hero{align-items:flex-start;flex-direction:column}.topActions{justify-content:flex-start;padding-top:0}.wrap{padding:14px}h1{font-size:24px}.appBanner{width:auto;max-width:100%;justify-content:center;min-height:36px;padding:8px 12px}.panelHead{align-items:stretch;flex-direction:column}.headActionForm .btn{width:100%}.actions .btn,.actions button{width:100%}} @media(max-width:820px){.grid,.formgrid,.metrics{grid-template-columns:1fr}.linkMetric{grid-column:span 1}.metricLine{align-items:center;justify-content:center}.miniGo{width:auto;justify-content:center;display:inline-flex}.hero{align-items:flex-start;flex-direction:column}.topActions{justify-content:flex-start;padding-top:0}.wrap{padding:14px}h1{font-size:24px}.appBanner{width:auto;max-width:100%;justify-content:center;min-height:36px;padding:8px 12px}.panelHead{align-items:stretch;flex-direction:column}.headActionForm .btn{width:100%}.actions .btn,.actions button{width:100%}}
@media(max-width:820px){.brandPanel{grid-template-columns:repeat(2,minmax(0,1fr));width:100%}.brandPanel .appBanner{width:100%}} @media(max-width:820px){.brandPanel{grid-template-columns:repeat(2,minmax(0,1fr));width:100%}.brandPanel .appBanner{width:100%}}
@media(max-width:820px){.hero{gap:10px}.hero .brand{width:100%;min-width:0}.hero .uiPill,.hero .appBanner{width:100%;min-width:0;min-height:44px}.hero .appBanner{line-height:1.2}.topActions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:8px}.vpnCard,.returnCard{width:100%;min-width:0}.returnCard{grid-column:1/-1}.backBtn{white-space:normal;text-align:center}} @media(max-width:820px){.hero{gap:10px}.hero .brand{width:100%;min-width:0}.hero .uiPill,.hero .appBanner{width:100%;min-width:0;min-height:44px}.hero .appBanner{line-height:1.2}.topActions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:8px}.vpnCard,.returnCard{width:100%;min-width:0}.returnCard{grid-column:1/-1}.backBtn{white-space:normal;text-align:center}}
.seasonalFx{position:fixed;inset:0;display:block;width:100vw;height:100vh;z-index:1;pointer-events:none;opacity:.9;mix-blend-mode:screen}.seasonalFx[hidden]{display:none!important}
html[data-hub-shared-effects="1"] body::before,html[data-hub-shared-effects="1"] body::after{display:none!important}html[data-hub-shared-effects="1"] body>*:not(.seasonalFx){position:relative;z-index:2}
.hubAppearancePanel{margin-top:16px}.hubAppearancePanel h2{margin-bottom:8px}.appearanceHint{margin:10px 0 0;color:var(--muted);font-size:12px;line-height:1.5}.appearanceBlock{margin-top:12px;padding-top:12px;border-top:1px solid var(--line)}.appearanceBlock:first-of-type{margin-top:0;padding-top:0;border-top:0}.appearanceTitle{display:block;margin-bottom:8px;color:var(--muted);font-size:12px;font-weight:800;text-align:center}.seasonSwitch{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.seasonBtn,.hubDesignChoice{min-width:0;min-height:34px;padding:7px 8px;border:1px solid var(--line);border-radius:8px;background:rgba(255,255,255,.06);color:var(--text);font:700 11px/1.2 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;cursor:pointer}.seasonBtn[data-active="true"],.hubDesignChoice[aria-pressed="true"]{border-color:var(--cyan);background:rgba(34,211,238,.15);color:#ecfeff}.seasonBtn:disabled{opacity:.42;cursor:default}.hubDesignChoices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.hubDesignChoice{display:grid;gap:4px;min-height:58px;text-align:left}.hubDesignChoice strong,.hubDesignChoice small{display:block;overflow-wrap:anywhere}.hubDesignChoice strong{font-size:11px}.hubDesignChoice small{color:var(--muted);font-size:9px;font-weight:500}.hubDesignSwatch{display:inline-grid;place-items:center;width:24px;height:24px;border:1px solid var(--line);border-radius:6px;font-size:16px}.hubDesignSwatch.default{background:linear-gradient(135deg,#4c1d95,#1e1b4b)}.hubDesignSwatch.winter{color:#e0faff;background:linear-gradient(135deg,#0e7490,#172554)}.hubDesignSwatch.lite{color:#cbd5e1;background:#1e293b}
:root[data-hub-design="winter"]{--bg:#061426;--panel:#0c2238;--panel2:#16324b;--text:#ecf9ff;--muted:#a9c9dd;--line:rgba(139,211,236,.3);--blue:#036b99;--cyan:#7dd3fc;--teal:#38bdf8;--grid:rgba(125,211,252,.07)}html[data-hub-design="winter"] body{background-color:var(--bg);background-image:radial-gradient(ellipse at 10% 0%,#164d6e 0,transparent 45%),radial-gradient(ellipse at 100% 100%,#123c54 0,transparent 50%),linear-gradient(160deg,#061426,#0b2238 60%,#071524);background-size:100% 100%;animation:none}html[data-hub-design="winter"] body::before{inset:0;opacity:.55;filter:none;animation:none;background-image:radial-gradient(circle at 16px 22px,#c9f3ff 1px,transparent 2px),radial-gradient(circle at 80px 100px,#b2e7f7 1px,transparent 2px);background-size:180px 180px,260px 260px}html[data-hub-design="winter"] .panel{background:linear-gradient(160deg,rgba(180,231,250,.09),transparent 55%),var(--panel);backdrop-filter:none;box-shadow:0 8px 24px #0003}html[data-hub-design="winter"] :is(.metric,.code,.notice,.wanPicker,.globalLogsText,.seasonCard){background:var(--panel);border-color:var(--line)}
:root[data-hub-design="lite"]{--bg:#0f172a;--panel:#182235;--panel2:#253247;--text:#f1f5f9;--muted:#bac7d8;--line:#42516a;--blue:#315b9b;--cyan:#93c5fd}html[data-hub-design="lite"] body{background:var(--bg)!important;background-image:none!important}html[data-hub-design="lite"] *,html[data-hub-design="lite"] *::before,html[data-hub-design="lite"] *::after{animation:none!important;transition:none!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;filter:none!important;box-shadow:none!important;text-shadow:none!important}html[data-hub-design="lite"] body::before,html[data-hub-design="lite"] body::after,html[data-hub-design="lite"] .seasonalFx{display:none!important}html[data-hub-design="lite"] :is(.panel,.metric,.code,.notice,.wanPicker,.globalLogsText,.seasonCard){background:var(--panel)!important;border-color:var(--line)!important}html[data-hub-design="lite"] :is(.btn,.seasonBtn,.hubDesignChoice){background:rgba(255,255,255,.07)!important;color:var(--text)!important;border-color:var(--line)!important}
@media(max-width:820px){.routerEffectsDock{width:100%;min-width:0}.seasonPanel{position:static;width:100%;margin-top:8px}.seasonCard{width:100%;min-height:0;padding:10px 11px;border-radius:16px}.seasonCard .seasonSwitch{grid-template-columns:repeat(3,minmax(0,1fr))}.seasonCard .hubDesignChoice{min-height:54px}.seasonCard .hubDesignChoice strong{font-size:12px}.seasonCard .hubDesignChoice small{font-size:10px}}
</style> </style>
</head> </head>
<body> <body>
<canvas class="seasonalFx" id="seasonalFx" aria-hidden="true" hidden></canvas>
<main class="wrap"> <main class="wrap">
<section class="hero"> <section class="hero">
<div class="brand"> <div class="brand">
@@ -565,6 +579,34 @@ form{margin:0}.formgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr
<span>NetHaven VPN</span> <span>NetHaven VPN</span>
</a> </a>
</div> </div>
<div class="routerEffectsDock" id="routerEffectsDock">
<button class="uiPill routerEffectsToggle" id="routerEffectsToggle" type="button" aria-expanded="false" aria-controls="routerEffectsPanel" data-open="false">Эффекты</button>
<section class="seasonPanel" id="routerEffectsPanel" aria-label="Эффекты Hub" hidden>
<div class="seasonCard">
<div class="seasonLabel">Эффекты Hub</div>
<div class="seasonSwitch" role="group" aria-label="Выбор эффектов">
<button class="seasonBtn" type="button" data-season-mode="off" data-active="true" aria-pressed="true">Выкл</button>
<button class="seasonBtn" type="button" data-season-mode="snow" data-active="false" aria-pressed="false">Снег</button>
<button class="seasonBtn" type="button" data-season-mode="rain" data-active="false" aria-pressed="false">Дождь</button>
<button class="seasonBtn" type="button" data-season-mode="cosmos" data-active="false" aria-pressed="false">Космос</button>
<button class="seasonBtn" type="button" data-season-mode="embers" data-active="false" aria-pressed="false">Искры</button>
<button class="seasonBtn" type="button" data-season-mode="orbit" data-active="false" aria-pressed="false">Орбиты</button>
<button class="seasonBtn" type="button" data-season-mode="prism" data-active="false" aria-pressed="false">Призма</button>
<button class="seasonBtn" type="button" data-season-mode="pulse" data-active="false" aria-pressed="false">Пульс</button>
<button class="seasonBtn" type="button" data-season-mode="laser" data-active="false" aria-pressed="false">Лучи</button>
</div>
<div class="hubDesignSection">
<div class="seasonLabel">Дизайн</div>
<div class="hubDesignChoices" role="group" aria-label="Дизайн панели">
<button type="button" class="hubDesignChoice" data-hub-design="default" aria-pressed="true"><span class="hubDesignSwatch default" aria-hidden="true"></span><span><strong>Обычный</strong><small>Привычный вид Hub</small></span></button>
<button type="button" class="hubDesignChoice" data-hub-design="winter" aria-pressed="false"><span class="hubDesignSwatch winter" aria-hidden="true">❄</span><span><strong>Зимний</strong><small>Ледяные оттенки и снежные детали</small></span></button>
<button type="button" class="hubDesignChoice" data-hub-design="lite" aria-pressed="false"><span class="hubDesignSwatch lite" aria-hidden="true">☰</span><span><strong>Для слабых устройств</strong><small>Без анимации, размытия и свечения</small></span></button>
</div>
<p class="hubDesignHint" data-hub-design-hint role="status">Выбор сохраняется в этом браузере.</p>
</div>
</div>
</section>
</div>
<button class="uiPill globalLogsToggle" id="globalLogsToggle" type="button" aria-expanded="false" aria-controls="globalLogsPanel">Глобал логи</button> <button class="uiPill globalLogsToggle" id="globalLogsToggle" type="button" aria-expanded="false" aria-controls="globalLogsPanel">Глобал логи</button>
<div class="returnCard"> <div class="returnCard">
<a class="uiPill backBtn" href="/cgi-bin/luci/">Вернуться в службы OpenWrt</a> <a class="uiPill backBtn" href="/cgi-bin/luci/">Вернуться в службы OpenWrt</a>
@@ -689,8 +731,11 @@ EOF
</form> </form>
</section> </section>
</main> </main>
<script src="/luci-static/resources/owrt_remote_effects.js"></script>
<script> <script>
(function() { (function() {
var effectsPanel = document.getElementById('routerEffectsPanel');
var effectsToggle = document.getElementById('routerEffectsToggle');
var panel = document.getElementById('globalLogsPanel'); var panel = document.getElementById('globalLogsPanel');
var toggle = document.getElementById('globalLogsToggle'); var toggle = document.getElementById('globalLogsToggle');
var close = document.getElementById('globalLogsClose'); var close = document.getElementById('globalLogsClose');
@@ -700,6 +745,27 @@ EOF
var status = document.getElementById('globalLogsStatus'); var status = document.getElementById('globalLogsStatus');
var timer = null, controller = null, generation = 0, running = false; var timer = null, controller = null, generation = 0, running = false;
var renderedText = null; var renderedText = null;
function setEffectsOpen(open) {
if (!effectsPanel || !effectsToggle) return;
effectsPanel.hidden = !open;
effectsToggle.dataset.open = open ? 'true' : 'false';
effectsToggle.dataset.active = open ? 'true' : 'false';
effectsToggle.setAttribute('aria-expanded', open ? 'true' : 'false');
}
if (effectsToggle) effectsToggle.addEventListener('click', function(event) {
event.stopPropagation();
setEffectsOpen(!!effectsPanel && effectsPanel.hidden);
});
if (effectsPanel) effectsPanel.addEventListener('click', function(event) { event.stopPropagation(); });
document.addEventListener('click', function(event) {
if (effectsPanel && effectsToggle && !effectsPanel.hidden && !effectsPanel.contains(event.target) && !effectsToggle.contains(event.target)) setEffectsOpen(false);
});
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape' && effectsPanel && !effectsPanel.hidden) {
setEffectsOpen(false);
effectsToggle.focus();
}
});
function lineTone(line) { function lineTone(line) {
if (/^\[ERROR\]/.test(line)) return 'globalLogError'; if (/^\[ERROR\]/.test(line)) return 'globalLogError';
if (/^\[WARN\]/.test(line)) return 'globalLogWarn'; if (/^\[WARN\]/.test(line)) return 'globalLogWarn';
@@ -0,0 +1,986 @@
/* Shared Hub effects and design for the OpenWrt router panel. */
let seasonalFxCanvas = null;
let seasonButtons = [];
let seasonSwitches = [];
let hubDesignInitialized = false;
let seasonEffectsInitialized = false;
let hubAppearanceInitialized = false;
const SEASON_EFFECT_KEY = 'owrtRemote:seasonEffectMode';
const SEASON_EFFECT_MODES = new Set(['off', 'snow', 'rain', 'cosmos', 'embers', 'orbit', 'prism', 'pulse', 'laser']);
const HUB_DESIGN_KEY = 'owrtRemote:hubDesign';
const HUB_DESIGN_MODES = new Set(['default', 'winter', 'lite']);
let hubDesignMode = document.documentElement.dataset.hubDesign || 'default';
let seasonEffectMode = 'off';
let seasonalFxCtx = null;
let seasonalFxFrame = 0;
let seasonalFxResizeTimer = 0;
let seasonalFxLastTs = 0;
let seasonalFxParticles = [];
let seasonalFxSize = {width: 0, height: 0, dpr: 1};
let seasonalFxPointer = {x: 0, y: 0, lastX: 0, lastY: 0, targetWind: 0, wind: 0, lastMoveTs: 0, active: false};
function setHubDesign(nextMode, options = {}) {
hubDesignMode = HUB_DESIGN_MODES.has(nextMode) ? nextMode : 'default';
document.documentElement.dataset.hubDesign = hubDesignMode;
if (options.persist !== false) {
try { localStorage.setItem(HUB_DESIGN_KEY, hubDesignMode); } catch (error) {}
}
document.querySelectorAll('button[data-hub-design]').forEach(button => {
button.setAttribute('aria-pressed', String(button.dataset.hubDesign === hubDesignMode));
});
document.querySelectorAll('[data-hub-design-hint]').forEach(hint => {
hint.textContent = hubDesignMode === 'lite'
? 'Эффекты отключены. Статистика VPS — раз в 5 с, роутеры — раз в 10 с. Выбор сохранён в этом браузере.'
: hubDesignMode === 'winter'
? 'Зимние цвета и снежные детали. Падающий снег можно включить отдельно выше. Выбор сохранён в этом браузере.'
: 'Обычный дизайн Hub. Выбор сохранён в этом браузере.';
});
syncSeasonButtons();
if (hubDesignMode === 'lite') {
seasonFxStop();
seasonalFxParticles = [];
if (seasonalFxCanvas) {
seasonalFxCanvas.hidden = true;
seasonalFxCanvas.width = 1;
seasonalFxCanvas.height = 1;
}
} else {
setSeasonEffectMode(seasonEffectMode, {persist: false});
}
window.dispatchEvent(new Event('hubdesignchange'));
}
function initHubDesign() {
if (hubDesignInitialized) return;
hubDesignInitialized = true;
document.querySelectorAll('button[data-hub-design]').forEach(button => {
button.addEventListener('click', () => setHubDesign(button.dataset.hubDesign));
});
window.addEventListener('storage', event => {
if (event.key === HUB_DESIGN_KEY || event.key === null) {
let mode = 'default';
try { mode = localStorage.getItem(HUB_DESIGN_KEY); } catch (error) {}
setHubDesign(mode, {persist: false});
}
if (event.key === SEASON_EFFECT_KEY || event.key === null) {
setSeasonEffectMode(loadSeasonEffectMode(), {persist: false});
}
});
let savedMode = hubDesignMode;
try { savedMode = localStorage.getItem(HUB_DESIGN_KEY) || savedMode; } catch (error) {}
setHubDesign(savedMode, {persist: false});
}
function loadSeasonEffectMode() {
try {
const value = localStorage.getItem(SEASON_EFFECT_KEY);
return SEASON_EFFECT_MODES.has(value) ? value : 'off';
} catch (e) {
return 'off';
}
}
function saveSeasonEffectMode(mode) {
try {
localStorage.setItem(SEASON_EFFECT_KEY, mode);
} catch (e) {}
}
function syncSeasonButtons() {
seasonButtons.forEach((button) => {
const active = button.dataset.seasonMode === (hubDesignMode === 'lite' ? 'off' : seasonEffectMode);
button.disabled = hubDesignMode === 'lite' && button.dataset.seasonMode !== 'off';
button.dataset.active = active ? 'true' : 'false';
button.setAttribute('aria-pressed', active ? 'true' : 'false');
});
}
function seasonFxResetCanvas() {
if (!seasonalFxCanvas || hubDesignMode === 'lite' || document.hidden) return;
seasonalFxCtx = seasonalFxCanvas.getContext('2d');
if (!seasonalFxCtx) return;
const rect = seasonalFxCanvas.getBoundingClientRect();
const dpr = Math.min(window.devicePixelRatio || 1, 2);
const width = Math.max(1, Math.round(rect.width || window.innerWidth || 1));
const height = Math.max(1, Math.round(rect.height || window.innerHeight || 1));
seasonalFxCanvas.width = Math.max(1, Math.round(width * dpr));
seasonalFxCanvas.height = Math.max(1, Math.round(height * dpr));
seasonalFxCtx.setTransform(dpr, 0, 0, dpr, 0, 0);
seasonalFxSize = {width, height, dpr};
if (!seasonalFxPointer.active) {
seasonalFxPointer.x = width * .5;
seasonalFxPointer.y = height * .44;
seasonalFxPointer.lastX = seasonalFxPointer.x;
seasonalFxPointer.lastY = seasonalFxPointer.y;
}
}
function seasonFxSpawn(mode, randomY = false) {
const width = seasonalFxSize.width || window.innerWidth || 1;
const height = seasonalFxSize.height || window.innerHeight || 1;
if (mode === 'snow') {
return {
x: Math.random() * width,
y: randomY ? Math.random() * height : -Math.random() * height,
r: .8 + Math.random() * 1.1,
vy: .014 + Math.random() * .022,
vx: (Math.random() - .5) * .02,
drift: Math.random() * Math.PI * 2,
driftSpeed: .00045 + Math.random() * .0009,
alpha: .52 + Math.random() * .26
};
}
if (mode === 'cosmos') {
const angle = Math.random() * Math.PI * 2;
const distance = 20 + Math.random() * Math.max(width, height) * .28;
const speed = .10 + Math.random() * .18;
return {
x: width * .5 + Math.cos(angle) * distance,
y: height * .5 + Math.sin(angle) * distance,
vx: Math.cos(angle) * speed,
vy: Math.sin(angle) * speed,
size: .7 + Math.random() * 1.8,
tail: 10 + Math.random() * 18,
twinkle: Math.random() * Math.PI * 2,
twinkleSpeed: .006 + Math.random() * .01,
alpha: .45 + Math.random() * .42
};
}
if (mode === 'embers') {
return {
x: Math.random() * width,
y: randomY ? Math.random() * height : height + Math.random() * height * .18,
vx: (Math.random() - .5) * .045,
vy: -(.022 + Math.random() * .05),
size: 1.1 + Math.random() * 2.4,
hue: 18 + Math.random() * 26,
alpha: .22 + Math.random() * .26,
sway: Math.random() * Math.PI * 2,
swaySpeed: .0015 + Math.random() * .0024
};
}
if (mode === 'orbit') {
const centerX = width * .5;
const centerY = height * .42;
return {
angle: Math.random() * Math.PI * 2,
radius: 20 + Math.random() * Math.min(width, height) * .22,
radiusSwing: 6 + Math.random() * 16,
radiusDrift: Math.random() * Math.PI * 2,
radiusSpeed: .0014 + Math.random() * .0022,
speed: (Math.random() > .5 ? 1 : -1) * (.0012 + Math.random() * .0024),
size: .9 + Math.random() * 2.2,
alpha: .22 + Math.random() * .34,
hue: 182 + Math.random() * 110,
lane: .72 + Math.random() * .7,
x: centerX,
y: centerY
};
}
if (mode === 'prism') {
return {
x: Math.random() * width,
y: randomY ? Math.random() * height : (Math.random() * height * .2),
vx: (Math.random() - .5) * .075,
vy: (Math.random() - .5) * .075,
size: 3.8 + Math.random() * 8.8,
rot: Math.random() * Math.PI * 2,
rotSpeed: (Math.random() - .5) * .006,
hue: Math.random() * 360,
alpha: .26 + Math.random() * .28
};
}
if (mode === 'pulse') {
return {
angle: Math.random() * Math.PI * 2,
radius: Math.random() * 26,
radiusSpeed: .035 + Math.random() * .065,
orbit: Math.random() * Math.PI * 2,
orbitSpeed: (Math.random() - .5) * .0034,
size: 4 + Math.random() * 16,
hue: 182 + Math.random() * 150,
alpha: .18 + Math.random() * .26,
phase: Math.random() * Math.PI * 2,
phaseSpeed: .003 + Math.random() * .0045
};
}
if (mode === 'laser') {
const side = Math.random() > .5 ? 1 : -1;
return {
x: side > 0 ? -40 - Math.random() * width * .18 : width + 40 + Math.random() * width * .18,
y: Math.random() * height,
vx: side > 0 ? (.24 + Math.random() * .26) : -(.24 + Math.random() * .26),
vy: (Math.random() - .5) * .065,
len: 20 + Math.random() * 42,
width: .8 + Math.random() * 1.5,
hue: 190 + Math.random() * 140,
alpha: .16 + Math.random() * .26,
pulse: Math.random() * Math.PI * 2,
pulseSpeed: .003 + Math.random() * .004
};
}
if (mode === 'aurora') {
return {
x: Math.random() * width,
y: height * (.08 + Math.random() * .34),
phase: Math.random() * Math.PI * 2,
phaseSpeed: .0008 + Math.random() * .0016,
wave: 24 + Math.random() * 88,
waveSpeed: .0002 + Math.random() * .0005,
sway: Math.random() * Math.PI * 2,
swaySpeed: .0004 + Math.random() * .001,
thickness: 10 + Math.random() * 18,
hue: 155 + Math.random() * 70,
alpha: .12 + Math.random() * .14,
vx: (Math.random() - .5) * .02,
vy: (Math.random() - .5) * .01
};
}
if (mode === 'matrix') {
const columns = Math.max(2, Math.floor(width / 16));
const column = Math.floor(Math.random() * columns);
const columnWidth = width / columns;
return {
x: column * columnWidth + columnWidth * .5,
y: randomY ? Math.random() * height : -Math.random() * height,
vy: 4.6 + Math.random() * 6.8,
size: 11 + Math.random() * 9,
alpha: .38 + Math.random() * .42,
glyph: seasonFxRandomGlyph(),
glyphSpeed: .003 + Math.random() * .006,
trail: 18 + Math.random() * 30,
trailAlpha: .06 + Math.random() * .08,
hue: 120 + Math.random() * 40
};
}
if (mode === 'nebula') {
const angle = Math.random() * Math.PI * 2;
const distance = Math.random() * Math.min(width, height) * .34;
return {
x: width * .5 + Math.cos(angle) * distance,
y: height * .5 + Math.sin(angle) * distance * .72,
vx: (Math.random() - .5) * .075,
vy: (Math.random() - .5) * .065,
size: 70 + Math.random() * 130,
hue: 225 + Math.random() * 90,
alpha: .06 + Math.random() * .08,
drift: Math.random() * Math.PI * 2,
driftSpeed: .0003 + Math.random() * .0008,
pulse: Math.random() * Math.PI * 2
};
}
if (mode === 'fireworks') {
const fromLeft = Math.random() > .5;
const startX = fromLeft ? -60 - Math.random() * width * .2 : width + 60 + Math.random() * width * .2;
const startY = Math.random() * height * .82;
const speed = 1.8 + Math.random() * 3.4;
const angle = fromLeft ? (-.26 + Math.random() * .38) : (Math.PI - .26 + Math.random() * .38);
return {
x: startX,
y: startY,
vx: Math.cos(angle) * speed,
vy: Math.sin(angle) * speed,
gravity: .022 + Math.random() * .028,
drag: .985 + Math.random() * .009,
life: .4 + Math.random() * 1.2,
size: 1.1 + Math.random() * 2.4,
hue: Math.random() * 360,
alpha: .34 + Math.random() * .42,
sparkle: Math.random() * Math.PI * 2,
sparkleSpeed: .03 + Math.random() * .06,
trail: 8 + Math.random() * 18
};
}
if (mode === 'vortex') {
const angle = Math.random() * Math.PI * 2;
return {
x: width * .5,
y: height * .5,
angle,
radius: 18 + Math.random() * Math.min(width, height) * .42,
radiusSpeed: .012 + Math.random() * .018,
spin: (Math.random() > .5 ? 1 : -1) * (.002 + Math.random() * .0035),
wobble: Math.random() * Math.PI * 2,
wobbleSpeed: .002 + Math.random() * .004,
lane: .38 + Math.random() * .76,
size: 1.2 + Math.random() * 3.4,
hue: 190 + Math.random() * 130,
alpha: .22 + Math.random() * .28
};
}
if (mode === 'comet') {
const fromLeft = Math.random() > .5;
const startX = fromLeft ? -60 - Math.random() * width * .2 : width + 60 + Math.random() * width * .2;
const startY = Math.random() * height * .82;
const speed = 1.5 + Math.random() * 2.6;
const angle = fromLeft ? (-.25 + Math.random() * .35) : (Math.PI - .25 + Math.random() * .35);
return {
x: startX,
y: startY,
vx: Math.cos(angle) * speed,
vy: Math.sin(angle) * speed,
len: 44 + Math.random() * 88,
width: 1 + Math.random() * 2.8,
hue: 190 + Math.random() * 120,
alpha: .2 + Math.random() * .24,
wobble: Math.random() * Math.PI * 2,
wobbleSpeed: .006 + Math.random() * .01
};
}
return {
x: Math.random() * width,
y: randomY ? Math.random() * height : -Math.random() * height,
len: 8 + Math.random() * 10,
vy: .12 + Math.random() * .12,
vx: -(0.028 + Math.random() * .055),
width: .55 + Math.random() * .55,
alpha: .14 + Math.random() * .16
};
}
function seasonFxRandomGlyph() {
const glyphs = '01<>[]{}#@*+=%$';
return glyphs[Math.floor(Math.random() * glyphs.length)];
}
function seasonFxParticleCountForMode(mode, area, width, height) {
if (mode === 'snow') return Math.min(560, Math.max(180, Math.round(area / 2100)));
if (mode === 'cosmos') return Math.min(420, Math.max(160, Math.round(area / 2600)));
if (mode === 'embers') return Math.min(280, Math.max(90, Math.round(area / 6200)));
if (mode === 'orbit') return Math.min(160, Math.max(54, Math.round(area / 10800)));
if (mode === 'prism') return Math.min(240, Math.max(84, Math.round(area / 7200)));
if (mode === 'pulse') return Math.min(110, Math.max(36, Math.round(area / 16000)));
if (mode === 'laser') return Math.min(180, Math.max(68, Math.round(area / 9200)));
if (mode === 'aurora') return Math.min(12, Math.max(6, Math.round(width / 180)));
if (mode === 'matrix') return Math.min(96, Math.max(54, Math.round(width / 18)));
if (mode === 'nebula') return Math.min(24, Math.max(14, Math.round(area / 120000)));
if (mode === 'fireworks') return Math.min(220, Math.max(120, Math.round(area / 5200)));
if (mode === 'vortex') return Math.min(180, Math.max(80, Math.round(area / 9000)));
if (mode === 'comet') return Math.min(150, Math.max(54, Math.round(area / 11000)));
return Math.min(360, Math.max(140, Math.round(area / 3200)));
}
function seasonFxBuildParticles() {
if (seasonEffectMode === 'off') {
seasonalFxParticles = [];
return;
}
const width = seasonalFxSize.width || window.innerWidth || 1;
const height = seasonalFxSize.height || window.innerHeight || 1;
const area = Math.max(1, width * height);
const count = seasonFxParticleCountForMode(seasonEffectMode, area, width, height);
seasonalFxParticles = Array.from({length: count}, () => seasonFxSpawn(seasonEffectMode, true));
}
function seasonFxStop() {
if (seasonalFxFrame) {
cancelAnimationFrame(seasonalFxFrame);
seasonalFxFrame = 0;
}
seasonalFxLastTs = 0;
seasonalFxPointer.targetWind = 0;
seasonalFxPointer.wind = 0;
if (seasonalFxCtx && seasonalFxCanvas) {
seasonalFxCtx.clearRect(0, 0, seasonalFxSize.width, seasonalFxSize.height);
}
}
function seasonFxHandlePointerMove(ev) {
if (!seasonalFxCanvas || hubDesignMode === 'lite' || document.hidden || seasonEffectMode === 'off') return;
const width = seasonalFxSize.width || window.innerWidth || 1;
const height = seasonalFxSize.height || window.innerHeight || 1;
const x = Math.max(0, Math.min(width, Number(ev.clientX) || 0));
const y = Math.max(0, Math.min(height, Number(ev.clientY) || 0));
const deltaX = seasonalFxPointer.lastMoveTs ? (x - seasonalFxPointer.lastX) : 0;
const centerBias = ((x / width) - .5) * .03;
const motionBias = Math.max(-.05, Math.min(.05, deltaX * .0016));
seasonalFxPointer.x = x;
seasonalFxPointer.y = y;
seasonalFxPointer.lastX = x;
seasonalFxPointer.lastY = y;
seasonalFxPointer.lastMoveTs = Date.now();
seasonalFxPointer.active = true;
seasonalFxPointer.targetWind = centerBias + motionBias;
}
function seasonFxHandlePointerLeave() {
seasonalFxPointer.active = false;
seasonalFxPointer.targetWind = 0;
}
function seasonFxStep(ts) {
if (!seasonalFxCanvas || !seasonalFxCtx || seasonEffectMode === 'off' || hubDesignMode === 'lite' || document.hidden) {
seasonalFxFrame = 0;
return;
}
if (!seasonalFxLastTs) seasonalFxLastTs = ts;
const dt = Math.min(40, Math.max(1, ts - seasonalFxLastTs));
seasonalFxLastTs = ts;
const {width, height} = seasonalFxSize;
if (!seasonalFxPointer.active || (Date.now() - seasonalFxPointer.lastMoveTs) > 160) {
seasonalFxPointer.targetWind *= .92;
if (Math.abs(seasonalFxPointer.targetWind) < .0008) seasonalFxPointer.targetWind = 0;
}
seasonalFxPointer.wind += (seasonalFxPointer.targetWind - seasonalFxPointer.wind) * Math.min(.18, dt / 140);
seasonalFxCtx.clearRect(0, 0, width, height);
seasonalFxCtx.globalCompositeOperation = 'source-over';
seasonalFxCtx.shadowBlur = 0;
seasonalFxCtx.shadowColor = 'rgba(0,0,0,0)';
if (seasonEffectMode === 'snow') {
seasonalFxCtx.fillStyle = 'rgba(255,255,255,.8)';
for (const p of seasonalFxParticles) {
p.drift += p.driftSpeed * dt;
p.y += p.vy * dt;
p.x += (p.vx + seasonalFxPointer.wind * (.75 + p.r * .22)) * dt + Math.sin(p.drift) * .013 * dt;
if (p.y > height + 14) {
Object.assign(p, seasonFxSpawn('snow'));
p.y = -12 - Math.random() * 40;
}
if (p.x < -20) p.x = width + 20;
if (p.x > width + 20) p.x = -20;
seasonalFxCtx.beginPath();
seasonalFxCtx.fillStyle = `rgba(255,255,255,${p.alpha})`;
seasonalFxCtx.arc(p.x, p.y, p.r, 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'rain') {
seasonalFxCtx.lineCap = 'round';
for (const p of seasonalFxParticles) {
p.y += p.vy * dt;
const rainWind = seasonalFxPointer.wind * .42;
p.x += (p.vx + rainWind) * dt;
if (p.y > height + p.len + 20) {
Object.assign(p, seasonFxSpawn('rain'));
p.y = -20 - Math.random() * height * .2;
}
if (p.x < -40) p.x = width + 40;
if (p.x > width + 40) p.x = -40;
seasonalFxCtx.strokeStyle = `rgba(191,229,255,${p.alpha})`;
seasonalFxCtx.lineWidth = p.width;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(p.x, p.y);
seasonalFxCtx.lineTo(p.x + (p.vx + rainWind * .7) * 18, p.y + p.len);
seasonalFxCtx.stroke();
}
} else if (seasonEffectMode === 'cosmos') {
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
seasonalFxCtx.fillStyle = 'rgba(255,255,255,.9)';
const centerX = width * .5;
const centerY = height * .5;
for (const p of seasonalFxParticles) {
p.twinkle += p.twinkleSpeed * dt;
const driftX = seasonalFxPointer.wind * (18 + p.size * 6);
const driftY = Math.sin(p.twinkle) * .15;
p.x += (p.vx + driftX) * dt;
p.y += (p.vy + driftY) * dt;
const dx = p.x - centerX;
const dy = p.y - centerY;
const dist = Math.hypot(dx, dy);
if (dist > Math.max(width, height) * .8) {
Object.assign(p, seasonFxSpawn('cosmos'));
}
const alpha = Math.max(.12, Math.min(.95, p.alpha + Math.sin(p.twinkle) * .12));
seasonalFxCtx.strokeStyle = `rgba(171,205,255,${alpha * .34})`;
seasonalFxCtx.lineWidth = Math.max(.4, p.size * .55);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(p.x, p.y);
seasonalFxCtx.lineTo(p.x - (p.vx * p.tail + seasonalFxPointer.wind * 4), p.y - (p.vy * p.tail));
seasonalFxCtx.stroke();
seasonalFxCtx.beginPath();
seasonalFxCtx.fillStyle = `rgba(255,255,255,${alpha})`;
seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'embers') {
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const focusX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
const focusY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .74;
const influenceRadius = Math.min(width, height) * .34 + 70;
for (const p of seasonalFxParticles) {
const prevX = p.x;
const prevY = p.y;
p.sway += p.swaySpeed * dt;
if (seasonalFxPointer.active) {
const dx = focusX - p.x;
const dy = focusY - p.y;
const dist = Math.max(1, Math.hypot(dx, dy));
const pull = Math.max(0, 1 - dist / influenceRadius);
p.vx += ((dx / dist) * pull * .0058 + seasonalFxPointer.wind * .04) * dt;
p.vy += ((dy / dist) * pull * .0041 - .0002) * dt;
} else {
p.vx += seasonalFxPointer.wind * .015 * dt;
p.vy -= .00038 * dt;
}
p.vx *= .988;
p.vy *= .988;
p.x += (p.vx + Math.sin(p.sway) * .018) * dt;
p.y += p.vy * dt;
if (p.y < -34 || p.x < -80 || p.x > width + 80 || p.y > height + 80) {
Object.assign(p, seasonFxSpawn('embers'));
p.y = height + Math.random() * 30;
p.x = seasonalFxPointer.active ? focusX + (Math.random() - .5) * 120 : Math.random() * width;
}
const glow = seasonalFxPointer.active
? Math.max(0, 1 - Math.hypot(focusX - p.x, focusY - p.y) / 150)
: 0;
const alpha = Math.min(.96, p.alpha + glow * .4 + Math.abs(Math.sin(p.sway)) * .08);
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,72%,${alpha * .56})`;
seasonalFxCtx.lineWidth = Math.max(.7, p.size * .58);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
seasonalFxCtx.fillStyle = `hsla(${p.hue + 8},100%,66%,${alpha})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'orbit') {
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const centerX = (seasonalFxPointer.active ? seasonalFxPointer.x : width * .5) + seasonalFxPointer.wind * width * .06;
const centerY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .42;
const core = seasonalFxCtx.createRadialGradient(centerX, centerY, 0, centerX, centerY, Math.min(width, height) * .16);
core.addColorStop(0, 'rgba(34,211,238,.14)');
core.addColorStop(.45, 'rgba(168,85,247,.08)');
core.addColorStop(1, 'rgba(15,23,42,0)');
seasonalFxCtx.fillStyle = core;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(centerX, centerY, Math.min(width, height) * .16, 0, Math.PI * 2);
seasonalFxCtx.fill();
for (const p of seasonalFxParticles) {
const prevX = p.x || centerX;
const prevY = p.y || centerY;
p.radiusDrift += p.radiusSpeed * dt;
p.angle += p.speed * dt * (1 + Math.min(.8, Math.abs(seasonalFxPointer.wind) * 10));
const radius = p.radius + Math.sin(p.radiusDrift) * p.radiusSwing;
p.x = centerX + Math.cos(p.angle) * radius;
p.y = centerY + Math.sin(p.angle * p.lane) * radius * (.42 + p.lane * .22);
const alpha = Math.max(.14, Math.min(.92, p.alpha + Math.sin(p.radiusDrift) * .1));
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,72%,${alpha * .42})`;
seasonalFxCtx.lineWidth = Math.max(.6, p.size * .52);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
if (p.size > 1.7) {
seasonalFxCtx.strokeStyle = `hsla(${p.hue + 18},100%,74%,${alpha * .18})`;
seasonalFxCtx.lineWidth = .55;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(centerX, centerY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
}
seasonalFxCtx.fillStyle = `hsla(${p.hue + 12},100%,76%,${alpha})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'prism') {
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const focusX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
const focusY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .46;
const pullRadius = Math.min(width, height) * .38 + 90;
for (const p of seasonalFxParticles) {
const prevX = p.x;
const prevY = p.y;
p.rot += p.rotSpeed * dt;
if (seasonalFxPointer.active) {
const dx = focusX - p.x;
const dy = focusY - p.y;
const dist = Math.max(1, Math.hypot(dx, dy));
const pull = Math.max(0, 1 - dist / pullRadius);
p.vx += ((dx / dist) * pull * .0052 + seasonalFxPointer.wind * .022) * dt;
p.vy += ((dy / dist) * pull * .0044) * dt;
} else {
p.vx += seasonalFxPointer.wind * .01 * dt;
p.vy += Math.sin(p.rot) * .0009 * dt;
}
p.vx *= .992;
p.vy *= .992;
p.x += p.vx * dt;
p.y += p.vy * dt;
if (p.x < -90 || p.x > width + 90 || p.y < -90 || p.y > height + 90) {
Object.assign(p, seasonFxSpawn('prism', true));
if (seasonalFxPointer.active) {
p.x = focusX + (Math.random() - .5) * 140;
p.y = focusY + (Math.random() - .5) * 140;
}
}
const alpha = Math.min(.96, p.alpha + Math.abs(Math.sin(p.rot * 1.6)) * .16);
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,76%,${alpha * .34})`;
seasonalFxCtx.lineWidth = Math.max(.7, p.size * .16);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
seasonalFxCtx.save();
seasonalFxCtx.translate(p.x, p.y);
seasonalFxCtx.rotate(p.rot);
seasonalFxCtx.fillStyle = `hsla(${p.hue},100%,64%,${alpha})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(0, -p.size);
seasonalFxCtx.lineTo(p.size * .8, 0);
seasonalFxCtx.lineTo(0, p.size);
seasonalFxCtx.lineTo(-p.size * .8, 0);
seasonalFxCtx.closePath();
seasonalFxCtx.fill();
seasonalFxCtx.restore();
}
} else if (seasonEffectMode === 'pulse') {
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const centerX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
const centerY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .48;
const maxRadius = Math.min(width, height) * .34 + 50;
for (const p of seasonalFxParticles) {
p.phase += p.phaseSpeed * dt;
p.orbit += p.orbitSpeed * dt * (1 + Math.min(1.2, Math.abs(seasonalFxPointer.wind) * 12));
p.radius += p.radiusSpeed * dt;
if (p.radius > maxRadius) {
Object.assign(p, seasonFxSpawn('pulse', true));
p.radius = Math.random() * 18;
}
const offsetX = Math.cos(p.orbit) * p.radius;
const offsetY = Math.sin(p.orbit * 1.18) * p.radius * .7;
const x = centerX + offsetX;
const y = centerY + offsetY;
const life = 1 - Math.min(1, p.radius / maxRadius);
const pulse = .45 + .55 * Math.abs(Math.sin(p.phase));
const alpha = Math.max(.05, Math.min(.92, p.alpha * life + pulse * .08));
const ring = Math.max(2, p.size * (.45 + (1 - life) * 1.6));
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,74%,${alpha * .82})`;
seasonalFxCtx.lineWidth = Math.max(.7, 1.1 + (1 - life) * 2.2);
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(x, y, ring, 0, Math.PI * 2);
seasonalFxCtx.stroke();
seasonalFxCtx.fillStyle = `hsla(${p.hue + 24},100%,76%,${alpha * .72})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(x, y, Math.max(.8, ring * .18), 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'aurora') {
seasonalFxCtx.globalCompositeOperation = 'screen';
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const baseY = height * .16;
for (let i = 0; i < seasonalFxParticles.length; i++) {
const p = seasonalFxParticles[i];
p.phase += p.phaseSpeed * dt;
p.sway += p.swaySpeed * dt;
p.x += seasonalFxPointer.wind * dt * 36 + p.vx * dt * 10;
p.y += p.vy * dt * 10;
p.wave += p.waveSpeed * dt;
if (p.x < -160) p.x = width + 160;
if (p.x > width + 160) p.x = -160;
const amp = p.wave * (1 + Math.sin(p.sway) * .3);
const yBase = baseY + (i % 3) * height * .09 + Math.sin(p.phase * .7 + i * .42) * amp * .12;
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,70%,${p.alpha * .28})`;
seasonalFxCtx.lineWidth = p.thickness * 3.2;
seasonalFxCtx.beginPath();
for (let s = 0; s <= 16; s++) {
const x = width * s / 16;
const y = yBase + Math.sin(p.phase + s * .58 + p.sway) * amp + Math.cos(p.phase * .6 + s * .2) * amp * .18;
if (s === 0) seasonalFxCtx.moveTo(x, y);
else seasonalFxCtx.lineTo(x, y);
}
seasonalFxCtx.stroke();
seasonalFxCtx.strokeStyle = `hsla(${p.hue + 18},100%,82%,${p.alpha * .66})`;
seasonalFxCtx.lineWidth = Math.max(1, p.thickness * .52);
seasonalFxCtx.beginPath();
for (let s = 0; s <= 16; s++) {
const x = width * s / 16;
const y = yBase + Math.sin(p.phase + s * .58 + p.sway) * amp + Math.cos(p.phase * .6 + s * .2) * amp * .18;
if (s === 0) seasonalFxCtx.moveTo(x, y);
else seasonalFxCtx.lineTo(x, y);
}
seasonalFxCtx.stroke();
}
} else if (seasonEffectMode === 'matrix') {
seasonalFxCtx.globalCompositeOperation = 'lighter';
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.shadowColor = 'rgba(80,255,120,.55)';
seasonalFxCtx.shadowBlur = 10;
seasonalFxCtx.textAlign = 'center';
seasonalFxCtx.textBaseline = 'middle';
for (const p of seasonalFxParticles) {
if (Math.random() < .08) p.glyph = seasonFxRandomGlyph();
p.y += p.vy * dt;
p.x += seasonalFxPointer.wind * dt * 8;
if (p.y > height + p.trail) {
Object.assign(p, seasonFxSpawn('matrix'));
p.y = -Math.random() * height * .34;
}
if (p.x < -40) p.x = width + 40;
if (p.x > width + 40) p.x = -40;
seasonalFxCtx.fillStyle = `rgba(70,255,130,${p.trailAlpha})`;
seasonalFxCtx.fillRect(p.x - .8, p.y - p.trail, 1.6, p.trail + 6);
seasonalFxCtx.font = `900 ${Math.max(12, Math.round(p.size))}px ui-monospace, SFMono-Regular, Consolas, monospace`;
seasonalFxCtx.fillStyle = `rgba(170,255,190,${p.alpha})`;
seasonalFxCtx.fillText(p.glyph, p.x, p.y);
}
} else if (seasonEffectMode === 'nebula') {
seasonalFxCtx.globalCompositeOperation = 'screen';
for (const p of seasonalFxParticles) {
p.drift += p.driftSpeed * dt;
p.pulse += .0006 * dt;
p.x += (p.vx + seasonalFxPointer.wind * .024) * dt;
p.y += p.vy * dt;
if (p.x < -p.size) p.x = width + p.size;
if (p.x > width + p.size) p.x = -p.size;
if (p.y < -p.size) p.y = height + p.size;
if (p.y > height + p.size) p.y = -p.size;
const alpha = Math.min(.22, p.alpha + Math.sin(p.drift) * .03 + Math.abs(Math.sin(p.pulse)) * .02);
const glow = seasonalFxCtx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.size);
glow.addColorStop(0, `hsla(${p.hue},100%,72%,${alpha})`);
glow.addColorStop(.35, `hsla(${p.hue + 18},100%,60%,${alpha * .44})`);
glow.addColorStop(1, 'rgba(0,0,0,0)');
seasonalFxCtx.fillStyle = glow;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'fireworks') {
seasonalFxCtx.globalCompositeOperation = 'lighter';
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
for (const p of seasonalFxParticles) {
const prevX = p.x;
const prevY = p.y;
p.sparkle += p.sparkleSpeed * dt;
p.vx *= Math.pow(p.drag, dt / 16);
p.vy = p.vy * Math.pow(p.drag, dt / 16) + p.gravity * dt;
p.x += p.vx * dt;
p.y += p.vy * dt;
p.life -= dt / 1200;
if (p.life <= 0 || p.x < -80 || p.x > width + 80 || p.y > height + 120) {
Object.assign(p, seasonFxSpawn('fireworks'));
continue;
}
const spark = .5 + .5 * Math.sin(p.sparkle);
const alpha = Math.min(.96, p.alpha * Math.max(.2, p.life) + Math.abs(spark) * .18);
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,72%,${alpha * .84})`;
seasonalFxCtx.lineWidth = Math.max(.6, p.size * .6);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
seasonalFxCtx.strokeStyle = `hsla(${p.hue + 22},100%,86%,${alpha * .34})`;
seasonalFxCtx.lineWidth = Math.max(1.2, p.size * 2.8);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
seasonalFxCtx.fillStyle = `hsla(${p.hue + 14},100%,88%,${alpha})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(p.x, p.y, Math.max(.8, p.size * .95), 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'vortex') {
seasonalFxCtx.globalCompositeOperation = 'lighter';
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const centerX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
const centerY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .5;
for (const p of seasonalFxParticles) {
const prevX = p.x || centerX;
const prevY = p.y || centerY;
p.radius += p.radiusSpeed * dt;
p.angle += p.spin * dt * (1 + Math.min(1.4, Math.abs(seasonalFxPointer.wind) * 10));
p.wobble += p.wobbleSpeed * dt;
const radius = p.radius + Math.sin(p.wobble) * 20;
p.x = centerX + Math.cos(p.angle) * radius;
p.y = centerY + Math.sin(p.angle * p.lane) * radius * .84;
if (radius > Math.max(width, height) * .6) {
Object.assign(p, seasonFxSpawn('vortex'));
}
const alpha = Math.min(.92, p.alpha + Math.abs(Math.sin(p.wobble)) * .14);
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,72%,${alpha * .22})`;
seasonalFxCtx.lineWidth = Math.max(.7, p.size * .74);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
seasonalFxCtx.strokeStyle = `hsla(${p.hue + 22},100%,84%,${alpha * .14})`;
seasonalFxCtx.lineWidth = Math.max(1.4, p.size * 2.8);
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(centerX, centerY);
seasonalFxCtx.lineTo(p.x, p.y);
seasonalFxCtx.stroke();
seasonalFxCtx.fillStyle = `hsla(${p.hue + 12},100%,86%,${alpha})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(p.x, p.y, Math.max(.8, p.size), 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'comet') {
seasonalFxCtx.globalCompositeOperation = 'lighter';
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
for (const p of seasonalFxParticles) {
const prevX = p.x;
const prevY = p.y;
p.wobble += p.wobbleSpeed * dt;
p.x += (p.vx + seasonalFxPointer.wind * .03) * dt;
p.y += (p.vy + Math.sin(p.wobble) * .012) * dt;
if (p.x < -width * .4 || p.x > width * 1.4 || p.y < -120 || p.y > height + 120) {
Object.assign(p, seasonFxSpawn('comet'));
continue;
}
const tailX = p.x - p.vx * p.len * .62;
const tailY = p.y - p.vy * p.len * .62;
const alpha = Math.min(.95, p.alpha + Math.abs(Math.sin(p.wobble)) * .14);
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,72%,${alpha * .84})`;
seasonalFxCtx.lineWidth = p.width;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(p.x, p.y);
seasonalFxCtx.lineTo(tailX, tailY);
seasonalFxCtx.stroke();
seasonalFxCtx.strokeStyle = `hsla(${p.hue + 18},100%,86%,${alpha * .22})`;
seasonalFxCtx.lineWidth = p.width * 3.6;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(prevX, prevY);
seasonalFxCtx.lineTo(tailX, tailY);
seasonalFxCtx.stroke();
seasonalFxCtx.fillStyle = `hsla(${p.hue + 12},100%,88%,${alpha})`;
seasonalFxCtx.beginPath();
seasonalFxCtx.arc(p.x, p.y, Math.max(1, p.width * 1.2), 0, Math.PI * 2);
seasonalFxCtx.fill();
}
} else if (seasonEffectMode === 'laser') {
seasonalFxCtx.lineCap = 'round';
seasonalFxCtx.lineJoin = 'round';
const focusX = seasonalFxPointer.active ? seasonalFxPointer.x : width * .5;
const focusY = seasonalFxPointer.active ? seasonalFxPointer.y : height * .52;
const influence = Math.min(width, height) * .42 + 120;
for (const p of seasonalFxParticles) {
p.pulse += p.pulseSpeed * dt;
if (seasonalFxPointer.active) {
const dx = focusX - p.x;
const dy = focusY - p.y;
const dist = Math.max(1, Math.hypot(dx, dy));
const pull = Math.max(0, 1 - dist / influence);
p.vx += (dx / dist) * pull * .008 * dt;
p.vy += (dy / dist) * pull * .006 * dt;
} else {
p.vx += seasonalFxPointer.wind * .02 * dt;
}
p.vx *= .996;
p.vy *= .995;
p.x += p.vx * dt;
p.y += p.vy * dt;
if (p.x < -width * .35 || p.x > width * 1.35 || p.y < -120 || p.y > height + 120) {
Object.assign(p, seasonFxSpawn('laser', true));
}
const alpha = Math.min(.94, p.alpha + Math.abs(Math.sin(p.pulse)) * .18);
const tailX = p.x - p.vx * p.len * .55;
const tailY = p.y - p.vy * p.len * .55;
seasonalFxCtx.strokeStyle = `hsla(${p.hue},100%,72%,${alpha * .9})`;
seasonalFxCtx.lineWidth = p.width;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(p.x, p.y);
seasonalFxCtx.lineTo(tailX, tailY);
seasonalFxCtx.stroke();
seasonalFxCtx.strokeStyle = `hsla(${p.hue + 28},100%,86%,${alpha * .34})`;
seasonalFxCtx.lineWidth = p.width * 3.2;
seasonalFxCtx.beginPath();
seasonalFxCtx.moveTo(p.x, p.y);
seasonalFxCtx.lineTo(tailX, tailY);
seasonalFxCtx.stroke();
}
}
seasonalFxFrame = requestAnimationFrame(seasonFxStep);
}
function seasonFxStart() {
if (!seasonalFxCanvas || seasonEffectMode === 'off' || hubDesignMode === 'lite' || document.hidden) return;
seasonalFxCanvas.hidden = false;
seasonFxResetCanvas();
seasonFxBuildParticles();
seasonFxStop();
seasonalFxFrame = requestAnimationFrame(seasonFxStep);
}
function setSeasonEffectMode(nextMode, options = {}) {
const mode = SEASON_EFFECT_MODES.has(nextMode) ? nextMode : 'off';
seasonEffectMode = mode;
document.documentElement.dataset.seasonEffect = mode;
if (options.persist !== false) saveSeasonEffectMode(mode);
syncSeasonButtons();
if (!seasonalFxCanvas) return;
if (mode === 'off' || hubDesignMode === 'lite') {
seasonalFxCanvas.hidden = true;
seasonFxStop();
return;
}
seasonalFxCanvas.hidden = false;
seasonFxStart();
}
function initSeasonEffects() {
if (!seasonalFxCanvas || seasonEffectsInitialized) return;
seasonEffectsInitialized = true;
seasonSwitches.forEach((el) => {
const columns = Math.min(3, Math.max(2, el.querySelectorAll('[data-season-mode]').length));
el.style.gridTemplateColumns = `repeat(${columns},minmax(0,1fr))`;
});
window.addEventListener('resize', () => {
clearTimeout(seasonalFxResizeTimer);
seasonalFxResizeTimer = setTimeout(() => {
seasonalFxResizeTimer = 0;
if (seasonEffectMode === 'off' || hubDesignMode === 'lite' || document.hidden) return;
seasonFxResetCanvas();
seasonFxBuildParticles();
}, 120);
});
window.addEventListener('pointermove', seasonFxHandlePointerMove, {passive: true});
window.addEventListener('pointerleave', seasonFxHandlePointerLeave);
window.addEventListener('blur', seasonFxHandlePointerLeave);
document.addEventListener('visibilitychange', () => {
if (document.hidden) seasonFxStop();
else seasonFxStart();
});
window.addEventListener('pagehide', seasonFxStop);
window.addEventListener('pageshow', () => {
if (!seasonalFxFrame) seasonFxStart();
});
seasonEffectMode = loadSeasonEffectMode();
syncSeasonButtons();
setSeasonEffectMode(seasonEffectMode, {persist: false});
}
function initHubAppearance() {
if (hubAppearanceInitialized || !document.body) return;
hubAppearanceInitialized = true;
seasonalFxCanvas = document.getElementById('seasonalFx');
if (!seasonalFxCanvas) {
document.documentElement.dataset.hubSharedEffects = '1';
seasonalFxCanvas = document.createElement('canvas');
seasonalFxCanvas.id = 'seasonalFx';
seasonalFxCanvas.className = 'seasonalFx';
seasonalFxCanvas.width = seasonalFxCanvas.height = 1;
seasonalFxCanvas.hidden = true;
seasonalFxCanvas.setAttribute('aria-hidden', 'true');
document.body.prepend(seasonalFxCanvas);
}
seasonButtons = Array.from(document.querySelectorAll('[data-season-mode]'));
seasonSwitches = Array.from(document.querySelectorAll('.seasonSwitch'));
seasonButtons.forEach(button => button.addEventListener('click', () => {
setSeasonEffectMode(button.dataset.seasonMode || 'off');
}));
initHubDesign();
initSeasonEffects();
}
function bootHubAppearance() {
if (hubAppearanceInitialized) return;
// Wait for the parsed body so the dashboard's own canvas is reused. The
// interactive state precedes completion of deferred terminal libraries.
if (!document.body || document.readyState === 'loading') {
setTimeout(bootHubAppearance, 25);
return;
}
initHubAppearance();
}
bootHubAppearance();
+1
View File
@@ -228,6 +228,7 @@ install_file "etc/init.d/owrt-remote" 0755
install_file "etc/hotplug.d/iface/99-owrt-remote" 0755 install_file "etc/hotplug.d/iface/99-owrt-remote" 0755
install_config install_config
install_file "www/cgi-bin/owrt-remote" 0755 install_file "www/cgi-bin/owrt-remote" 0755
install_file "www/luci-static/resources/owrt_remote_effects.js" 0644
install_file "usr/share/luci/menu.d/luci-app-owrt-remote.json" 0644 install_file "usr/share/luci/menu.d/luci-app-owrt-remote.json" 0644
install_file "usr/share/rpcd/acl.d/luci-app-owrt-remote.json" 0644 install_file "usr/share/rpcd/acl.d/luci-app-owrt-remote.json" 0644
install_file "www/luci-static/resources/view/owrt_remote.js" 0644 install_file "www/luci-static/resources/view/owrt_remote.js" 0644
+61
View File
@@ -0,0 +1,61 @@
"""Static checks for the OpenWrt router effects/design panel."""
import os
from pathlib import Path
import shutil
import subprocess
import unittest
ROOT = Path(__file__).resolve().parents[1]
CGI = ROOT / 'files/www/cgi-bin/owrt-remote'
EFFECTS = ROOT / 'files/www/luci-static/resources/owrt_remote_effects.js'
DEPLOY = ROOT / 'vps/deploy-router-effects.ps1'
class RouterEffectsTests(unittest.TestCase):
def test_router_page_exposes_all_effects_and_designs(self):
page = CGI.read_text(encoding='utf-8')
for mode in ('off', 'snow', 'rain', 'cosmos', 'embers', 'orbit', 'prism', 'pulse', 'laser'):
self.assertIn(f'data-season-mode="{mode}"', page)
for mode in ('default', 'winter', 'lite'):
self.assertIn(f'data-hub-design="{mode}"', page)
self.assertIn('data-hub-shared-effects="1"', page)
self.assertIn('/luci-static/resources/owrt_remote_effects.js', page)
self.assertIn('id="routerEffectsToggle"', page)
self.assertIn('id="routerEffectsPanel" aria-label="Эффекты Hub" hidden', page)
self.assertIn('class="routerEffectsDock"', page)
self.assertIn('function setEffectsOpen(open)', page)
self.assertIn('.seasonCard .hubDesignChoices{display:grid;grid-template-columns:1fr;', page)
def test_shared_runtime_has_cursor_and_lite_controls(self):
runtime = EFFECTS.read_text(encoding='utf-8')
for marker in ('function initHubAppearance()', 'function seasonFxHandlePointerMove(',
"const SEASON_EFFECT_MODES", "const HUB_DESIGN_MODES",
"localStorage.getItem(HUB_DESIGN_KEY)"):
self.assertIn(marker, runtime)
self.assertGreater(len(runtime), 30000)
def test_fresh_install_and_router_deploy_include_runtime(self):
install = (ROOT / 'install.sh').read_text(encoding='utf-8')
deploy = DEPLOY.read_text(encoding='utf-8')
self.assertIn('install_file "www/luci-static/resources/owrt_remote_effects.js" 0644', install)
self.assertIn('/www/luci-static/resources/owrt_remote_effects.js', deploy)
self.assertIn('ROUTER_EFFECTS_V120_', deploy)
self.assertIn('owrt-remote-backup-before-router-effects-v120', deploy)
def test_shell_and_javascript_parse(self):
sh = shutil.which('sh')
if not sh and os.name == 'nt':
candidate = Path(os.environ.get('ProgramFiles', 'C:/Program Files')) / 'Git/usr/bin/sh.exe'
sh = str(candidate) if candidate.exists() else None
if sh:
result = subprocess.run([sh, '-n', str(CGI)], capture_output=True, text=True, timeout=20)
self.assertEqual(result.returncode, 0, result.stderr)
node = shutil.which('node')
if node:
result = subprocess.run([node, '--check', str(EFFECTS)], capture_output=True, text=True, timeout=20)
self.assertEqual(result.returncode, 0, result.stderr)
if __name__ == '__main__':
unittest.main()
+123
View File
@@ -0,0 +1,123 @@
param(
[string]$Router = 'root@192.168.2.1',
[ValidateSet('Install', 'Rollback')][string]$Action = 'Install'
)
$ErrorActionPreference = 'Stop'
$RepoRoot = Split-Path -Parent $PSScriptRoot
$UploadName = 'owrt-router-effects-' + [guid]::NewGuid().ToString('N')
$StageRoot = Join-Path ([System.IO.Path]::GetTempPath()) $UploadName
$Utf8 = [System.Text.UTF8Encoding]::new($false)
$RemoteScript = @'
#!/bin/sh
set -eu
stage=/tmp/__UPLOAD_NAME__
cgi=/www/cgi-bin/owrt-remote
effects=/www/luci-static/resources/owrt_remote_effects.js
backup=/root/owrt-remote-backup-before-router-effects-v120
changed=0
restore_file() {
path="$1"
name="$2"
if [ -e "$backup/$name.absent" ]; then
rm -f "$path"
else
test -s "$backup/$name"
mkdir -p "$(dirname "$path")"
cp -p "$backup/$name" "$path.new"
mv -f "$path.new" "$path"
fi
}
cleanup() {
code=$?
trap - EXIT
if [ "$code" -ne 0 ] && [ "$changed" = 1 ] && [ -d "$backup" ]; then
restore_file "$cgi" cgi || true
restore_file "$effects" effects.js || true
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache 2>/dev/null || true
/etc/init.d/uhttpd reload >/dev/null 2>&1 || true
fi
rm -rf "$stage"
exit "$code"
}
trap cleanup EXIT INT TERM
if [ '__ACTION__' = Install ]; then
test -s "$stage/cgi"
test -s "$stage/effects.js"
sh -n "$stage/cgi"
grep -F -q 'id="routerEffectsPanel"' "$stage/cgi"
grep -F -q 'data-season-mode="prism"' "$stage/cgi"
grep -F -q 'data-hub-design="lite"' "$stage/cgi"
grep -F -q 'function initHubAppearance()' "$stage/effects.js"
grep -F -q 'function seasonFxHandlePointerMove(' "$stage/effects.js"
grep -F -q 'const HUB_DESIGN_MODES' "$stage/effects.js"
mkdir -p "$backup"
if [ ! -e "$backup/cgi" ] && [ ! -e "$backup/cgi.absent" ]; then
if [ -e "$cgi" ]; then cp -p "$cgi" "$backup/cgi"; else : >"$backup/cgi.absent"; fi
fi
if [ ! -e "$backup/effects.js" ] && [ ! -e "$backup/effects.js.absent" ]; then
if [ -e "$effects" ]; then cp -p "$effects" "$backup/effects.js"; else : >"$backup/effects.js.absent"; fi
fi
cp "$stage/cgi" "$cgi.new"
chmod 0755 "$cgi.new"
mv -f "$cgi.new" "$cgi"
cp "$stage/effects.js" "$effects.new"
chmod 0644 "$effects.new"
mv -f "$effects.new" "$effects"
else
test -d "$backup"
restore_file "$cgi" cgi
restore_file "$effects" effects.js
chmod 0755 "$cgi" 2>/dev/null || true
fi
changed=1
rm -rf /tmp/luci-indexcache /tmp/luci-modulecache 2>/dev/null || true
/etc/init.d/uhttpd reload >/dev/null 2>&1 || /etc/init.d/uhttpd restart >/dev/null 2>&1 || true
chmod 0755 "$cgi" 2>/dev/null || true
test -x "$cgi"
test -s "$effects"
if [ '__ACTION__' = Install ]; then
grep -F -q 'id="routerEffectsPanel"' "$cgi"
grep -F -q 'function initHubAppearance()' "$effects"
fi
printf '\nBackup: %s\nROUTER_EFFECTS_V120_%s_OK\n' "$backup" '__ACTION__'
'@
$RemoteScript = $RemoteScript.Replace('__UPLOAD_NAME__', $UploadName).Replace('__ACTION__', $Action)
try {
[System.IO.Directory]::CreateDirectory($StageRoot) | Out-Null
[System.IO.File]::WriteAllText(
(Join-Path $StageRoot 'run.sh'),
$RemoteScript.Replace("`r`n", "`n") + "`n",
$Utf8
)
if ($Action -eq 'Install') {
$cgi = [System.IO.File]::ReadAllText((Join-Path $RepoRoot 'files\www\cgi-bin\owrt-remote')).Replace("`r`n", "`n")
$effects = [System.IO.File]::ReadAllText((Join-Path $RepoRoot 'files\www\luci-static\resources\owrt_remote_effects.js')).Replace("`r`n", "`n")
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'cgi'), $cgi, $Utf8)
[System.IO.File]::WriteAllText((Join-Path $StageRoot 'effects.js'), $effects, $Utf8)
}
& scp -O -r -- $StageRoot "${Router}:/tmp/"
if ($LASTEXITCODE -ne 0) { throw 'Upload failed. Router was not changed.' }
& ssh -T -o ConnectTimeout=10 $Router "sh /tmp/$UploadName/run.sh"
if ($LASTEXITCODE -ne 0) { throw "$Action failed. See the output above; success was not confirmed." }
Write-Host "Router effects $Action finished successfully. Refresh the OpenWrt panel."
}
finally {
$Resolved = [System.IO.Path]::GetFullPath($StageRoot)
$Expected = [System.IO.Path]::GetFullPath((Join-Path ([System.IO.Path]::GetTempPath()) $UploadName))
if ($Resolved -ne $Expected -or (Split-Path -Leaf $Resolved) -ne $UploadName) {
throw 'Unsafe staging cleanup path.'
}
if (Test-Path -LiteralPath $Resolved) {
Remove-Item -LiteralPath $Resolved -Recurse -Force
}
}