Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
/**
* Flag administrators and special user group members with a letter
* in parenthesis behind links that go into their user namespace.
* E.g. Didym -> Didym (A)
*
* @rev 20:22, 10. Jan. 2017 (CET)
* @author Euku, 28. Dez. 2005
* @author Sir und Olliminatore - Ex-Admin-Markierung
* @author PDD - Adaptierung/zusätzliche Markierungen/Fixes
* @author Littl - aufgeräumt & beschleunigt
* @author Guandalug - Etwas umgeräumt und potentielle Skinabhängigkeit entfernt
* @author Didym, Rillke (Commons), 2014
**/
// <nowiki>
/*global mediaWiki, jQuery*/
(function (mw, $) {
'use strict';
// DEU: Jeder der folgenden vordefinierbaren Variablenwerte kann in
// der eigenen monobook.js/vector.js/common.js vorbelegt werden.
// Beispielsweise um Commons-Admins zu markieren, muss die folgende Zeile hinzugefügt werden:
// window.markAdminCfg = { groups: { comadmin: { enabled: true } } };
// ENG: For a more complex setting, e.g. turning off flagging of administrators and turning on flagging
// of stewards and local OTRS members, following lines must be added:
// window.markAdminCfg = { groups: {
// sysop: { enabled: false },
// wdadmin: { enabled: true },
// 'OTRS-member': { enabled: true }
// }
// };
// Config usernames on page -> markAdmins-data.js
var markAdmins = mw.libs.markAdmins = {
nodes: [],
config: {
groups: {}
},
defaults: {
groups: {
sysop: {
label: 'A',
legacyName: 'admins',
legacyLabelId: 'atxt',
enabled: true
},
oversight: {
label: 'OS',
legacyName: 'oversight',
legacyLabelId: 'oversighttxt',
enabled: true
},
checkuser: {
label: 'CU',
legacyName: 'checkuser',
legacyLabelId: 'checkusertxt',
enabled: true
},
bureaucrat: {
label: 'B',
legacyName: 'bureaucrat',
legacyLabelId: 'bureautxt',
enabled: true
},
steward: {
label: 'S',
legacyName: 'steward',
legacyLabelId: 'stewtxt',
enabled: true
},
/* not yet in data file
'OTRS-member': {
label: 'P',
legacyName: 'otrs',
legacyLabelId: 'otrstxt'
},
'Image-reviewer': {
label: 'L',
legacyName: 'imagereviewers',
legacyLabelId: 'imgreviewertxt'
} */
arbcom: {
label: 'SG',
legacyName: 'arbcom',
legacyLabelId: 'arbcomtxt',
enabled: true
},
ombudsman: {
label: 'Omb',
legacyName: 'ombudsman',
legacyLabelId: 'ombudsmantxt',
enabled: true
},
renadmin: {
label: 'A-Ren',
legacyName: 'renadmins',
legacyLabelId: 'renatxt',
enabled: true
},
comadmin: {
label: 'Com-A',
legacyName: 'comadmins',
legacyLabelId: 'comatxt',
enabled: false
},
exadmin: {
label: 'Ex-A',
legacyName: 'exadmins',
legacyLabelId: 'exatxt',
enabled: false
},
wdadmin: {
label: 'WD-A',
legacyName: 'wdadmins',
legacyLabelId: 'wdatxt',
enabled: false
},
exbureaucrat: {
label: 'Ex-B',
legacyName: 'exbureaucrats',
legacyLabelId: 'exbureautxt',
enabled: false
}
},
runOn: ['Special', 'User', 'User_talk', 'Project', 'File', 'Help'],
runOnHistory: true,
runOnTalk: true,
runOnDiff: true
},
init: function (users) {
markAdmins.users = users;
// Wait for user configuration through their .js
// Not adding as a gadget dependency because user .js
// is sometimes invalid and fails loading and
// gadget dependencies do not offer failed/error options
mw.loader.using('user', markAdmins.mergeConfig, markAdmins.mergeConfig);
},
mergeConfig: function () {
// Merge new configuration
// var optionsConfig = mw.user.options.get('markAdminCfg');
var cfg = $.extend(
true,
markAdmins.config,
markAdmins.defaults,
window.markAdminCfg || {}
// optionsConfig ? JSON.parse(optionsConfig) : {}
);
// Merge legacy config (only for backward compatibility, maybe removed in future)
$.each(cfg.groups, function (groupName, grpCfg) {
// Display settings
var enabled = window['mark' + grpCfg.legacyName];
if (enabled !== undefined)
grpCfg.enabled = !!enabled;
// Label
var label = window['mark' + grpCfg.legacyLabelId];
if (label !== undefined)
grpCfg.label = label;
});
cfg.markSubpages = !!window.marksubpages;
cfg.dontmarkmyself = window.dontmarkmyself ? mw.config.get('wgUserName') : false;
// Hook-up content loading
mw.hook('wikipage.content').add(markAdmins.addLabels);
},
markUser: function (marks, a, b) {
b.appendChild(document.createTextNode('\u00A0(' + marks.join("/") + ')'));
a.appendChild(b);
markAdmins.nodes.push(b);
},
destroy: function () {
$.each(markAdmins.nodes, function (i, n) {
$(n).remove();
});
},
reInit: function () {
markAdmins.destroy();
markAdmins.mergeConfig();
},
addLabels: function (content) {
var users = markAdmins.users;
if (!users)
return;
if (!markAdmins.fullPageProcessed) {
content = $('#mw-content-text')[0] || $('#bodyContent')[0] || $('#content')[0];
markAdmins.fullPageProcessed = true;
}
// Right, the configuration evaluation is here
// It might be possible to use Ajax for page
// navigation in future.
var canNs = mw.config.get('wgCanonicalNamespace');
var isSubpageListing = !!({
'Prefixindex': 1,
'Allpages': 1
})[mw.config.get('wgCanonicalSpecialPageName')];
var ns = mw.config.get('wgNamespaceNumber');
var isUserpage = ns === 2 || ns === 3;
var isHistory = mw.config.get('wgAction') === 'history';
var isTalk = ns % 2 === 1;
var isDiff = !!mw.util.getParamValue('diff');
var cfg = markAdmins.config;
var nsCondition = cfg.runOn.indexOf(canNs) !== -1;
var enabledGroups = {}; // collect only relevant groups
var marker = {},
allAnchors; // collect user-links
var previousUser = '';
var reUserpage = /\/wiki\/Benutzer(in)?([ _]Diskussion)?:(.+)/;
// Namespace run conditions
if (!(nsCondition ||
isHistory && cfg.runOnHistory ||
isTalk && cfg.runOnTalk ||
isDiff && cfg.runOnDiff))
return;
$.each(cfg.groups, function (g, grpCfg) {
if (grpCfg.enabled) {
enabledGroups[g] = grpCfg;
if (users[g])
enabledGroups[g].users = '|' + users[g].join('|') + '|';
else // should never happen
delete enabledGroups[g];
}
});
if (isUserpage) { // Add also the userpage link!?
allAnchors = $(content).find('a');
allAnchors.push($('#ca-nstab-user').find('a')[0]);
} else
allAnchors = content.getElementsByTagName('A');
var node = document.createElement('b');
node.className = 'adminMark';
for (var i = 0, lenAnchors = allAnchors.length; i < lenAnchors; ++i) {
var a = allAnchors[i];
var href = a.getAttribute("href");
// If it's not a link to a user
if (!href)
continue;
// Extract user page ( /wiki/User_talk:Foo/subpage -> Foo/subpage )
var m = href.match(reUserpage);
if (!m || !m[3])
continue;
var userpage = m[3];
// Extract user
var user = userpage.replace(/[\/#].*/, '');
var isMainUserpageLink = user === userpage;
var isUsertalkLink = !!m[2];
// Two consecutive links to the same user? Don't mark followups!
previousUser = (previousUser === user && isUsertalkLink);
if (previousUser) // only once
continue;
if (marker[user] === undefined) {
var curUser = "|" + user + "|";
var mark = [];
// String concatenation is oftentimes faster in modern browsers,
// so using Arrays and joining them finally seems advantage.
// But we would need an additional IF, so there is no gain.
for (var g in enabledGroups) {
if (enabledGroups[g].users.indexOf(curUser) !== -1)
mark.push(enabledGroups[g].label);
}
// Don't mark certain pages, except link to user main page
// Does the link go to the main user page or, if linking subpages is enabled,
// is it not a page that is just listing subpages?
if (!(isMainUserpageLink || cfg.markSubpages && !isSubpageListing))
continue;
if (cfg.dontmarkmyself && user === cfg.dontmarkmyself)
continue;
// Are there markers at all?
marker[user] = mark[0] ? mark : '';
}
// Check finished, now append node
if (marker[user]) {
markAdmins.markUser(marker[user], a, node.cloneNode(1));
// Required for consecutive user link check
previousUser = user;
}
} // end loop
}
};
importScript('Benutzer:РDD3/markAdmins-data.js'); // Can be removed if placed as regular Gadget
mw.hook('userjs.script-loaded.markadmins').add(markAdmins.init);
}(mediaWiki, jQuery)); // </nowiki> EOF