Gebruiker:MakiBoy/common.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 1: | Regel 1: | ||
− | + | function getEditCount(mw) { | |
− | + | var userName = 'MakiBoy'; | |
− | + | var api = new mw.Api(); | |
− | + | return api.get({ | |
− | + | action: 'query', | |
− | + | list: 'users', | |
+ | usprop: 'editcount', | ||
+ | ususers: userName, | ||
+ | }).then(function (data) { | ||
+ | return data.query.users[0].editcount; | ||
+ | }); | ||
+ | } | ||
function addLink(mw, conf) { | function addLink(mw, conf) { | ||
var title, url; | var title, url; | ||
− | |||
− | |||
− | |||
title = new mw.Title('Special:MyPage/' + conf.subpageName); | title = new mw.Title('Special:MyPage/' + conf.subpageName); | ||
Regel 35: | Regel 38: | ||
(function (mw, $) { | (function (mw, $) { | ||
$(function () { | $(function () { | ||
− | var conf; | + | getEditCount(mw).then(function (editCount) { |
− | + | var conf; | |
− | + | conf = [{ | |
− | + | subpageName: 'Kladblok', | |
− | + | portletLabel: 'Kladblok', | |
− | + | portletTooltip: 'Naar mijn kladblok', | |
− | + | editintroPagename: 'Template:User_sandbox', | |
− | + | preloadPagename: 'Template:User_sandbox/preload' | |
− | preloadPagename: 'Template: | + | }, |
− | + | { | |
+ | subpageName: 'aantal/bewerkingen', | ||
+ | portletLabel: 'Aantal bewerkingen: ' + editCount, | ||
+ | portletTooltip: 'Naar mijn aantal bewerkingen', | ||
+ | editintroPagename: 'Template:User_editcount', | ||
+ | preloadPagename: 'Template:User_editcount/preload' | ||
+ | }]; | ||
− | + | $.each(conf, function (i, conf) { | |
− | + | addLink(mw, conf); | |
+ | }); | ||
}); | }); | ||
}); | }); | ||
}(mediaWiki, jQuery)); | }(mediaWiki, jQuery)); |
Versie van 13 dec 2022 11:30
function getEditCount(mw) {
var userName = 'MakiBoy';
var api = new mw.Api();
return api.get({
action: 'query',
list: 'users',
usprop: 'editcount',
ususers: userName,
}).then(function (data) {
return data.query.users[0].editcount;
});
}
function addLink(mw, conf) {
var title, url;
title = new mw.Title('Special:MyPage/' + conf.subpageName);
url = new mw.Uri(title.getUrl());
url.extend({
action: 'edit',
redlink: 1,
editintro: new mw.Title(conf.editintroPagename),
preload: new mw.Title(conf.preloadPagename)
});
mw.util.addPortletLink(
'p-personal',
url,
conf.portletLabel,
'pt-sandbox',
conf.portletTooltip,
null,
'#pt-preferences'
);
}
(function (mw, $) {
$(function () {
getEditCount(mw).then(function (editCount) {
var conf;
conf = [{
subpageName: 'Kladblok',
portletLabel: 'Kladblok',
portletTooltip: 'Naar mijn kladblok',
editintroPagename: 'Template:User_sandbox',
preloadPagename: 'Template:User_sandbox/preload'
},
{
subpageName: 'aantal/bewerkingen',
portletLabel: 'Aantal bewerkingen: ' + editCount,
portletTooltip: 'Naar mijn aantal bewerkingen',
editintroPagename: 'Template:User_editcount',
preloadPagename: 'Template:User_editcount/preload'
}];
$.each(conf, function (i, conf) {
addLink(mw, conf);
});
});
});
}(mediaWiki, jQuery));