v1.0.19 - exact working version from f68dab2
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<name>Minimal Profile</name>
|
||||
<summary>Hides profile fields to create a minimal user profile</summary>
|
||||
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
||||
<version>1.0.18</version>
|
||||
<version>1.0.19</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Your Name</author>
|
||||
<namespace>MinimalProfile</namespace>
|
||||
@@ -14,7 +14,4 @@
|
||||
<dependencies>
|
||||
<nextcloud min-version="33" max-version="33"/>
|
||||
</dependencies>
|
||||
<scripts>
|
||||
<script>minimalprofile</script>
|
||||
</scripts>
|
||||
</info>
|
||||
@@ -1,2 +1,13 @@
|
||||
/* Test if CSS loads - blue border */
|
||||
#content { border: 5px solid blue !important; }
|
||||
/* Hide profile fields */
|
||||
.personal-settings-setting-box:has(#account-property-pronouns) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-role) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-headline) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-biography) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-organisation) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-phone) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-address) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-birthdate) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-website) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-twitter) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-fediverse) { display: none !important; }
|
||||
.personal-settings-setting-box:has(#account-property-location) { display: none !important; }
|
||||
@@ -17,63 +17,48 @@
|
||||
'location': '#account-property-location'
|
||||
};
|
||||
|
||||
function applyCss(hiddenFields) {
|
||||
console.log('MinimalProfile: Hidden fields:', hiddenFields);
|
||||
|
||||
function updateCss(hiddenFields) {
|
||||
if (!hiddenFields || hiddenFields.length === 0) {
|
||||
console.log('MinimalProfile: No hidden fields to apply');
|
||||
console.log('MinimalProfile: No hidden fields');
|
||||
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:', field);
|
||||
} else {
|
||||
console.log('MinimalProfile: Unknown field:', field);
|
||||
css += selector + ' { display: none !important; } ';
|
||||
console.log('MinimalProfile: Hiding', field, selector);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
if (css) {
|
||||
var style = document.createElement('style');
|
||||
style.id = 'minimalprofile-style';
|
||||
style.textContent = css;
|
||||
document.head.appendChild(style);
|
||||
console.log('MinimalProfile: CSS applied:', css);
|
||||
var style = document.createElement('style');
|
||||
style.id = 'minimalprofile-style';
|
||||
style.textContent = css;
|
||||
document.head.appendChild(style);
|
||||
console.log('MinimalProfile: CSS applied', css);
|
||||
}
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.onload = function() {
|
||||
console.log('MinimalProfile: Response status', req.status);
|
||||
if (req.status === 200) {
|
||||
try {
|
||||
var data = JSON.parse(req.responseText);
|
||||
console.log('MinimalProfile: Data', data);
|
||||
updateCss(data.hiddenFields);
|
||||
} catch (e) {
|
||||
console.error('MinimalProfile: Error', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
req.onerror = function() {
|
||||
console.error('MinimalProfile: Request failed');
|
||||
};
|
||||
req.open('GET', OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields'));
|
||||
req.send();
|
||||
|
||||
function init() {
|
||||
var url = OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields');
|
||||
console.log('MinimalProfile: Fetching:', url);
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open('GET', url);
|
||||
req.onload = function() {
|
||||
console.log('MinimalProfile: Response status:', req.status);
|
||||
if (req.status === 200) {
|
||||
try {
|
||||
var data = JSON.parse(req.responseText);
|
||||
console.log('MinimalProfile: Response data:', data);
|
||||
applyCss(data.hiddenFields || []);
|
||||
} catch (e) {
|
||||
console.error('MinimalProfile: Parse error', e);
|
||||
}
|
||||
} else {
|
||||
console.error('MinimalProfile: HTTP error:', req.status);
|
||||
}
|
||||
};
|
||||
req.onerror = function() {
|
||||
console.error('MinimalProfile: Request failed');
|
||||
};
|
||||
req.send();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
setTimeout(function() {
|
||||
var el = document.querySelector('#account-property-pronouns');
|
||||
console.log('MinimalProfile: Pronouns element found?', !!el);
|
||||
}, 3000);
|
||||
})();
|
||||
@@ -24,7 +24,6 @@ class Application extends App implements IBootstrap {
|
||||
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
||||
function() {
|
||||
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||
Util::addScript('minimalprofile', 'minimalprofile');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user