v1.0.45 - handle plain JSON response

This commit is contained in:
2026-04-16 20:57:16 +02:00
parent 9cd4d84a4a
commit e643db10df
2 changed files with 9 additions and 9 deletions

View File

@@ -4,7 +4,7 @@
<name>Minimal Profile</name> <name>Minimal Profile</name>
<summary>Hides profile fields to create a minimal user profile</summary> <summary>Hides profile fields to create a minimal user profile</summary>
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description> <description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
<version>1.0.44</version> <version>1.0.45</version>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Your Name</author> <author>Your Name</author>
<namespace>MinimalProfile</namespace> <namespace>MinimalProfile</namespace>

View File

@@ -1,5 +1,5 @@
/** /**
* MinimalProfile v43 - Debug OCS response * MinimalProfile v45 - Handle both OCS and plain JSON
*/ */
(function() { (function() {
'use strict'; 'use strict';
@@ -8,7 +8,7 @@
return; return;
} }
console.log('MinimalProfile v43: Starting'); console.log('MinimalProfile v45: Starting');
var map = { var map = {
'pronouns': '#account-property-pronouns', 'pronouns': '#account-property-pronouns',
@@ -38,22 +38,22 @@
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true); xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true);
xhr.onload = function() { 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) { if (xhr.status === 200) {
try { try {
var data = JSON.parse(xhr.responseText); var data = JSON.parse(xhr.responseText);
var fields = data?.ocs?.data?.hiddenFields; var fields = data?.ocs?.data?.hiddenFields || data?.hiddenFields;
console.log('MinimalProfile v43: API returned', fields); console.log('MinimalProfile v45: Fields:', fields);
hideFields(fields); hideFields(fields);
} catch(e) { } catch(e) {
console.error('MinimalProfile v43: JSON parse error', e); console.error('MinimalProfile v45: Parse error', e);
} }
} else { } else {
console.error('MinimalProfile v43: API failed', xhr.status); console.error('MinimalProfile v45: API failed', xhr.status);
} }
}; };
xhr.onerror = function() { xhr.onerror = function() {
console.error('MinimalProfile v43: Network error'); console.error('MinimalProfile v45: Network error');
}; };
xhr.send(); xhr.send();
} }