Files
nextcloud_minimalprofile/js/minimalprofile.js
2026-04-16 15:05:53 +02:00

57 lines
1.5 KiB
JavaScript

/**
* Minimal Profile - Show fields based on config
*/
(function() {
'use strict';
var fieldSelectors = {
'pronouns': '#account-property-pronouns',
'role': '#account-property-role',
'headline': '#account-property-headline',
'biography': '#account-property-biography',
'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'
};
function showFields(hiddenFields) {
var allFields = Object.keys(fieldSelectors);
allFields.forEach(function(field) {
if (!hiddenFields.includes(field)) {
var selector = fieldSelectors[field];
var el = document.querySelector(selector);
if (el) {
var box = el.closest('.personal-settings-setting-box');
if (box) {
box.style.display = '';
}
}
}
});
}
function init() {
var req = new XMLHttpRequest();
req.onload = function() {
if (req.status === 200) {
try {
var data = JSON.parse(req.responseText);
showFields(data.hiddenFields || []);
} catch (e) {}
}
};
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
req.send();
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();