Files
nextcloud_minimalprofile/js/minimalprofile.js

62 lines
1.9 KiB
JavaScript
Raw Normal View History

2026-04-16 16:37:44 +02:00
/**
2026-04-16 20:55:54 +02:00
* MinimalProfile v43 - Debug OCS response
2026-04-16 16:37:44 +02:00
*/
(function() {
2026-04-16 16:37:44 +02:00
'use strict';
2026-04-16 20:34:38 +02:00
if (!window.location.pathname.includes('/settings/')) {
return;
}
2026-04-16 20:55:54 +02:00
console.log('MinimalProfile v43: Starting');
2026-04-16 20:47:35 +02:00
var map = {
'pronouns': '#account-property-pronouns',
'role': '#account-property-role',
2026-04-16 20:47:35 +02:00
'headline': '#account-property-headline'
};
2026-04-16 18:37:54 +02:00
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);
}
}
2026-04-16 20:47:35 +02:00
function loadConfig() {
var xhr = new XMLHttpRequest();
2026-04-16 20:54:35 +02:00
xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true);
xhr.onload = function() {
2026-04-16 20:55:54 +02:00
console.log('MinimalProfile v43: Response status', xhr.status, 'body:', xhr.responseText.substring(0, 200));
if (xhr.status === 200) {
try {
var data = JSON.parse(xhr.responseText);
2026-04-16 20:55:54 +02:00
var fields = data?.ocs?.data?.hiddenFields;
console.log('MinimalProfile v43: API returned', fields);
hideFields(fields);
} catch(e) {
2026-04-16 20:55:54 +02:00
console.error('MinimalProfile v43: JSON parse error', e);
}
} else {
2026-04-16 20:55:54 +02:00
console.error('MinimalProfile v43: API failed', xhr.status);
}
};
xhr.onerror = function() {
2026-04-16 20:55:54 +02:00
console.error('MinimalProfile v43: Network error');
};
xhr.send();
2026-04-16 20:47:35 +02:00
}
loadConfig();
})();