Files
nextcloud_minimalprofile/js/minimalprofile.js

76 lines
2.5 KiB
JavaScript
Raw Normal View History

2026-04-16 16:37:44 +02:00
/**
2026-04-16 20:34:38 +02:00
* Minimal Profile - Only run on settings page
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
// Only run on settings page
if (!window.location.pathname.includes('/settings/')) {
console.log('MinimalProfile: Not on settings page, skipping');
return;
}
console.log('MinimalProfile: START - v1.0.32');
2026-04-16 16:37:44 +02:00
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 applyCss(hiddenFields) {
2026-04-16 18:37:54 +02:00
console.log('MinimalProfile: applyCss called with', hiddenFields);
if (!hiddenFields || hiddenFields.length === 0) {
console.log('MinimalProfile: No fields to hide');
return;
}
var css = '';
hiddenFields.forEach(function(field) {
var selector = fieldSelectors[field];
if (selector) {
css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; }';
console.log('MinimalProfile: Hiding ' + field);
}
});
if (css) {
var style = document.createElement('style');
style.textContent = css;
2026-04-16 18:37:54 +02:00
style.id = 'minimalprofile-dynamic';
document.head.appendChild(style);
2026-04-16 20:34:38 +02:00
console.log('MinimalProfile: CSS applied');
}
}
2026-04-16 18:37:54 +02:00
console.log('MinimalProfile: Fetching config...');
var req = new XMLHttpRequest();
2026-04-16 20:34:38 +02:00
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
req.onload = function() {
2026-04-16 20:34:38 +02:00
console.log('MinimalProfile: Status:', req.status);
if (req.status === 200) {
try {
var data = JSON.parse(req.responseText);
2026-04-16 20:34:38 +02:00
console.log('MinimalProfile: Data:', data);
applyCss(data.hiddenFields || []);
} catch (e) {
console.error('MinimalProfile: Parse error', e);
}
}
};
2026-04-16 18:37:54 +02:00
req.onerror = function() {
2026-04-16 20:34:38 +02:00
console.error('MinimalProfile: Request failed');
2026-04-16 18:37:54 +02:00
};
req.send();
})();