From e643db10df7c732345e1b4b01f9f1d619fafdbeb Mon Sep 17 00:00:00 2001 From: Guy Van Sanden Date: Thu, 16 Apr 2026 20:57:16 +0200 Subject: [PATCH] v1.0.45 - handle plain JSON response --- appinfo/info.xml | 2 +- js/minimalprofile.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index cf6bbaf..07c324b 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.44 + 1.0.45 AGPL Your Name MinimalProfile diff --git a/js/minimalprofile.js b/js/minimalprofile.js index 09e1fad..4407005 100644 --- a/js/minimalprofile.js +++ b/js/minimalprofile.js @@ -1,5 +1,5 @@ /** - * MinimalProfile v43 - Debug OCS response + * MinimalProfile v45 - Handle both OCS and plain JSON */ (function() { 'use strict'; @@ -8,7 +8,7 @@ return; } - console.log('MinimalProfile v43: Starting'); + console.log('MinimalProfile v45: Starting'); var map = { 'pronouns': '#account-property-pronouns', @@ -38,22 +38,22 @@ var xhr = new XMLHttpRequest(); xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true); xhr.onload = function() { - console.log('MinimalProfile v43: Response status', xhr.status, 'body:', xhr.responseText.substring(0, 200)); + console.log('MinimalProfile v45: Response', xhr.status, xhr.responseText); if (xhr.status === 200) { try { var data = JSON.parse(xhr.responseText); - var fields = data?.ocs?.data?.hiddenFields; - console.log('MinimalProfile v43: API returned', fields); + var fields = data?.ocs?.data?.hiddenFields || data?.hiddenFields; + console.log('MinimalProfile v45: Fields:', fields); hideFields(fields); } catch(e) { - console.error('MinimalProfile v43: JSON parse error', e); + console.error('MinimalProfile v45: Parse error', e); } } else { - console.error('MinimalProfile v43: API failed', xhr.status); + console.error('MinimalProfile v45: API failed', xhr.status); } }; xhr.onerror = function() { - console.error('MinimalProfile v43: Network error'); + console.error('MinimalProfile v45: Network error'); }; xhr.send(); }