MediaWiki:DYK-nomination-wizard.js: Difference between revisions

Content deleted Content added
sync from User:SD0001/DYK-helper/withJsMode2.js - requested on talk
Per request on talk
Line 448:
 
// Show number of QPQs required
mw.loader.using('ext.gadget.libLua').then(function() {
new mw.Api().get({
return mw.libs.lua.call({
"action": "query",
module: 'NewDYKnomination',
"prop": "revisions",
func: 'getRequiredQpqCount',
"titles": "User:SDZeroBot/DYK nomination counts.json|Template:Did you know/Backlog mode?",
var numPriorNoms = nomCounts args: [mw.config.get('wgUserName')] || 0;
"formatversion": "2",
});
"rvprop": "content",
}).then(function(jsonoutput) {
"rvslots": "main"
var [numQpqsNeeded, numPriorNoms] = output.split('\t').map(num => parseInt(num));
}).then(function(json) {
if (numQpqsNeeded === 2) {
var nomCountsText = json.query.pages[0].revisions[0].slots.main.content;
$('#dyk-qpq-count').text('2, as DYK is currently in backlog mode and you have ' + numPriorNoms + ' past nominations');
var nomCounts = JSON.parse(nomCountsText);
} else if (numPriorNomsnumQpqsNeeded >=== 51) {
var backlogModeText = json.query.pages[1].revisions[0].slots.main.content;
var isInBacklogMode = /^true/.test(backlogModeText);
var numPriorNoms = nomCounts[mw.config.get('wgUserName')] || 0;
if (isInBacklogMode && numPriorNoms >= 20) {
$('#dyk-qpq-count').text('2, as DYK is currently in backlog mode and you have ' + numPriorNoms + ' past nominations')
} else if (numPriorNoms >= 5) {
$('#dyk-qpq-count').text('1, as you have ' + numPriorNoms + ' past nominations');
} else if (numQpqsNeeded == 0) {
$('#dyk-qpq-count').text('0, as you have less than 5 past nominations');
} else {
$('#dyk-qpq-count').text('failed to calculate');
}
}).catch(function(err) {
$('#dyk-qpq-count').text('failed to calculate');
console.log(err);
});
 
};