Files
nextcloud_minimalprofile/js/minimalprofile.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
console.log('MinimalProfile: Loading...');
var fieldSelectors = {
'pronouns': '#account-property-pronouns',
2026-04-16 15:46:23 +02:00
'role': '#account-property-role',
'headline': '#account-property-headline',
'biography': '#account-property-biography',
2026-04-16 15:46:23 +02:00
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'
};
2026-04-16 15:46:23 +02:00
function applyCss(hiddenFields) {
if (!hiddenFields || hiddenFields.length === 0) {
console.log('MinimalProfile: No hidden fields');
return;
}
2026-04-16 15:46:23 +02:00
var css = '';
hiddenFields.forEach(function(field) {
var selector = fieldSelectors[field];
if (selector) {
2026-04-16 15:46:23 +02:00
css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; } ';
console.log('MinimalProfile: Hiding', field);
}
2026-04-16 15:46:23 +02:00
});
2026-04-16 15:46:23 +02:00
if (css) {
var style = document.createElement('style');
style.id = 'minimalprofile-style';
style.textContent = css;
document.head.appendChild(style);
console.log('MinimalProfile: CSS applied');
}
}
2026-04-16 15:46:23 +02:00
function init() {
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);
}
}
2026-04-16 15:46:23 +02:00
};
req.onerror = function() {
console.error('MinimalProfile: Request failed');
};
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
req.send();
}
2026-04-16 15:46:23 +02:00
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();