From 018c65adc5413979bd6e8c2160f21d61a854520c Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 9 Sep 2026 10:06:49 +0300 Subject: [PATCH] refactor: move frontend JS to external files and enable strict CSP --- .gitignore | 3 + .../page-2026-09-09T05-41-29-429Z.yml | 6 - .../page-2026-09-09T05-43-31-505Z.yml | 6 - public/admin.html | 2 +- public/admin.js | 28 +- public/audit.html | 75 +--- public/branches.html | 116 +---- public/dashboard.html | 113 +---- public/error.html | 21 +- public/files.html | 168 +------ public/groups.html | 356 +-------------- public/index.html | 199 +-------- public/journal.html | 412 +----------------- public/js/audit.js | 71 +++ public/js/branches.js | 117 +++++ public/js/dashboard.js | 110 +++++ public/js/error.js | 16 + public/js/files.js | 169 +++++++ public/js/groups.js | 357 +++++++++++++++ public/js/index.js | 191 ++++++++ public/js/journal.js | 410 +++++++++++++++++ public/js/links.js | 151 +++++++ public/js/login.js | 20 + public/js/settings.js | 221 ++++++++++ public/js/share.js | 157 +++++++ public/js/students.js | 246 +++++++++++ public/js/trash.js | 97 +++++ public/links.html | 147 +------ public/login.html | 23 +- public/settings.html | 226 +--------- public/share.html | 156 +------ public/students.html | 250 +---------- public/trash.html | 94 +--- server.js | 17 +- 34 files changed, 2444 insertions(+), 2307 deletions(-) delete mode 100644 .playwright-mcp/page-2026-09-09T05-41-29-429Z.yml delete mode 100644 .playwright-mcp/page-2026-09-09T05-43-31-505Z.yml create mode 100644 public/js/audit.js create mode 100644 public/js/branches.js create mode 100644 public/js/dashboard.js create mode 100644 public/js/error.js create mode 100644 public/js/files.js create mode 100644 public/js/groups.js create mode 100644 public/js/index.js create mode 100644 public/js/journal.js create mode 100644 public/js/links.js create mode 100644 public/js/login.js create mode 100644 public/js/settings.js create mode 100644 public/js/share.js create mode 100644 public/js/students.js create mode 100644 public/js/trash.js diff --git a/.gitignore b/.gitignore index ce242a7..c6450e6 100644 --- a/.gitignore +++ b/.gitignore @@ -23,5 +23,8 @@ tmp/ .DS_Store Thumbs.db +# --- Playwright test artifacts --- +.playwright-mcp/ + # --- Internal audit (not for commit) --- SECURITY_AUDIT.md diff --git a/.playwright-mcp/page-2026-09-09T05-41-29-429Z.yml b/.playwright-mcp/page-2026-09-09T05-41-29-429Z.yml deleted file mode 100644 index 33a3d9f..0000000 --- a/.playwright-mcp/page-2026-09-09T05-41-29-429Z.yml +++ /dev/null @@ -1,6 +0,0 @@ -- generic [ref=f1e2]: - - heading "Админ-панель" [level=1] [ref=f1e3] - - textbox "Пароль" [ref=f1e4] - - button "Войти" [ref=f1e5] [cursor=pointer] - - link "На главную" [ref=f1e7] [cursor=pointer]: - - /url: / \ No newline at end of file diff --git a/.playwright-mcp/page-2026-09-09T05-43-31-505Z.yml b/.playwright-mcp/page-2026-09-09T05-43-31-505Z.yml deleted file mode 100644 index 8a5290f..0000000 --- a/.playwright-mcp/page-2026-09-09T05-43-31-505Z.yml +++ /dev/null @@ -1,6 +0,0 @@ -- generic [ref=f3e2]: - - heading "Админ-панель" [level=1] [ref=f3e3] - - textbox "Пароль" [active] [ref=f3e4] - - button "Войти" [ref=f3e5] [cursor=pointer] - - link "На главную" [ref=f3e7] [cursor=pointer]: - - /url: / \ No newline at end of file diff --git a/public/admin.html b/public/admin.html index b8320aa..31a5e3e 100644 --- a/public/admin.html +++ b/public/admin.html @@ -3,7 +3,7 @@ Админ-панель - + diff --git a/public/admin.js b/public/admin.js index 5e88d09..cd5c2b6 100644 --- a/public/admin.js +++ b/public/admin.js @@ -42,7 +42,7 @@ function buildSidebar(active) {
На главную - Выйти + Выйти
`; } @@ -137,14 +137,32 @@ function copyText(text) { function renderPager(el, page, totalPages, onPage) { if (!el) return; if (totalPages <= 1) { el.innerHTML = ''; return; } - let html = ``; + let html = ``; for (let i = 1; i <= totalPages; i++) { if (totalPages > 9 && i > 2 && i < totalPages - 1 && Math.abs(i - page) > 2) { if (i === 3) html += ``; continue; } - html += ``; + html += ``; } - html += ``; + html += ``; el.innerHTML = html; -} \ No newline at end of file + el._onPage = onPage; + el._page = page; + if (!el._bound) { + el._bound = true; + el.addEventListener('click', e => { + const btn = e.target.closest('button'); + if (!btn || btn.disabled) return; + const p = btn.dataset.page ? parseInt(btn.dataset.page, 10) : el._page + parseInt(btn.dataset.nav, 10); + if (el._onPage) el._onPage(p); + }); + } +} + +document.addEventListener('click', e => { + const imgEl = e.target.closest('[data-img]'); + if (imgEl) { e.preventDefault(); showImg(imgEl.dataset.img); return; } + const out = e.target.closest('[data-action="logout"]'); + if (out) { e.preventDefault(); doLogout(); } +}); \ No newline at end of file diff --git a/public/audit.html b/public/audit.html index 24ddd6d..036a769 100644 --- a/public/audit.html +++ b/public/audit.html @@ -17,7 +17,7 @@
- +
@@ -39,77 +39,6 @@
- + \ No newline at end of file diff --git a/public/branches.html b/public/branches.html index 4f31ed3..8d10ec2 100644 --- a/public/branches.html +++ b/public/branches.html @@ -16,7 +16,7 @@
-
@@ -28,7 +28,7 @@ - -