Initial commit: Minimal Profile app for Nextcloud 33
This commit is contained in:
53
js/minimalprofile.js
Normal file
53
js/minimalprofile.js
Normal file
@@ -0,0 +1,53 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var fieldSelectors = {
|
||||
'pronouns': 'input[id="account-property-pronouns"]',
|
||||
'role': 'input[id="account-property-role"]',
|
||||
'headline': 'input[id="account-property-headline"]',
|
||||
'biography': 'input[id="account-property-biography"]',
|
||||
'organisation': 'input[id="account-property-organisation"]',
|
||||
'phone': 'input[id="account-property-phone"]',
|
||||
'address': 'input[id="account-property-address"]',
|
||||
'birthdate': 'input[id="account-property-birthdate"]',
|
||||
'website': 'input[id="account-property-website"]',
|
||||
'twitter': 'input[id="account-property-twitter"]',
|
||||
'fediverse': 'input[id="account-property-fediverse"]',
|
||||
'location': 'input[id="account-property-location"]'
|
||||
};
|
||||
|
||||
function hideFields(hiddenFields) {
|
||||
hiddenFields.forEach(function(field) {
|
||||
var selector = fieldSelectors[field];
|
||||
if (selector) {
|
||||
var elements = document.querySelectorAll(selector);
|
||||
elements.forEach(function(el) {
|
||||
var parent = el.parentElement;
|
||||
while (parent && !parent.classList.contains('personal-settings-setting-box')) {
|
||||
parent = parent.parentElement;
|
||||
if (!parent) return;
|
||||
}
|
||||
if (parent && parent.classList.contains('personal-settings-setting-box')) {
|
||||
parent.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
OCP.registerLoadEndpoint(function() {
|
||||
var req = new XMLHttpRequest();
|
||||
req.onload = function() {
|
||||
if (req.status === 200) {
|
||||
try {
|
||||
var data = JSON.parse(req.responseText);
|
||||
if (data.hiddenFields && data.hiddenFields.length > 0) {
|
||||
hideFields(data.hiddenFields);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
};
|
||||
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
|
||||
req.send();
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user