Extract all magic numbers into share.config

Unified config file with [server] (user-facing: port, dir, ttl, lang,
etc.) and [internal] (constants: timeouts, buffer sizes, cert params,
UI timings). Replaces both DEFAULTS dict and hardcoded constants.
JS constants (toast_ms, progress_hide_ms) passed through CFG injection.
Old share.conf no longer used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 20:52:57 +04:00
co-authored by Claude Opus 4.6
parent 082a80a6c5
commit 9cc4693f39
3 changed files with 60 additions and 26 deletions
+4 -2
View File
@@ -194,6 +194,8 @@ const _cfg = typeof CFG !== 'undefined' ? CFG : {};
const defaultLang = _cfg.lang || 'ru';
const REFRESH_MS = (_cfg.refresh || 5) * 1000;
const PER_PAGE_OPTS = _cfg.perPage || [10, 25, 50, 100];
const TOAST_MS = _cfg.toastMs || 2500;
const PROGRESS_HIDE_MS = _cfg.progressHideMs || 1200;
/* ── i18n ── */
@@ -266,7 +268,7 @@ function toast(msg) {
toastEl.textContent = msg;
toastEl.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toastEl.classList.remove('show'), 2500);
toastTimer = setTimeout(() => toastEl.classList.remove('show'), TOAST_MS);
}
function fmtSize(b) {
@@ -371,7 +373,7 @@ function upload(fileList) {
xhr.onload = () => {
done();
pfill.style.width = '100%';
setTimeout(() => { $('progress').style.display = 'none'; pfill.style.width = '0' }, 1200);
setTimeout(() => { $('progress').style.display = 'none'; pfill.style.width = '0' }, PROGRESS_HIDE_MS);
if (xhr.status === 200) {
const r = JSON.parse(xhr.responseText);
toast(t().uploaded(r.count));