MediaWiki:Gadget-markAdmins.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
da MediaWiki:Gadget-markAdmins2.js del 4 ott 2018 alle 09:13; nuova versione basata sulle informazioni presenti nella pagina Utente:ItwikiBot/AdminList e aggiornate automaticamente; vedi WP:Officina del 4 ott 2018 alle 09:27 |
fix regex: sostituisci tutti gli underscore nei nomi utente, non solo il primo |
||
(6 versioni intermedie di 3 utenti non mostrate) | |||
Riga 1:
/**
* This script highlights the users in special groups thanks to a JSON that is
* populated with these data by a bot (in this case, using APIs).
*
* This script needs
* @FixMe Find a better place to insert abbrs. The huge fantasy of wikipedians
* may produce weird results, e.g. breaking the username when half of it links
* to the user page, and the other half to the talk page. This should also avoid
* cases where the abbr inherits some CSS from the signature (currently handled
* with font-style: initial).
*/
// <nowiki>
( function ( mw, $ ) {
'use strict';
// run only if in allowed ns, history, talks, and diffs
var allowedNs = [ 'Help', 'User', 'User_talk', 'Project', 'Special' ]
disabledPages = [ 'Prefixindex', 'Allpages' ],
cfgPage = 'Utente:ItwikiBot/AdminList',
if ( ! (
allowedNs.indexOf( mw.config.get( 'wgCanonicalNamespace' ) ) !== -1 ||
Riga 21 ⟶ 30:
}
// do nothing in these special pages (
if( disabledPages.indexOf( specialPage ) !== -1 ) {
▲ var specialPage = mw.config.get( 'wgCanonicalSpecialPageName' );
return;
}
mw.hook( 'wikipage.content' ).add( function markAdmins ( $content ) {
mw.util.addCSS( 'abbr.adminMark { font-style: initial; font-weight: bold; padding-left: 5px; font-size: 0.7em; }' );
$.getJSON( '/wiki/
var
▲ var userPattern = /.wiki.Utente.(.+)/;
// for each link
$content.find( 'a' ).each( function addPerUserGroups () {
var $link = $( this )
userLink, userName, knownUserGroups, groupShort, groupName, i,
$container, $abbr;
// only links to users
Riga 44 ⟶ 53:
// no sub pages
userName = decodeURIComponent( userLink.replace( /\/.*/, '' ).replace( /_/g, ' ' ) ); if ( knownUserGroups ) {
$container = $( '<span>' );
for(
$abbr = $( '<abbr class="adminMark">' )
.attr( 'title', groupName )
|