Files
nextcloud_minimalprofile/js/minimalprofile.js

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-04-16 16:37:44 +02:00
/**
* MinimalProfile v41 - API-based config
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;
}
console.log('MinimalProfile v41: 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();
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();
2026-04-16 20:47:35 +02:00
}
loadConfig();
})();