MediaWiki
Gadget-statistics.js
From Dogcraft Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
function uecGetEditCount() { | /*function uecGetEditCount() { | ||
var params2 = { | var params2 = { | ||
Line 11: | Line 11: | ||
}, | }, | ||
uecData = ""; | uecData = ""; | ||
/ | //var api2 = new mw.Api(); | ||
uecData += "ab"; | uecData += "ab"; | ||
Line 25: | Line 25: | ||
} | } | ||
//} | //} | ||
/ | //else if (uecMode == "single") | ||
{ | //{ | ||
// for ( u in users ) { | |||
// uecData += '|users[u].name = users[u].editcount \n'; | |||
// } | |||
} | //} | ||
else if (uecMode == "raw") | //else if (uecMode == "raw") | ||
{ | //{ | ||
// for ( u in users ) { | |||
// uecData += 'users[u].name users[u].editcount\n'; | |||
// } | |||
} | //} | ||
}); | }); | ||
return uecData; | return uecData; | ||
} | }*/ | ||
function testAPIEdit() { | function testAPIEdit() { | ||
api = new mw.Api(); | api = new mw.Api(); | ||
var params2 = { | |||
action: 'query', | |||
format: 'json', | |||
list: 'allusers', | |||
aulimit: 10, | |||
auprop: 'editcount' | |||
}, | |||
uecTableData = "", | |||
uecSingleData = "", | |||
uecRawData = ""; | |||
api.get( params2 ).done( function uecCallAPI ( data ) | |||
{ | |||
var users = data.query.allusers, | |||
u; | |||
for ( u in users ) { | |||
uecTableData += '{{!}}-\n{{!}}' + users[u].name + '{{!!}}' + users[u].editcount + '\n{{!}}-\n'; | |||
} | |||
for ( u in users ) { | |||
uecSingleData += '|' + users[u].name + ' = ' + users[u].editcount + '\n'; | |||
} | |||
for ( u in users ) { | |||
uecRawData += " " + users[u].name + " " + users[u].editcount + '\n'; | |||
} | |||
}); | |||
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', | 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', | templateSection1 = '<includeonly>{{#switch: {{{mode|}}}\n|table = <div class=\"phonefullscreen uecTable2\">\n{{{!}} class=\"wikitable sortable\"\n!Username\n!Edit count\n', | ||
templateSection1data = | templateSection1data = uecTableData, | ||
templateSection2 = '{{!}}}</div>\n|single = \n{{#switch: {{{username}}} \n', | templateSection2 = '{{!}}}</div>\n|single = \n{{#switch: {{{username}}} \n', | ||
templateSection2data = | templateSection2data = uecSingleData, | ||
templateSection3 = '|There is no data on this user\n}}\n|raw =\n', | templateSection3 = '|There is no data on this user\n}}\n|raw =\n', | ||
templateSection3data = | templateSection3data = uecRawData, | ||
templateSection4 = '|That mode does not exist\n}}\n', | templateSection4 = '|That mode does not exist\n}}\n', | ||
pagecontent = templateNoInclude + templateSection1 + templateSection1data + templateSection2 + templateSection2data + templateSection3 + templateSection3data + templateSection4; | pagecontent = templateNoInclude + templateSection1 + templateSection1data + templateSection2 + templateSection2data + templateSection3 + templateSection3data + templateSection4; |
Revision as of 22:20, 5 July 2020
$(document).ready(function() {
/*function uecGetEditCount() {
var params2 = {
action: 'query',
format: 'json',
list: 'allusers',
aulimit: 10,
auprop: 'editcount'
},
uecData = "";
//var api2 = new mw.Api();
uecData += "ab";
api.get( params2 ).done( function uecCallAPI ( data )
{
var users2 = data.query.allusers,
u2;
//if (uecMode == "table")
//{
for ( u2 in users2 ) {
uecData += '{{!}}-\n{{!}}' + users2[u2].name + '{{!!}}' + users2[u2].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() {
api = new mw.Api();
var params2 = {
action: 'query',
format: 'json',
list: 'allusers',
aulimit: 10,
auprop: 'editcount'
},
uecTableData = "",
uecSingleData = "",
uecRawData = "";
api.get( params2 ).done( function uecCallAPI ( data )
{
var users = data.query.allusers,
u;
for ( u in users ) {
uecTableData += '{{!}}-\n{{!}}' + users[u].name + '{{!!}}' + users[u].editcount + '\n{{!}}-\n';
}
for ( u in users ) {
uecSingleData += '|' + users[u].name + ' = ' + users[u].editcount + '\n';
}
for ( u in users ) {
uecRawData += " " + users[u].name + " " + users[u].editcount + '\n';
}
});
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 = uecTableData,
templateSection2 = '{{!}}}</div>\n|single = \n{{#switch: {{{username}}} \n',
templateSection2data = uecSingleData,
templateSection3 = '|There is no data on this user\n}}\n|raw =\n',
templateSection3data = uecRawData,
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.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 22:20. (12 months ago)