refactor(js): avoid use of window.XXX and move to import/export

- change worker: do not cache html pages (not necessary)
- remove use of window.XXX and maximize import/export,
  this will provide more clarety,
  show circular dependencies + you will benefit IDE help
This commit is contained in:
Edouard Vanbelle
2026-04-13 15:09:10 +02:00
parent a2e5cfce24
commit 6f4abfcec4
42 changed files with 1104 additions and 1038 deletions
+7 -5
View File
@@ -1,3 +1,5 @@
import { i18n } from './i18n.js';
/**
* OxiCloud – Notification Bell Module
*
@@ -5,7 +7,7 @@
* in the top-bar. Upload progress, quota errors, and general messages all
* go through this module.
*
* Public API (on window.notifications):
* Public API (exported as `notifications`):
* addUploadBatch(totalFiles) → batchId
* updateFile(batchId, fileName, pct, status)
* finishBatch(batchId, successCount, totalFiles)
@@ -147,7 +149,7 @@ const notifications = (() => {
item.className = 'notif-item';
item.id = batchId;
const t = window.i18n?.t || ((k) => k);
const t = i18n?.t || ((k) => k);
const uploadingText = folderName ? `📁 ${t('upload.uploading')} ${_esc(folderName)}…` : t('upload.uploading');
const filesLabel = t('upload.files');
@@ -252,7 +254,7 @@ const notifications = (() => {
const pctEl = $(`${batchId}-pct`);
const statsEl = $(`${batchId}-stats`);
const t = window.i18n?.t || ((k) => k);
const t = i18n?.t || ((k) => k);
const filesLabel = t('upload.files');
if (fillEl) fillEl.style.width = `${pctVal}%`;
@@ -280,7 +282,7 @@ const notifications = (() => {
const curEl = $(`${batchId}-current`);
if (curEl) curEl.textContent = '';
const t = window.i18n?.t || ((k) => k);
const t = i18n?.t || ((k) => k);
const completeText = t('upload.complete', {
count: successCount,
total: totalFiles
@@ -351,4 +353,4 @@ const notifications = (() => {
};
})();
window.notifications = notifications;
export { notifications };