Files
WarpBox/static/js/upload-popups.js
Daniel Legt 6035ea1eb2 feat(config): support *_MB env vars for upload size limits
- Add `applyMegabytesOrBytesEnv` to accept size settings in either bytes or MB
- Prefer `*_BYTES` when set, otherwise convert `*_MB` to bytes with overflow guard
- Add coverage for MB-based environment overrides
- Introduce `static/js/upload-popups.js` to lazy-load and cache popup templatesfeat(config): support *_MB env vars for upload size limits

- Add `applyMegabytesOrBytesEnv` to accept size settings in either bytes or MB
- Prefer `*_BYTES` when set, otherwise convert `*_MB` to bytes with overflow guard
- Add coverage for MB-based environment overrides
- Introduce `static/js/upload-popups.js` to lazy-load and cache popup templates
2026-04-29 01:42:41 +03:00

37 lines
1.3 KiB
JavaScript

window.WBPopups = (() => {
const cache = new Map();
const docs = {
cli: { title: "CLI Guide", template: "cli" },
faq: { title: "Help & FAQ", template: "faq" },
dailyQuota: { title: "Upload limits", template: "upload-limits" },
about: { title: "About WarpBox", template: "about", about: true },
examples: { title: "Examples", template: "examples" },
};
async function loadTemplate(name) {
if (cache.has(name)) return cache.get(name);
const response = await fetch(`/static/popups/${name}.html`, { credentials: "same-origin" });
if (!response.ok) throw new Error(`Could not load popup template: ${name}`);
const template = await response.text();
cache.set(name, template);
return template;
}
async function renderTemplate(name, data = {}) {
const template = await loadTemplate(name);
return window.WBUtils.renderTemplate(template, data);
}
async function renderDoc(name, data = {}) {
const doc = docs[name];
if (!doc) return null;
return {
title: doc.title,
about: Boolean(doc.about),
html: await renderTemplate(doc.template, data),
};
}
return { renderTemplate, renderDoc };
})();