v1.0.19 - exact working version from f68dab2
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.18</version>
|
<version>1.0.19</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Your Name</author>
|
<author>Your Name</author>
|
||||||
<namespace>MinimalProfile</namespace>
|
<namespace>MinimalProfile</namespace>
|
||||||
@@ -14,7 +14,4 @@
|
|||||||
<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,2 +1,13 @@
|
|||||||
/* Test if CSS loads - blue border */
|
/* Hide profile fields */
|
||||||
#content { border: 5px solid blue !important; }
|
.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; }
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
var fieldSelectors = {
|
var fieldSelectors = {
|
||||||
'pronouns': '#account-property-pronouns',
|
'pronouns': '#account-property-pronouns',
|
||||||
'role': '#account-property-role',
|
'role': '#account-property-role',
|
||||||
'headline': '#account-property-headline',
|
'headline': '#account-property-headline',
|
||||||
'biography': '#account-property-biography',
|
'biography': '#account-property-biography',
|
||||||
'organisation': '#account-property-organisation',
|
'organisation': '#account-property-organisation',
|
||||||
@@ -17,63 +17,48 @@
|
|||||||
'location': '#account-property-location'
|
'location': '#account-property-location'
|
||||||
};
|
};
|
||||||
|
|
||||||
function applyCss(hiddenFields) {
|
function updateCss(hiddenFields) {
|
||||||
console.log('MinimalProfile: Hidden fields:', hiddenFields);
|
|
||||||
|
|
||||||
if (!hiddenFields || hiddenFields.length === 0) {
|
if (!hiddenFields || hiddenFields.length === 0) {
|
||||||
console.log('MinimalProfile: No hidden fields to apply');
|
console.log('MinimalProfile: No hidden fields');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var css = '';
|
var css = '';
|
||||||
hiddenFields.forEach(function(field) {
|
hiddenFields.forEach(function(field) {
|
||||||
var selector = fieldSelectors[field];
|
var selector = fieldSelectors[field];
|
||||||
if (selector) {
|
if (selector) {
|
||||||
css += '.personal-settings-setting-box:has(' + selector + ') { display: none !important; } ';
|
css += selector + ' { display: none !important; } ';
|
||||||
console.log('MinimalProfile: Hiding field:', field);
|
console.log('MinimalProfile: Hiding', field, selector);
|
||||||
} else {
|
|
||||||
console.log('MinimalProfile: Unknown field:', field);
|
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
if (css) {
|
var style = document.createElement('style');
|
||||||
var style = document.createElement('style');
|
style.id = 'minimalprofile-style';
|
||||||
style.id = 'minimalprofile-style';
|
style.textContent = css;
|
||||||
style.textContent = css;
|
document.head.appendChild(style);
|
||||||
document.head.appendChild(style);
|
console.log('MinimalProfile: CSS applied', css);
|
||||||
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() {
|
setTimeout(function() {
|
||||||
var url = OC.generateUrl('/apps/minimalprofile/api/v1/hidden-fields');
|
var el = document.querySelector('#account-property-pronouns');
|
||||||
console.log('MinimalProfile: Fetching:', url);
|
console.log('MinimalProfile: Pronouns element found?', !!el);
|
||||||
|
}, 3000);
|
||||||
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();
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
@@ -24,7 +24,6 @@ class Application extends App implements IBootstrap {
|
|||||||
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
||||||
function() {
|
function() {
|
||||||
Util::addStyle('minimalprofile', 'minimalprofile');
|
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||||
Util::addScript('minimalprofile', 'minimalprofile');
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user