MediaWiki:Gadget-GroupIndicators.js: Skillnad mellan sidversioner
Utseende
Innehåll som raderades Innehåll som lades till
Nirmos (Diskussion | Bidrag) Åtgärdar skriptfel på sidor för IP-adresser (TypeError: data.query is undefined). |
Nirmos (Diskussion | Bidrag) Lägger till interface-admin. Använder mediawiki.api i stället för $.getJSON. Använder formatversion=2. |
||
Rad 11: | Rad 11: | ||
var checkuser = 'a checkuser.'; |
var checkuser = 'a checkuser.'; |
||
var oversight = 'an oversighter.'; |
var oversight = 'an oversighter.'; |
||
var interfaceadmin = 'an interface admin'; |
|||
var globalrollbacker = 'a global rollbacker.'; |
var globalrollbacker = 'a global rollbacker.'; |
||
var globalbot = 'a global bot (with global bot status).'; |
var globalbot = 'a global bot (with global bot status).'; |
||
Rad 33: | Rad 34: | ||
checkuser = 'IP-kontrollant.'; |
checkuser = 'IP-kontrollant.'; |
||
oversight = 'censor.'; |
oversight = 'censor.'; |
||
interfaceadmin = 'gränssnittsadministratör'; |
|||
globalrollbacker = 'global tillbakarullare.'; |
globalrollbacker = 'global tillbakarullare.'; |
||
globalbot = 'en global robot (med global robot-status).'; |
globalbot = 'en global robot (med global robot-status).'; |
||
Rad 41: | Rad 43: | ||
local = $( '.gadget-groupindicator-local' ); |
local = $( '.gadget-groupindicator-local' ); |
||
global = $( '.gadget-groupindicator-global' ); |
global = $( '.gadget-groupindicator-global' ); |
||
( new mw.Api() ).get( { |
|||
$.getJSON( |
|||
action: 'query', |
|||
'/w/api.php?action=query&list=users&usprop=groups&ususers=' + username + '&format=json', |
|||
list: 'users', |
|||
⚫ | |||
⚫ | |||
var q = data.query; |
|||
ususers: username, |
|||
⚫ | |||
formatversion: 2 |
|||
⚫ | |||
} ).done( function( data ) { |
|||
⚫ | |||
var q = data.query; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
if ( groups ) { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
if ( groups.indexOf( ' |
} |
||
if ( groups.indexOf( 'rollbacker' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Rollbacker.svg" class="' + classes + '" id="' + id + 'rollbacker"><img src="//upload.wikimedia.org/wikipedia/commons/e/e7/Wikipedia_Rollbacker.svg" height="' + height + '" title="' + text + rollbacker + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'bot' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Administrator.svg" class="' + classes + '" id="' + id + 'sysop"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/20px-Wikipedia_Administrator.svg.png" height="' + height + '" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/30px-Wikipedia_Administrator.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/40px-Wikipedia_Administrator.svg.png 2x" title="' + text + sysop + '" data-file-width="' + dfw + '" data-file-height="' + dfh + '"></a>' ); |
local.append( '<a href="//commons.wikimedia.org/wiki/File:Robot_icon.svg" class="' + classes + '" id="' + id + 'bot"><img src="//upload.wikimedia.org/wikipedia/commons/0/05/Robot_icon.svg" height="' + height + '" title="' + text + bot + '"></a>' ); |
||
} |
|||
if ( groups.indexOf( 'sysop' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Administrator.svg" class="' + classes + '" id="' + id + 'sysop"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/20px-Wikipedia_Administrator.svg.png" height="' + height + '" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/30px-Wikipedia_Administrator.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/40px-Wikipedia_Administrator.svg.png 2x" title="' + text + sysop + '" data-file-width="' + dfw + '" data-file-height="' + dfh + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'bureaucrat' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_bureaucrat.svg" class="' + classes + '" id="' + id + 'bureaucrat"><img src="//upload.wikimedia.org/wikipedia/commons/9/95/Wikipedia_bureaucrat.svg" height="' + height + '" title="' + text + bureaucrat + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'checkuser' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Checkuser.svg" class="' + classes + '" id="' + id + 'checkuser"><img src="//upload.wikimedia.org/wikipedia/commons/b/b5/Wikipedia_Checkuser.svg" height="' + height + '" title="' + text + checkuser + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'oversight' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Oversight_logo.png" class="' + classes + '" id="' + id + 'oversight"><img src="//upload.wikimedia.org/wikipedia/commons/0/06/Oversight_logo.png" height="' + height + '" title="' + text + oversight + '"></a>' ); |
|||
} |
|||
⚫ | |||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Interface_administrator.svg" class="' + classes + '" id="' + id + 'interface-admin"><img src="//upload.wikimedia.org/wikipedia/commons/e/eb/Wikipedia_Interface_administrator.svg" height="' + height + '" title="' + text + interfaceadmin + '"></a>' ); |
|||
} |
} |
||
} |
} |
||
} |
} |
||
); |
} ); |
||
( new mw.Api() ).get( { |
|||
$.getJSON( |
|||
action: 'query', |
|||
'/w/api.php?action=query&meta=globaluserinfo&guiprop=groups&guiuser=' + username + '&format=json', |
|||
⚫ | |||
function ( data ) { |
|||
guiprop: 'groups', |
|||
var q = data.query; |
|||
guiuser: username, |
|||
⚫ | |||
formatversion: 2 |
|||
if ( q ) { |
|||
} ).done( function( data ) { |
|||
⚫ | |||
var q = data.query; |
|||
var groups; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
groups = q.globaluserinfo.groups; |
|||
} |
|||
if ( groups.indexOf( 'global- |
if ( groups ) { |
||
if ( groups.indexOf( 'global-rollbacker' ) !== -1 ) { |
|||
global.append( '<a href="//commons.wikimedia.org/wiki/File:Meta-Wiki_Global_rollback-2000px.png" class="' + classes + '" id="' + id + 'globalrollbacker"><img src="//upload.wikimedia.org/wikipedia/commons/a/a1/Meta-Wiki_Global_rollback-2000px.png" height="' + height + '" title="' + text + globalrollbacker + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'global-bot' ) !== -1 ) { |
|||
local.append( '<a href="//commons.wikimedia.org/wiki/File:Robot_icon.svg" class="' + classes + '" id="' + id + 'globalbot"><img src="//upload.wikimedia.org/wikipedia/commons/0/05/Robot_icon.svg" height="' + height + '" title="' + text + globalbot + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'global-sysop' ) !== -1 ) { |
|||
global.append( '<a href="//commons.wikimedia.org/wiki/File:Meta-Wiki_Global_sysop-2000px.png" class="' + classes + '" id="' + id + 'globalsysop"><img src="//upload.wikimedia.org/wikipedia/commons/5/57/Meta-Wiki_Global_sysop-2000px.png" height="' + height + '" title="' + text + globalsysop + '"></a>' ); |
|||
} |
|||
if ( groups.indexOf( 'steward' ) !== -1 ) { |
|||
⚫ | |||
} |
} |
||
} |
} |
||
} |
} |
||
); |
} ); |
||
} |
} |
||
} ); |
} ); |
Versionen från 31 augusti 2018 kl. 22.23
$( function () {
'use strict';
var v = mw.config.get();
var username = v.wgRelevantUserName;
var text = 'This user is ';
var autopatrolled = 'autopatrolled.';
var rollbacker = 'a rollbacker.';
var bot = 'a bot (with a bot flag).';
var sysop = 'a sysop.';
var bureaucrat = 'a bureaucrat.';
var checkuser = 'a checkuser.';
var oversight = 'an oversighter.';
var interfaceadmin = 'an interface admin';
var globalrollbacker = 'a global rollbacker.';
var globalbot = 'a global bot (with global bot status).';
var globalsysop = 'a global sysop.';
var steward = 'a steward.';
var height = 20;
var dfw = 200;
var dfh = 200;
var classes = 'mw-indicator gadget-groupindicator';
var id = 'mw-indicator-group-';
var indicators = $( '#content' ).children( '.mw-indicators' );
var local;
var global;
if ( username ) {
if ( v.wgUserLanguage === 'sv' ) {
text = 'Den här användaren är ';
autopatrolled = 'autopatrullerad.';
rollbacker = 'tillbakarullare.';
bot = 'en robot (med robotstatus).';
sysop = 'administratör.';
bureaucrat = 'byråkrat.';
checkuser = 'IP-kontrollant.';
oversight = 'censor.';
interfaceadmin = 'gränssnittsadministratör';
globalrollbacker = 'global tillbakarullare.';
globalbot = 'en global robot (med global robot-status).';
globalsysop = 'global administratör.';
steward = 'steward.';
}
indicators.prepend( '<span class="gadget-groupindicator-local"></span><span class="gadget-groupindicator-global"></span>' );
local = $( '.gadget-groupindicator-local' );
global = $( '.gadget-groupindicator-global' );
( new mw.Api() ).get( {
action: 'query',
list: 'users',
usprop: 'groups',
ususers: username,
formatversion: 2
} ).done( function( data ) {
var q = data.query;
var groups;
if ( q ) {
groups = q.users[ 0 ].groups;
if ( groups ) {
if ( groups.indexOf( 'autopatrolled' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Autopatrolled.svg" class="' + classes + '" id="' + id + 'autopatrolled"><img src="//upload.wikimedia.org/wikipedia/commons/a/a2/Wikipedia_Autopatrolled.svg" height="' + height + '" title="' + text + autopatrolled + '"></a>' );
}
if ( groups.indexOf( 'rollbacker' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Rollbacker.svg" class="' + classes + '" id="' + id + 'rollbacker"><img src="//upload.wikimedia.org/wikipedia/commons/e/e7/Wikipedia_Rollbacker.svg" height="' + height + '" title="' + text + rollbacker + '"></a>' );
}
if ( groups.indexOf( 'bot' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Robot_icon.svg" class="' + classes + '" id="' + id + 'bot"><img src="//upload.wikimedia.org/wikipedia/commons/0/05/Robot_icon.svg" height="' + height + '" title="' + text + bot + '"></a>' );
}
if ( groups.indexOf( 'sysop' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Administrator.svg" class="' + classes + '" id="' + id + 'sysop"><img src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/20px-Wikipedia_Administrator.svg.png" height="' + height + '" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/30px-Wikipedia_Administrator.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Wikipedia_Administrator.svg/40px-Wikipedia_Administrator.svg.png 2x" title="' + text + sysop + '" data-file-width="' + dfw + '" data-file-height="' + dfh + '"></a>' );
}
if ( groups.indexOf( 'bureaucrat' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_bureaucrat.svg" class="' + classes + '" id="' + id + 'bureaucrat"><img src="//upload.wikimedia.org/wikipedia/commons/9/95/Wikipedia_bureaucrat.svg" height="' + height + '" title="' + text + bureaucrat + '"></a>' );
}
if ( groups.indexOf( 'checkuser' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Checkuser.svg" class="' + classes + '" id="' + id + 'checkuser"><img src="//upload.wikimedia.org/wikipedia/commons/b/b5/Wikipedia_Checkuser.svg" height="' + height + '" title="' + text + checkuser + '"></a>' );
}
if ( groups.indexOf( 'oversight' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Oversight_logo.png" class="' + classes + '" id="' + id + 'oversight"><img src="//upload.wikimedia.org/wikipedia/commons/0/06/Oversight_logo.png" height="' + height + '" title="' + text + oversight + '"></a>' );
}
if ( groups.indexOf( 'interface-admin' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Wikipedia_Interface_administrator.svg" class="' + classes + '" id="' + id + 'interface-admin"><img src="//upload.wikimedia.org/wikipedia/commons/e/eb/Wikipedia_Interface_administrator.svg" height="' + height + '" title="' + text + interfaceadmin + '"></a>' );
}
}
}
} );
( new mw.Api() ).get( {
action: 'query',
meta: 'globaluserinfo',
guiprop: 'groups',
guiuser: username,
formatversion: 2
} ).done( function( data ) {
var q = data.query;
var groups;
if ( q ) {
groups = q.globaluserinfo.groups;
if ( groups ) {
if ( groups.indexOf( 'global-rollbacker' ) !== -1 ) {
global.append( '<a href="//commons.wikimedia.org/wiki/File:Meta-Wiki_Global_rollback-2000px.png" class="' + classes + '" id="' + id + 'globalrollbacker"><img src="//upload.wikimedia.org/wikipedia/commons/a/a1/Meta-Wiki_Global_rollback-2000px.png" height="' + height + '" title="' + text + globalrollbacker + '"></a>' );
}
if ( groups.indexOf( 'global-bot' ) !== -1 ) {
local.append( '<a href="//commons.wikimedia.org/wiki/File:Robot_icon.svg" class="' + classes + '" id="' + id + 'globalbot"><img src="//upload.wikimedia.org/wikipedia/commons/0/05/Robot_icon.svg" height="' + height + '" title="' + text + globalbot + '"></a>' );
}
if ( groups.indexOf( 'global-sysop' ) !== -1 ) {
global.append( '<a href="//commons.wikimedia.org/wiki/File:Meta-Wiki_Global_sysop-2000px.png" class="' + classes + '" id="' + id + 'globalsysop"><img src="//upload.wikimedia.org/wikipedia/commons/5/57/Meta-Wiki_Global_sysop-2000px.png" height="' + height + '" title="' + text + globalsysop + '"></a>' );
}
if ( groups.indexOf( 'steward' ) !== -1 ) {
global.append( '<a href="//commons.wikimedia.org/wiki/File:Wikimedia-logo.svg" class="' + classes + '" id="' + id + 'steward"><img src="//upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg" height="' + height + '" title="' + text + steward + '"></a>' );
}
}
}
} );
}
} );