// <nowiki>
AwaConfig = {};
AwaConfig.summaryAd = " using [[User:Auawise|Auawise]] script";
AwaConfig.watchTaggedPages = false;
AwaConfig.markTaggedPagesAsMinor = true;
function Awatag() {
if( mw.config.get('wgNamespaceNumber') == 1 ) {
addPortletLink( 'p-cactions', "javascript:Awatag.callback()", "Iraq", "Awa-tag", "Tag article", "");
}
}
addOnloadHook(Awatag);
Awatag.callback = function AwatagCallback( uid ) {
var Window = new SimpleWindow( 600, 400 );
Window.setTitle( "Choose only one tag" );
var form = new QuickForm( Awatag.callback.evaluate );
form.append( { type:'header', label:'Choose one type to add to WP:Iraq' } );
form.append( { type:'radio', name: 'common', list: Awatag.commonList } );
form.append( { type:'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
}
Awatag.commonList = [
{
label: '{{Iraq|importance=low|class=stub}}: low importance, and stub',
value: 'Iraq|importance=mid|class=stub' },
{
label: '{{Iraq|importance=low|class=start}}: low importance, and start',
value: 'Iraq|importance=mid|class=start' },
{
label: '{{Iraq|importance=low|class=B}}: low importance, and B-class',
value: 'Iraq|importance=low|class=B' },
{
label: '{{Iraq|importance=mid|class=stub}}: mid importance,and stub',
value: 'Iraq|importance=mid|class=stub' },
{
label: '{{Iraq|importance=mid|class=start}}: mid importance, and start',
value: 'Iraq|importance=mid|start' },
{
label: '{{Iraq|importance=mid|class=B}}: mid importance, and B-class',
value: 'Iraq|importance=mid|class=B' },
{
label: '{{Iraq|importance=high|class=stub}}: high importance, and stub',
value: 'Iraq|importance=high|class=stub' },
{
label: '{{Iraq|importance=high|class=start}}: high importance, and start',
value: 'Iraq|importance=high|class=start' },
{
label: '{{Iraq|importance=high|class=B}}: high importance, and B-class',
value: 'Iraq|importance=high|class=B' },
{
label: '{{Iraq|attention=yes}}: article needs attention',
value: 'Iraq|attention=yes' }
];
Awatag.callbacks = {
main: function( self ) {
var form = self.responseXML.getElementById( 'editform' );
var summaryText = 'Added';
var addStub = false;
var addUncategorized = false;
var text = '';
for( var i = 0; i < self.params.tags.length; i++ ) {
if( self.params.tags[i] == 'stub' ) {
addStub = true;
} else if( self.params.tags[i] == 'uncategorized' ) {
addUncategorized = true;
} else {
text += '\{\{' + self.params.tags[i] +
'|date=\{\{subst:CURRENTMONTHNAME\}\} \{\{subst:CURRENTYEAR\}\}\}\}\n';
}
if( self.params.tags.length > 2 && i < (self.params.tags.length - 1) && i != 0 ) {
summaryText += ',';
}
if( self.params.tags.length > 1 && i == (self.params.tags.length - 1) ) {
summaryText += ' and';
}
summaryText += ' \{\{' + self.params.tags[i] + '\}\}';
}
text += form.wpTextbox1.value;
if( addStub ) {
text += '\n\{\{stub|date=\{\{subst:CURRENTMONTHNAME\}\} \{\{subst:CURRENTYEAR\}\}\}\}';
}
if( addUncategorized ) {
text += '\n\{\{uncategorized|date=\{\{subst:CURRENTMONTHNAME\}\} \{\{subst:CURRENTYEAR\}\}\}\}';
}
summaryText += ' tag' + ( self.params.tags.length > 1 ? 's' : '' ) + ' to article.' + AwaConfig.summaryAd
var postData = {
'wpMinoredit': AwaConfig.markTaggedPagesAsMinor ? 1 : undefined,
'wpWatchthis': AwaConfig.watchTaggedPages ? 1 : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': summaryText,
'wpTextbox1': text
};
self.post( postData );
}
}
Awatag.callback.evaluate = function AwatagCallbackEvaluate(e) {
var form = e.target;
var tags = getChecked( form.common );
if( tags.length == 0 ) {
alert( 'You must select at least one tag' );
return;
}
var params = {
tags: tags
}
Status.init( form );
var query = {
'title': mw.config.get('wgPageName'),
'action': 'submit'
};
Wikipedia.actionCompleted.redirect = mw.config.get('wgPageName');
Wikipedia.actionCompleted.notice = "Tagging complete, reloading article in some seconds";
var wikipedia_wiki = new Wikipedia.wiki( 'Article modification', query, Awatag.callbacks.main );
wikipedia_wiki.params = params;
wikipedia_wiki.get();
}
// </nowiki>