MediaWiki:DYK-nomination-wizard.js: Difference between revisions
Content deleted Content added
update date check behaviour per feedback at WT:DYK |
per tper |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1:
/**
* DYK-nomination-wizard
* Wizard to easily create DYK nominations▼
*
* Loaded on [[Wikipedia:Did you know/Create new nomination]]
* using [[mw:Snippets/Load JS and CSS by URL]]
*
* Author: [[User:SD0001]]
▲ * Wizard to easily create DYK nominations
*
*/
Line 20 ⟶ 21:
$.ready
).then(function() {
.click(function () {▼
});▼
▲ }
if (mw.config.get('wgPageName') !== 'Wikipedia:Did_you_know/Create_new_nomination' ||
mw.config.get('wgAction') !== 'view') return;
Line 34 ⟶ 29:
var NOMINATIONS_PAGE = 'Template talk:Did you know';
dyk.advert = ' ([[
// Calculating prose character count, code based on [[User:Shubinator/DYKcheck.js]] and [[User:Dr pda/prosesize.js]]
Line 107 ⟶ 102:
dyk.callback = function dykMainCallback() {
var form = new Morebits.quickForm(
form.append({
Line 141 ⟶ 136:
name: 'date',
tooltip: 'The date on which creation/expansion began. Must be within the past week. ',
event: dyk.dateCheck // for the benefit of browsers that don't support a datepicker for date fields
});
Line 313 ⟶ 307:
name: 'qpq',
label: 'Reviewed: ',
tooltip: 'DYK nomination(s) you reviewed. This is
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 342 ⟶ 343:
type: 'div',
style: 'float: right; font-size: smaller;', //text-decoration: italic;',
label: $('<
.append(
'[[ ].join(' • '))
).get()
});
Line 352 ⟶ 354:
var result = form.render();
// Attach to the page, #dyk-
$('#dyk-
dyk.updateProseSize(result, mw.util.getParamValue('article'));
Line 388 ⟶ 390:
'form.quickform div textarea.dyk-source { font-size: 110%; height: 35px; }' +
'form.quickform div textarea.dyk-comments { font-size: 125%; height: 35px; }'
);
Line 443 ⟶ 441:
$(Morebits.quickForm.getElementContainer(result.multiarticle)).css('margin-top', '10px');
// Show number of QPQs required
mw.loader.using('ext.gadget.libLua').then(function() {
return mw.libs.lua.call({
module: 'NewDYKnomination',
func: 'getRequiredQpqCount',
args: [mw.config.get('wgUserName')]
}).then(function(output) {
var [numQpqsNeeded, numPriorNoms] = output.split('\t').map(num => parseInt(num));
dyk.numQpqsRequiredPerArticle = numQpqsNeeded;
if (numQpqsNeeded === 2) {
$('#dyk-qpq-count').text('2, as DYK is currently in backlog mode and you have ' + numPriorNoms + ' past nominations');
} else if (numQpqsNeeded === 1) {
$('#dyk-qpq-count').text('1, as you have ' + numPriorNoms + ' past nominations');
} else if (numQpqsNeeded === 0) {
$('#dyk-qpq-count').text('0, as you have fewer than 5 past nominations');
} else {
$('#dyk-qpq-count').text('failed to calculate');
}
$('#dyk-qpq-count').text('failed to calculate');
console.log(err);
});
};
Line 472 ⟶ 494:
if (type === 'source') {
txtarea.previousElementSibling.style.borderTop = 'none';
txtarea.previousElementSibling.style.marginTop = '0';
Line 541 ⟶ 561:
addTemplateParam('status', params.status);
addTemplateParam('hook', params.hook + (params.source ? ('\n{{smalldiv|1= \n*
Object.keys(params).filter(function (field) {
Line 626 ⟶ 646:
var prosesizewarn = $('#dyk-prosesize').css('color') === "rgb(255, 0, 0)";
if (prosesizewarn && !confirm('This article has
return;
}
if (sourcewarning && !confirm('You have not specified the source for each hook. Are you sure you want to continue?')) {
return;
}
if (dyk.numQpqsRequiredPerArticle > 0 &&
!/Template:Did you know nominations\/\w+/.test(form.qpq.value) &&
!confirm('You have not specified a QPQ. The nomination may be rejected unless you provide a QPQ soon after the nomination. Are you sure you want to continue?')) {
return;
}
Line 641 ⟶ 667:
Morebits.wiki.actionCompleted.redirect = NOMINATIONS_PAGE + '#' + dyk.articles.join(', ');
Morebits.wiki.actionCompleted.notice = 'Completed';
Morebits.wiki.api.setApiUserAgent('[[w:
var nompage = new Morebits.wiki.page(NOMPAGE_PREFIX + article, 'Creating nomination page');
Line 658 ⟶ 684:
if (pageText === newPageText) {
var linknode = document.createElement('a');
linknode.setAttribute("href", mw.util.getUrl("
linknode.appendChild(document.createTextNode('Repair nomination'));
dykpage.getStatusElement().error(['Could not find the target spot for the nomination. Please see: ', linknode, '.']);
|