MediaWiki:Gadget-markAdmins.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m rimosso commento ricorsivo |
Minime correzioni stilistiche come da convenzioni MediaWiki: dichiarazioni di variabili in alto, no Yoda conditions; nomi alle funzioni anonime per chiarezza nelle stack trace, +una variabile per maggiore configurabilità |
||
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
*/
// <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 19 ⟶ 25:
}
// 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-weight: bold; padding-left: 5px; }' );
$.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 42 ⟶ 48:
// no sub pages
if( userLink.indexOf( '/' ) === -1 ) {
if ( knownUserGroups ) {
$container = $( '<span>' );
for(
$abbr = $( '<abbr class="adminMark">' )
.attr( 'title', groupName )
|