The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* <nowiki> */
/* Bharat Mitra: speedy deletion module */
( function () {
	'use strict';
	var BM = window.BharatMitra;
	var GROUPS = [
		{ group: 'General', options: [
			[ 'G11', 'G11: Spam or advertising' ],
			[ 'G3', 'G3: Vandalism or hoax' ],
			[ 'G1', 'G1: Nonsense or gibberish' ],
			[ 'G2', 'G2: Test page' ],
			[ 'G12', 'G12: Copyright violation' ],
			[ 'G10', 'G10: Attack page' ]
		] },
		{ group: 'Articles', options: [
			[ 'A7', 'A7: No indication of importance, no reliable sources' ],
			[ 'A2', 'A2: Foreign-language article with no context' ],
			[ 'A1', 'A1: Very short article, no context' ],
			[ 'G4', 'G4: Recreated deleted material without improvement' ]
		] },
		{ group: 'Redirects', options: [
			[ 'G8', 'G8: Broken redirect to a page that does not exist' ],
			[ 'R3', 'R3: Redirect from an implausible typo' ]
		] },
		{ group: 'Files', options: [
			[ 'F3', 'F3: Image with an unacceptable licence' ],
			[ 'F1', 'F1: Redundant image' ],
			[ 'F5', 'F5: Unused non-free image' ]
		] }
	];
	function buildTag( v ) {
		/* The Db templates exist only with a lowercase code (Db-a7, Db-g11,
		   Db-r3 and so on); Db-A7 / Db-G11 are missing templates, so the
		   criterion must be lowercased or the tag never renders. */
		return '{{subst:db-' + v.criterion.toLowerCase() + '}}';
	}
	BM.register( 'speedy', {
		open: function () {
			var title = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' );
			BM.core.getConfig().then( function ( cfg ) {
			BM.core.dialog( {
				title: 'Nominate for speedy deletion',
				help: 'Page: ' + title + '. The criteria are those listed at Bharatpedia:Criteria for speedy deletion. The creator will be notified under this month\'s section.',
				fields: [
					{ name: 'criterion', label: 'Criterion', type: 'select', required: true, options: GROUPS },
					{ name: 'note', label: 'Note (goes in the edit summary)', type: 'text' },
					{ name: 'notify', label: 'Notify the creator', type: 'checkbox', value: cfg.speedyNotify !== false }
				],
				preview: function ( v ) { return buildTag( v ); },
				previewTitle: function () { return title; },
				submitLabel: 'Nominate',
				success: 'The page has been nominated for speedy deletion.',
				onSubmit: function ( v ) {
					return BM.core.getPage( title ).then( function ( p ) {
						if ( !p.exists ) { throw new Error( 'This page does not exist.' ); }
						if ( /\{\{\s*(?:subst:)?db/i.test( p.content ) ) {
							throw new Error( 'This page already has a speedy deletion tag.' );
						}
						var tag = buildTag( v );
						var nl = p.content.indexOf( '\n' );
						var firstLine = nl === -1 ? p.content : p.content.slice( 0, nl );
						var newContent;
						if ( /^\s*#\s*REDIRECT/i.test( firstLine ) && nl !== -1 ) {
							newContent = firstLine + '\n' + tag + p.content.slice( nl );
						} else {
							newContent = tag + '\n' + p.content;
						}
						var note = BM.core.cleanParam( v.note );
						var summary = 'Nominated for speedy deletion (' + v.criterion + ')' +
							( note ? ': ' + note : '' ) + ' (using [[Bharatpedia:Bharat Mitra|Bharat Mitra]])';
						return BM.core.savePage( title, newContent, summary, p.revid ).then( function () {
							if ( !v.notify ) { return null; }
							var block = '{{subst:Db-notice|' + BM.core.cleanParam( title ) + '}}\n' + BM.SIG;
							return BM.core.notifyCreator( title, block,
								'Speedy deletion notice (using [[Bharatpedia:Bharat Mitra|Bharat Mitra]])' ).then( function ( status ) {
								if ( status === 'skipped' || status === 'failed' ) {
									mw.notify( 'The page has been nominated, but the creator could not be notified (no local account for the creator).', { type: 'warn' } );
								}
								return null;
							} );
						} );
					} );
				}
			} );
			} );
		}
	} );
}() );
/* </nowiki> */