MediaWiki
Gadget-statistics.js
From Dogcraft Wiki
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
function getEditCount() { | function getEditCount() { | ||
var | var params = { | ||
action: 'query', | action: 'query', | ||
format: 'json', | format: 'json', | ||
Line 13: | Line 13: | ||
api = new mw.Api(); | api = new mw.Api(); | ||
api.get( | api.get( params ).done( function ( data ) | ||
{ | { | ||
var users = data.query.allusers, | var users = data.query.allusers, |
Revision as of 17:57, 5 July 2020
$(document).ready(function() {
function getEditCount() {
var params = {
action: 'query',
format: 'json',
list: 'allusers',
aulimit: 3,
auprop: 'editcount'
},
uecData = "A",
api = new mw.Api();
api.get( params ).done( function ( data )
{
var users = data.query.allusers,
u;
uecData = "b";
//if (uecMode == "table")
//{
/*for ( u in users ) {
uecData += "a"//'{{!}}-\n{{!}}' + users[u].name + '{{!!}}' + users[u].editcount + '\n{{!}}-\n';
}*/
//}
/*else if (uecMode == "single")
{
for ( u in users ) {
uecData += '|users[u].name = users[u].editcount \n';
}
}
else if (uecMode == "raw")
{
for ( u in users ) {
uecData += 'users[u].name users[u].editcount\n';
}
}*/
});
return uecData;
}
function testAPIEdit() {
var templateNoInclude = '<noinclude>\n{{EditCountMain|mode=table}}\n{{EditCountMain|mode=single|username=username}}\n{{EditCountMain|mode=single|username=Me!}}\n{{EditCountMain|mode=raw}}\n{{EditCountMain|mode=double}} text\ntext\ntext <br> text\n</noinclude>\n',
templateSection1 = '<includeonly>{{#switch: {{{mode|}}}\n|table = <div class=\"phonefullscreen uecTable2\">\n{{{!}} class=\"wikitable sortable\"\n!Username\n!Edit count\n',
templateSection1data = getEditCount(),
templateSection2 = '{{!}}}</div>\n|single = \n{{#switch: {{{username}}} \n',
templateSection2data = "getEditCount('single')",
templateSection3 = '|There is no data on this user\n}}\n|raw =\n',
templateSection3data = "getEditCount('raw')",
templateSection4 = '|That mode does not exist\n}}\n',
pagecontent = templateNoInclude + templateSection1 + templateSection1data + templateSection2 + templateSection2data + templateSection3 + templateSection3data + templateSection4;
var params = {
action: 'edit',
format: 'json',
title: 'User:Domino/Sandbox',
text: pagecontent,
summary: 'Edit added with the API',
bot : 1,
},
api = new mw.Api();
api.postWithToken( 'csrf', params );
}
document.getElementById('gadgetSandboxButton').innerHTML = "<div id='gadgetSandboxButtoninner'><button type='button' style='background:blue;'>Press this to get editcounts</button></div>";
document.getElementById('gadgetSandboxButton').onclick = function() {testAPIEdit()};
});
This page was last modified on 5 July 2020, at 17:57. (12 months ago)