User:PleaseStand/userinfo-dev.js: Difference between revisions

Content deleted Content added
include "ago" in the Contributions link
Undid revision 1225074654 by PleaseStand (talk) - "named" group was removed in git:mediawiki/core/+/93e8350d295203ac
 
(12 intermediate revisions by the same user not shown)
Line 19:
'ps-userinfo-gendersymbol-female': '♀',
'ps-userinfo-gendersymbol-unknown': '',
'ps-userinfo-itemseparator': ' $1\u00a0|  $2',
'ps-userinfo-groupseparator': '$1,  $2',
 
'ps-userinfo-seconds': '$1 {{PLURAL:$1|second|seconds}}',
Line 37:
'ps-userinfo-ipv6': 'IPv6 address',
'ps-userinfo-lastedited': 'last edited [$2 $1 ago]',
'ps-userinfo-missing': 'unregistered username not registered',
'ps-userinfo-registration': '$1 old',
'ps-userinfo-user': '{{GENDER:$1|registered user}}'
Line 68:
groups: user.groups || [],
editCount: 'editcount' in user ? user.editcount : null,
registration: parseDateuser.registration ? new Date( user.registration ) : null,
isBlocked: 'blockexpiry' in user,
gender: user.gender || 'unknown',
lastEdited: ( contribs && contribs[0] ) ? parseDatenew Date( contribs[0].timestamp ) : null
};
} );
Line 82:
function displayInfo( info ) {
var userPrefix = mw.config.get( 'wgFormattedNamespaces' )[2] + ':',
hostParts = ___location.hostname.split( '.' ),
items = [],
groups = [],
Line 93 ⟶ 92:
page: userPrefix + info.name
} )
}, new h.Raw( h.element( 'strong', {}, mw.msg( 'ps-userinfo-blocked' ) ) ) ) );
}
 
Line 111 ⟶ 110:
} );
if ( groups.length ) {
items.push( groups.join( mw.message( 'ps-userinfo-groupseparator', '', '' ).parseescaped() ) );
} else {
items.push( mw.message( 'ps-userinfo-user', info.gender ).escaped() );
}
 
Line 124 ⟶ 125:
if ( info.editCount !== null ) {
items.push( h.element( 'a', { href:
'https://toolsxtools.wmflabswmcloud.org/supercountec/index.php?' + $.param( {
hostParts = encodeURIComponent( ___location.hostname.split( ) + './' ),+
user:encodeURIComponent( info.name, )
project: hostParts.slice( 0, -1 ).join( '.' )
} )
}, mw.message( 'ps-userinfo-editcount', info.editCount ).text() ) );
}
Line 153:
 
// Replace the subtitle with the rest of the info
$( '#siteSub' ).html( items.join( mw.message( 'ps-userinfo-itemseparator', '', '' ).parseescaped() ) );
}
 
Line 173:
} );
} );
}
 
/**
* Parse a UTC date in the subset of ISO 8601 used by MediaWiki's API.
* That format is YYYY-MM-DDTHH:MM:SSZ.
* @param {string} str The UTC date returned
* @return {Date} object
*/
function parseDate( str ) {
var m = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/.exec( str );
if ( !m ) {
return null;
}
var d = new Date();
d.setUTCFullYear( m[1], m[2] - 1, m[3] );
d.setUTCHours( m[4], m[5], m[6] );
return d;
}