From adcf3e62add90357b07603745b8ea5ffc9af0ab0 Mon Sep 17 00:00:00 2001 From: Guy Van Sanden Date: Thu, 16 Apr 2026 16:44:04 +0200 Subject: [PATCH] v1.0.29 - JS reads config, hides only configured --- appinfo/info.xml | 2 +- js/minimalprofile.js | 63 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index aa1b5c3..3547dc3 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.28 + 1.0.29 AGPL Your Name MinimalProfile diff --git a/js/minimalprofile.js b/js/minimalprofile.js index 706da64..99873f9 100644 --- a/js/minimalprofile.js +++ b/js/minimalprofile.js @@ -1,15 +1,60 @@ /** - * Minimal Profile - Test JS loading + * Minimal Profile - Load and hide configured fields */ (function() { 'use strict'; - console.log('MinimalProfile JS: START'); + console.log('MinimalProfile: START'); - // Load CSS directly - var link = document.createElement('link'); - link.rel = 'stylesheet'; - link.href = OC.linkTo('minimalprofile', 'css/minimalprofile.css'); - document.head.appendChild(link); - - console.log('MinimalProfile JS: CSS loaded from ' + link.href); + var fieldSelectors = { + 'pronouns': '#account-property-pronouns', + 'role': '#account-property-role', + 'headline': '#account-property-headline', + 'biography': '#account-property-biography', + 'organisation': '#account-property-organisation', + 'phone': '#account-property-phone', + 'address': '#account-property-address', + 'birthdate': '#account-property-birthdate', + 'website': '#account-property-website', + 'twitter': '#account-property-twitter', + 'fediverse': '#account-property-fediverse', + 'location': '#account-property-location' + }; + + function applyCss(hiddenFields) { + if (!hiddenFields || hiddenFields.length === 0) { + console.log('MinimalProfile: No fields to hide'); + return; + } + + var css = ''; + hiddenFields.forEach(function(field) { + var selector = fieldSelectors[field]; + if (selector) { + css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; }'; + console.log('MinimalProfile: Hiding ' + field); + } + }); + + if (css) { + var style = document.createElement('style'); + style.textContent = css; + document.head.appendChild(style); + console.log('MinimalProfile: CSS applied'); + } + } + + // Fetch config + var req = new XMLHttpRequest(); + req.onload = function() { + if (req.status === 200) { + try { + var data = JSON.parse(req.responseText); + applyCss(data.hiddenFields || []); + } catch (e) { + console.error('MinimalProfile: Parse error', e); + } + } + }; + req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields')); + req.send(); })(); \ No newline at end of file