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:
+4
-2
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user