MediaWiki:Gadget-markadmins.js: Rozdźěl mjez wersijomaj

korektura po stronje w esperantorěčneje wikipedije, dokelž stara wersija je faktisce zestarjena
(korektura po stronje w esperantorěčneje wikipedije, dokelž stara wersija je faktisce zestarjena)
/// User:PerfektesChaos/js/markGroupMembers/eo.js
//Z ruskeje wikipedije, po namjeće wužiwarja Obersachse
/// 2015-11-18 PerfektesChaos@de.wikipedia
//Based on the script made by [[:de:Benutzer:Spongo]]
/// adaptacija za hornjoserbsku wikipediju, Tlustulimu, 2016-01-19
//rewritten by [[m:User:Hoo man]]; 2012-08-26
// Mark users who are members of arbitrary groups
(function(mw, $) {
// ResourceLoader: compatible;
var userSet = {
// dependencies: mediawiki.util
'A' : ['Dundak', 'J budissin', 'Tlustulimu', 'Tchoř'],
// Requires: JavaScript 1.5, MediaWiki 1.23 (mw.hook, jQuery core)
'B' : [],
/// @license GPL [//www.mediawiki.org/w/COPYING] (+GFDL, LGPL, CC-BY-SA)
'C' : [],
/// <nowiki>
'Ar' : []
/* global window:false */
};
/* jshint forin:false,
bitwise:true, curly:true, eqeqeq:true, latedef:true,
laxbreak:true,
nocomma:true, strict:true, undef:true, unused:true */
 
var userSetTip = {
'A':'Administrator',
'B':'Běrokrat',
'C':'checkuser',
'Ar':'abitr'
}
 
$(document).ready(function() {
mw.util.addCSS('tt.userflags {color:#0645ad}');
mw.util.$content.find('a').each( function(i, lnk) {
if( /[?#]/.test(lnk.href) && lnk.href.indexOf('redlink=1') === -1 ) {
return;
}
var mm, f, user, flags, tips;
mm = /^Wužiwar(ka)?:(.*)/.exec(lnk.title);
if( !mm ) {
return;
}
user = decodeURIComponent(mm[2]);
if (lnk.className.indexOf('new') !== -1) {
user = user.replace(/ \([^\)]+\)$/,'');
}
flags = []; tips = [];
for( f in userSet ) {
if($.inArray( user, userSet[f] ) !== -1 ){
flags.push(f);
tips.push(userSetTip[f]);
}
}
if( !flags.length ) {
return;
}
 
( function ( mw, $ ) {
tips = ' ('+tips.join(', ')+')';
"use strict";
var Groups = [ "A", "B" ],
Users = { "A": ['J budissin',
'Tlustulimu',
'Tchoř'],
"B": false,
"C": false,
"I": false,
"O": false,
"K": false,
"Ar": false,
"Ar+": false },
Tips = { "A": "Administrator",
"B": "Běrokrat",
"C": "checkuser",
"I": "подводящий итоги",
"O": "Revizianto",
"K": "клерк",
"Ar": "abitr",
"Ar+": "Rezerwowy abitr" },
Live = true, // true: page is required to exist
Lower = false, // true: include links to subpages
Sep = "/",
Spaces = "Wužiwar(?:|ka)", // + talk NS
Style = "color:#0645AD;" +
"font-size:small;" +
"font-weight:bold;" +
"margin-left:0.2em;" +
"vertical-align:super;",
Badges, Learnt, Modes, REurl;
 
$(lnk)
.after('\u00A0', '<tt class=userflags title="'+tips+'">('+flags.join(',') + ')</tt>')
.attr('title', $(lnk).attr('title') + tips);
 
 
});
/*
});
* This program is free software; you can redistribute it and/or
})(mediaWiki, jQuery);
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program;
* if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*/
 
 
 
function found( i, dom ) {
// Matching result
// i -- element count
// dom -- DOM element <a>
var got = REurl.exec( dom.href ),
badge, k, mode, s, sign, staff, story, suffix, users, $a;
if ( got ) {
staff = got[ 1 ].replace( /_/, " " );
try {
staff = decodeURIComponent( staff );
} catch (e) {
if ( window.console &&
typeof window.console.log === "function" ) {
window.console.log( "hsb:Gadget-markGroupMembers decode",
staff );
}
} // try decode
got = [ ];
for ( k = 0; k < Groups.length; k++ ) {
sign = Groups[ k ];
users = Users[ sign ];
if ( users && $.inArray( staff, users ) >= 0 ) {
got.push( sign );
}
} // for k
if ( got.length ) {
sign = got.join();
if ( typeof Badges[ sign ] === "object" ) {
badge = Badges[ sign ];
story = badge.story;
mode = badge.mode;
} else {
mode = ++Modes;
Badges[ sign ] = { };
for ( k = 0; k < got.length; k++ ) {
s = got[ k ];
if ( story ) {
story = story + ", ";
suffix = suffix + Sep + s;
} else {
story = "";
suffix = "(" + s;
}
} // for k
story = story + Tips[ s ];
suffix = suffix + ")";
badge = Badges[ sign ];
badge.learnt = true;
badge.mode = mode;
badge.story = story;
badge.suffix = suffix;
Learnt = true;
}
$a = $( dom );
$a.attr( "title", $a.attr( "title" ) + "\n" + story );
$a.addClass( "markGroupMembers markGroupMembers-" + mode );
}
}
} // found()
 
 
 
function furnish( $area ) {
// Page content has been updated
// $area -- jQuery $content
var badge, sign, styles;
Learnt = false;
$area.find( "a[href^=\"/wiki/\"]" ).each( found );
if ( Learnt ) {
styles = "";
for ( sign in Badges ) {
badge = Badges[ sign ];
if ( badge.learnt ) {
badge.learnt = false;
styles = styles +
".markGroupMembers-" + badge.mode + ":after {" +
"content:\"" + badge.suffix + "\";" +
Style + "}";
}
} // for sign in Badges
mw.util.addCSS( styles );
}
} // furnish()
 
 
 
function fire() {
// Initialize gadget
if ( Live ) {
REurl = "/wiki/";
} else {
REurl = "/(?:wiki/|.+[?&]title=)";
}
REurl = REurl + Spaces;
if ( Lower ) {
REurl = REurl + ":([^#?&]+)";
} else {
REurl = REurl + ":([^/#?&]+)";
}
REurl = REurl + "(?:[#?].*)?$";
Badges = { };
Modes = 0;
REurl = new RegExp( REurl );
mw.hook( "wikipage.content" ).add( furnish );
} // fire()
 
 
 
mw.loader.using( [ "mediawiki.util" ],
fire );
}( window.mediaWiki, window.jQuery ) );
 
 
 
 
// Emacs
// Local Variables:
// coding: utf-8-dos
// End:
 
/// EOF </nowiki> markGroupMembers/eo.js
Z Wikipedije, swobodneje encyklopedije