User:SD0001/GAR-helper.js: Difference between revisions

Content deleted Content added
fix bug in determining GAR nomination page when there are more than 10 previous nominations
don't lose nomination text in case of failure
 
(One intermediate revision by the same user not shown)
Line 25:
if (e) e.preventDefault();
 
var Window = new Morebits.simpleWindow(600, 450600);
Window.setTitle( "Nominate article for GAR" );
Window.setScriptName('GAR-helper');
Line 80:
gar.preview = function(form) {
gar.initParams(form);
 
Morebits.status.init(gar.previewbox);
$(gar.previewbox).show();
Line 91:
tm.execute().then(function() {
gar.garpage = 'Wikipedia:Good article reassessment/' + gar.title + '/' + gar.num;
 
var previewText =
'<i>Preview of ' + gar.garpage + ':</i>\n'
Line 96 ⟶ 97:
+ gar.tasks.getNomPageText()
+ '\n----\n'
+ '<i>Notifications will be automatically delivered to the following pages. Uncheck to prevent notification:</i>\n\n'
+ (gar.tasks.getNotificationTargets().map(plength => '*[[User0 talk:' + p + ']]').join('\n');?
gar.tasks.getNotificationTargets()
.map(p => '*<span class=gar-user-to-notify>[[User talk:' + p + ']]</span>').join('\n') :
'*<i>None</i>');
 
form.previewer.beginRender(previewText, gar.garpage);.then(function () {
$(gar.previewbox).find('.gar-user-to-notify').each(function (_, e) {
$(e).prepend(
$('<input>')
.attr('type', 'checkbox')
.attr('value', mw.Title.newFromText($(e).text()).getMainText())
.prop('checked', true)
);
});
});
}, function () {
form.previewer.beginRender("Unable to render preview", gar.garpage);
Line 108 ⟶ 121:
var form = e.target;
gar.initParams(form);
 
gar.usersNotToNotify = new Set($(gar.previewbox)
.find('.gar-user-to-notify input:not(:checked)')
.get()
.map(e => e.value));
 
Morebits.simpleWindow.setButtonsEnabled(false);
Line 115 ⟶ 133:
tm.add(gar.tasks.getNumber, []);
tm.add(gar.tasks.editTalkPage, [ gar.tasks.getNumber ]);
tm.add(gar.tasks.createNomPage, [ gar.tasks.editTalkPage ], function (); {
Morebits.status.printUserText(gar.tasks.getNomPageText(),
'Your nomination text is provided below, with which you can manually create the page [[' + gar.garpage + ']].');
});
tm.add(gar.tasks.getCreator, []);
tm.add(gar.tasks.getLastGanNominator, []);
Line 256 ⟶ 277:
 
notify: function() {
var usersusersToNotify = gar.tasks.getNotificationTargets().filter(name => !gar.usersNotToNotify.has(name));
var appendtext = '\n\n' +
'{{subst:GARMessage|' + gar.title + '|GARpage=' + gar.num + '}} ~~~~';
var editsummary = '[[' + gar.title + ']] listed for good article reassessment' + gar.advert;
var defs = usersusersToNotify.map(function(user) {
var def = $.Deferred();
var usertalk = new Morebits.wiki.page('User talk:' + user, 'Notifying ' + user);