User:Dr pda/persondata.js

// 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 " +

"deprecated. Please remove it " +

"from your user script page."

} );

$( portletLink ).click( function ( e ) {

e.preventDefault();

mw.notify(

mw.message( 'pdata-deprecated' ),

{ title: 'Script deprecated' }

);

} );

}

});