User:Dr pda/persondata.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Dr pda/persondata. |
// This script used to populate the Persondata template with fields from
// infoboxes. However, it is now deprecated, and should no longer be used.
// See [[Wikipedia:Persondata]] for more details.
mw.loader.using( [
'mediawiki.jqueryMsg',
'mediawiki.util',
], function () {
var label, tooltip, portletLink;
// Find the label and tooltip the same way as the old script did.
if ( !document.forms.editform && $( '#persondata' ).length ) {
label = 'show/hide persondata';
tooltip = 'Show/hide persondata metadata';
} else if (
mw.config.get( 'wgNamespaceNumber' ) === 0 &&
$( '#wpTextbox1' ).length &&
!$( '#wpTextbox1' ).text().match( /persondata/i )
) {
label = 'add persondata';
tooltip = 'Add persondata metadata';
}
// Add the portlet link. When clicked, this pops up a notification saying
// that the script is deprecated.
if ( label && tooltip ) {
portletLink = mw.util.addPortletLink(
'p-cactions',
'#',
label,
'ca-pdata',
tooltip
);
mw.messages.set( {
'pdata-deprecated': "[[User:Dr pda/persondata.js]] is " +
"[[Wikipedia:Persondata|deprecated]]. Please remove it " +
"from your [[Wikipedia:User scripts|user script]] page."
} );
$( portletLink ).click( function ( e ) {
e.preventDefault();
mw.notify(
mw.message( 'pdata-deprecated' ),
{ title: 'Script deprecated' }
);
} );
}
});