From 11118bbf8b2a02f8f06353e465dfe163977e4d3b Mon Sep 17 00:00:00 2001 From: Guy Van Sanden Date: Thu, 16 Apr 2026 20:51:06 +0200 Subject: [PATCH] v1.0.41 - fix routes.xml, use API for config --- appinfo/info.xml | 2 +- appinfo/routes.xml | 2 +- js/minimalprofile.js | 61 +++++++++++++++++++++++++++++--------------- 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index a18ccd9..e2be126 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -4,7 +4,7 @@ Minimal Profile Hides profile fields to create a minimal user profile Allows administrators to hide profile fields like pronouns, social links, etc. - 1.0.35 + 1.0.41 AGPL Your Name MinimalProfile diff --git a/appinfo/routes.xml b/appinfo/routes.xml index b06c95f..9fcfcf8 100644 --- a/appinfo/routes.xml +++ b/appinfo/routes.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/js/minimalprofile.js b/js/minimalprofile.js index 9e068a7..ea2f1f9 100644 --- a/js/minimalprofile.js +++ b/js/minimalprofile.js @@ -1,5 +1,5 @@ /** - * Minimal Profile v40 - NEW SCRIPT + * MinimalProfile v41 - API-based config */ (function() { 'use strict'; @@ -8,14 +8,7 @@ return; } - console.log('MinimalProfile v40: HERE'); - - var storageKey = 'minimalprofile_hidden'; - var stored = localStorage.getItem(storageKey); - var hidden = stored ? JSON.parse(stored) : []; - var urlParam = new URLSearchParams(window.location.search).get('hide'); - if (urlParam) hidden = urlParam.split(','); - if (!hidden.length) return; + console.log('MinimalProfile v41: Starting'); var map = { 'pronouns': '#account-property-pronouns', @@ -23,17 +16,45 @@ 'headline': '#account-property-headline' }; - var css = ''; - hidden.forEach(function(f) { - if (map[f]) { - css += '.personal-settings-setting-box:has(' + map[f] + ') { display: none !important; }'; - console.log('Hiding:', f); + function hideFields(hidden) { + if (!hidden || !hidden.length) return; + + var css = ''; + hidden.forEach(function(f) { + if (map[f]) { + css += '.personal-settings-setting-box:has(' + map[f] + ') { display: none !important; }'; + console.log('Hiding:', f); + } + }); + + if (css) { + var s = document.createElement('style'); + s.textContent = css; + document.head.appendChild(s); } - }); - - if (css) { - var s = document.createElement('style'); - s.textContent = css; - document.head.appendChild(s); } + + function loadConfig() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/apps/minimalprofile/api/v1/hidden-fields', true); + xhr.onload = function() { + if (xhr.status === 200) { + try { + var data = JSON.parse(xhr.responseText); + console.log('MinimalProfile v41: API returned', data.hiddenFields); + hideFields(data.hiddenFields); + } catch(e) { + console.error('MinimalProfile v41: JSON parse error', e); + } + } else { + console.error('MinimalProfile v41: API failed', xhr.status); + } + }; + xhr.onerror = function() { + console.error('MinimalProfile v41: Network error'); + }; + xhr.send(); + } + + loadConfig(); })(); \ No newline at end of file