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

Content deleted Content added
create nom page only after editing talk page, so that template behaves correctly
community reassessment and individual reassessment unified to a single process
Line 33:
mw.util.addCSS('.quickform * { font-size: 12px; }');
 
var typefield = form.append({
type: 'field',
label: 'GAR type',
id: 'gartype_fieldset'
});
 
typefield.append({
type: 'radio',
name: 'gartype',
list: [
{
label: 'Community reassessment',
value: 'garc',
checked: true
},
{
label: 'Individual reassessment',
value: 'gari'
}
]
});
 
var field = form.append({
Line 94 ⟶ 72:
var form = e.target;
gar.params = {
type: form.gartype.value,
notify: form.notify.checked,
reason: form.reason.value
};
gar.garc = gar.params.type === 'garc';
gar.gari = gar.params.type === 'gari';
 
Morebits.simpleWindow.setButtonsEnabled(false);
Line 123 ⟶ 98:
new Morebits.status('Notifications', ['The script has notified the the reviewer and page creator. ' +
'Please consider manually notifying other involved editors and WikiProjects using ',
Morebits.htmlNode('code', '{{subst:GARMessage|' + gar.title + '|' + (gar.garc ? 'GAR' : '') + 'pageGARpage=' + gar.num + '}} ~~~~') ], 'warn');
});
 
Line 138 ⟶ 113:
list: 'allpages',
};
query.apnamespace = '14', // TalkWP
if (gar.garc) {
query.apnamespaceapprefix = '4',Good article reassessment//' WP+ gar.title + '/';
query.apprefix = 'Good article reassessment/' + gar.title + '/';
} else {
query.apnamespace = '1', // Talk
query.apprefix = gar.title + '/GA'; // name without namespace
}
var api = new Morebits.wiki.api('Getting numbering', query);
api.post().then(function(apiobj) {
Line 156 ⟶ 126:
createNomPage: function() {
var def = $.Deferred();
var appendtext = '{{subst:GAR/header}}\n' + gar.params.reason;
if (gar.garc) {
appendtext =
'{{subst:GAR/header}}\n' +
gar.params.reason;
} else {
appendtext =
'==GA Reassessment==\n' +
'{{subst:GAR/subst|{{subst:PAGENAME}}}}\n' +
gar.params.reason;
}
var pageobj = new Morebits.wiki.page(gar.garpage, 'Creating nomination page');
pageobj.setAppendText(appendtext);
Line 178 ⟶ 138:
editTalkPage: function() {
var def = $.Deferred();
querygar.apprefixgarpage = 'Wikipedia:Good article reassessment/' + gar.title + '/' + gar.num;
if (gar.garc) {
gar.garpage = 'Wikipedia:Good article reassessment/' + gar.title + '/' + gar.num;
} else {
gar.garpage = gar.talktitle + '/GA' + gar.num;
}
var talkpage = new Morebits.wiki.page(gar.talktitle, 'Editing talk page');
talkpage.load(function(talkpage) {
Line 189 ⟶ 145:
text = '{{subst:GAR}}\n' + text;
// append transclusion:
text += '\n\n==GA Reassessment==\n' +
if (gar.garc) {
'{{' + gar.garpage + '}}';
text += '\n\n==GA Reassessment==\n' +
'{{' + gar.garpage + '}}';
} else {
text += '\n\n{{' + gar.garpage + '}}';
}
talkpage.setPageText(text);
talkpage.setEditSummary('Nominating for good article reassessment' + gar.advert);
Line 266 ⟶ 218:
notify: function() {
var def = $.Deferred();
var users = Morebits.array.uniq(gar.usersToNotify).filter(userfunction =>(user) {
return user !== mw.config.get('wgUserName');
});
var appendtext = '\n\n' +
'{{subst:GARMessage|' + gar.title + '|GARpage=' + gar.num + '}} ~~~~' :;
(gar.garc ?
'{{subst:GARMessage|' + gar.title + '|GARpage=' + gar.num + '}} ~~~~' :
'{{subst:GARMessage|' + gar.title + '|page=' + gar.num + '}} ~~~~');
var editsummary = '[[' + gar.title + ']] listed for good article reassessment' + gar.advert;
var notificationsDone = 0;