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

Content deleted Content added
update date check behaviour per feedback at WT:DYK
change dyk-helper to dyk-wizard in edit summary, api user agent and other places
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
* Automates:
* - Creation of the nomination page
* - Transcluding the nomination at T:DYKT
* - Transcluding the nomination at article talk pages
*/
 
Line 20 ⟶ 21:
$.ready
).then(function() {
if (mw.config.get('wgNamespaceNumber') === 0) {
$(mw.util.addPortletLink('p-cactions', '#', 'DYK', 'dyk-portlet', 'Nominate for DYK'))
.click(function () {
window.open('/wiki/Wikipedia:Did_you_know/Create_new_nomination?article=' + encodeURIComponent(Morebits.pageNameNorm), '_blank')
});
}
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 = ' ([[UserWikipedia:SD0001Did you know/DYK-helperNomination wizard|DYK-helperwizard]])';
 
// Calculating prose character count, code based on [[User:Shubinator/DYKcheck.js]] and [[User:Dr pda/prosesize.js]]
Line 345 ⟶ 340:
.addClass('hlist')
.append(
$('<li>').append(Morebits.createHtml('[[enw:WP:DYKRULES|DYK rules]]')),
$('<li>').append(Morebits.createHtml('[[enw:UserWikipedia talk:SD0001Did you know/DYK-helperNomination wizard|Give feedback]]'))
).get()
});
Line 352 ⟶ 347:
var result = form.render();
 
// Attach to the page, #dyk-helperwizard-container is provided by the wikitext
$('#dyk-helperwizard-container').empty().append(result);
 
dyk.updateProseSize(result, mw.util.getParamValue('article'));
Line 641 ⟶ 636:
Morebits.wiki.actionCompleted.redirect = NOMINATIONS_PAGE + '#' + dyk.articles.join(', ');
Morebits.wiki.actionCompleted.notice = 'Completed';
Morebits.wiki.api.setApiUserAgent('[[w:Useren:MediaWiki:SD0001/DYK-helpernomination-wizard.js|DYK-helper]]');
 
var nompage = new Morebits.wiki.page(NOMPAGE_PREFIX + article, 'Creating nomination page');
Line 658 ⟶ 653:
if (pageText === newPageText) {
var linknode = document.createElement('a');
linknode.setAttribute("href", mw.util.getUrl("UserWikipedia:SD0001Did you know/DYK-helperNomination wizard/Fixing nomination"));
linknode.appendChild(document.createTextNode('Repair nomination'));
dykpage.getStatusElement().error(['Could not find the target spot for the nomination. Please see: ', linknode, '.']);