v1.0.27 - JS loads CSS via OC.linkTo
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<name>Minimal Profile</name>
|
<name>Minimal Profile</name>
|
||||||
<summary>Hides profile fields to create a minimal user profile</summary>
|
<summary>Hides profile fields to create a minimal user profile</summary>
|
||||||
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
||||||
<version>1.0.10</version>
|
<version>1.0.27</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Your Name</author>
|
<author>Your Name</author>
|
||||||
<namespace>MinimalProfile</namespace>
|
<namespace>MinimalProfile</namespace>
|
||||||
@@ -14,4 +14,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<nextcloud min-version="33" max-version="33"/>
|
<nextcloud min-version="33" max-version="33"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<scripts>
|
||||||
|
<script>minimalprofile</script>
|
||||||
|
</scripts>
|
||||||
</info>
|
</info>
|
||||||
@@ -1,64 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Minimal Profile - Test JS loading
|
||||||
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
console.log('MinimalProfile: Loading...');
|
console.log('MinimalProfile JS: START');
|
||||||
|
|
||||||
var fieldSelectors = {
|
// Load CSS directly
|
||||||
'pronouns': '#account-property-pronouns',
|
var link = document.createElement('link');
|
||||||
'role': '#account-property-role',
|
link.rel = 'stylesheet';
|
||||||
'headline': '#account-property-headline',
|
link.href = OC.linkTo('minimalprofile', 'css/minimalprofile.css');
|
||||||
'biography': '#account-property-biography',
|
document.head.appendChild(link);
|
||||||
'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 updateCss(hiddenFields) {
|
console.log('MinimalProfile JS: CSS loaded from ' + link.href);
|
||||||
if (!hiddenFields || hiddenFields.length === 0) {
|
|
||||||
console.log('MinimalProfile: No hidden fields');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var css = '';
|
|
||||||
hiddenFields.forEach(function(field) {
|
|
||||||
var selector = fieldSelectors[field];
|
|
||||||
if (selector) {
|
|
||||||
css += selector + ' { display: none !important; } ';
|
|
||||||
console.log('MinimalProfile: Hiding', field, selector);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
setTimeout(function() {
|
|
||||||
var el = document.querySelector('#account-property-pronouns');
|
|
||||||
console.log('MinimalProfile: Pronouns element found?', !!el);
|
|
||||||
}, 3000);
|
|
||||||
})();
|
})();
|
||||||
Reference in New Issue
Block a user