From e887d4e046cd0bb0f0a2004c1b5d3eb135cbb401 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 8 May 2026 07:17:29 +0200 Subject: [PATCH] convert settings loaders to modules --- public/index.html | 4 ++-- public/js/documents.js | 3 --- public/js/nextcloud.js | 14 +++++++++++--- test/clinical-notes-entrypoints.test.js | 10 ++++++++++ test/module-entrypoints.test.js | 4 +++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/public/index.html b/public/index.html index ccb2ca4..4ac2e11 100644 --- a/public/index.html +++ b/public/index.html @@ -496,7 +496,7 @@ - + @@ -504,7 +504,7 @@ - + diff --git a/public/js/documents.js b/public/js/documents.js index 940c22f..dace72f 100644 --- a/public/js/documents.js +++ b/public/js/documents.js @@ -2,8 +2,6 @@ // DOCUMENTS.JS — S3 document upload & management UI // ============================================================ -(function() { - function loadDocuments() { var container = document.getElementById('documents-list'); if (!container) return; @@ -124,4 +122,3 @@ }); console.log('Documents module loaded'); -})(); diff --git a/public/js/nextcloud.js b/public/js/nextcloud.js index 1304245..4c5ef65 100644 --- a/public/js/nextcloud.js +++ b/public/js/nextcloud.js @@ -1,15 +1,24 @@ -(function() { var _inited = false; document.addEventListener('tabChanged', function(e) { if (e.detail.tab !== 'settings' || _inited) return; _inited = true; + function setNextcloudConnectedStatus(url, user) { + var statusEl = document.getElementById('nc-status'); + if (!statusEl) return; + statusEl.textContent = 'Connected to '; + var strong = document.createElement('strong'); + strong.textContent = url || ''; + statusEl.appendChild(strong); + statusEl.appendChild(document.createTextNode(' as ' + (user || ''))); + } + function loadNextcloudStatus() { fetch('/api/auth/me', { headers: getAuthHeaders() }) .then(function(r) { return r.json(); }) .then(function(data) { var pathSection = document.getElementById('nc-webdav-path-section'); if (data.user && data.user.nextcloud_url) { - document.getElementById('nc-status').innerHTML = '✅ Connected to ' + data.user.nextcloud_url + ' as ' + data.user.nextcloud_user; + setNextcloudConnectedStatus(data.user.nextcloud_url, data.user.nextcloud_user); document.getElementById('nc-url').value = data.user.nextcloud_url; document.getElementById('nc-user').value = data.user.nextcloud_user; document.getElementById('btn-nc-disconnect').classList.remove('hidden'); @@ -72,4 +81,3 @@ console.log('✅ Nextcloud module loaded'); }); -})(); diff --git a/test/clinical-notes-entrypoints.test.js b/test/clinical-notes-entrypoints.test.js index 6a20148..7dfa91a 100644 --- a/test/clinical-notes-entrypoints.test.js +++ b/test/clinical-notes-entrypoints.test.js @@ -137,3 +137,13 @@ test('chart review preserves pasted note coverage cues', () => { assert.match(prompts, /avoid copying whole notes/); assert.match(prompts, /Pending tests, labs, referrals, medication changes, or action items/); }); + +test('settings scripts expose loaders without rendering account values as HTML', () => { + const nextcloud = read('public/js/nextcloud.js'); + const documents = read('public/js/documents.js'); + assert.match(nextcloud, /window\.loadNextcloudStatus = loadNextcloudStatus/); + assert.match(documents, /window\.loadDocuments = loadDocuments/); + assert.match(nextcloud, /function setNextcloudConnectedStatus\(url, user\)/); + assert.match(nextcloud, /strong\.textContent = url \|\| ''/); + assert.doesNotMatch(nextcloud, /nc-status'\)\.innerHTML/); +}); diff --git a/test/module-entrypoints.test.js b/test/module-entrypoints.test.js index f4bef1c..83c10e5 100644 --- a/test/module-entrypoints.test.js +++ b/test/module-entrypoints.test.js @@ -12,10 +12,12 @@ const moduleEntrypoints = [ 'public/js/ed-encounters.js', 'public/js/hospitalCourse.js', 'public/js/milestones.js', + 'public/js/nextcloud.js', 'public/js/notes.js', 'public/js/sickVisit.js', 'public/js/soap.js', - 'public/js/wellVisit.js' + 'public/js/wellVisit.js', + 'public/js/documents.js' ]; const iifeFreeEntrypoints = [