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

Content deleted Content added
per tper
sync from User:SD0001/DYK-helper/withJsMode2.js - requested on talk
Line 308:
name: 'qpq',
label: 'Reviewed: ',
tooltip: 'DYK nomination(s) you reviewed. This is compulsorymandatory for editors with 5+ DYKprior creditsnominations (QPQ requirement). You can fill this after you make the nomination as well. When the unreviewed backlog mode is active, a 2nd QPQ is also required for editors with 20+ past nominations.',
size: '50px',
value: NOMPAGE_PREFIX
});
 
form.append({
type: 'div',
name: 'qpq-required',
label: 'Number of QPQs required: <span id=dyk-qpq-count>calculating ...</span>'
});
form.append({
type: 'button',
Line 440 ⟶ 447:
$(Morebits.quickForm.getElementContainer(result.multiarticle)).css('margin-top', '10px');
 
// Show number of QPQs required
new mw.Api().get({
"action": "query",
"prop": "revisions",
"titles": "User:SDZeroBot/DYK nomination counts.json|Template:Did you know/Backlog mode?",
"formatversion": "2",
"rvprop": "content",
"rvslots": "main"
}).then(function(json) {
var nomCountsText = json.query.pages[0].revisions[0].slots.main.content;
var nomCounts = JSON.parse(nomCountsText);
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 {
$('#dyk-qpq-count').text('0, as you have less than 5 past nominations');
}
}).catch(function(err) {
$('#dyk-qpq-count').text('failed to calculate');
console.log(err);
});
};