注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
//未完成
// If FriendlyConfig aint exist.
if( typeof( FriendlyConfig ) == 'undefined' ) {
	FriendlyConfig = {};
}
 
/**
 FriendlyConfig.summaryAd ( string )
 If ad should be added or not to summary, default [[WP:FRIENDLY|Friendly]]
 */
if( typeof( FriendlyConfig.summaryAd ) == 'undefined' ) {
	FriendlyConfig.summaryAd = "(透過[[WP:FRIENDLY|Friendly]])";
}

$(afd);
 
function afd() {
	if( wgNamespaceNumber < 0 || wgCurRevisionId == false ) {
		return;
	} else {
		mw.util.addPortletLink( 'p-cactions', "javascript:afd.callback()", "提刪", "afd", "提請刪除討論", "");
	}
}

afd.callback = function afdCallback( uid ){
	var Window = new SimpleWindow( 600, 200 );
	Window.setTitle( "提請刪除討論" );
	var form = new QuickForm( afd.callback.evaluate , 'change' );
	var selection = form.append( {
			type: 'select',
			name: 'afd-option',
			label: '刪除方式:',
			event: afd.callback.interface_adj
		} );
	selection.append( {
			type: 'option',
			label: '刪除',
			value: 'delete'
		} );
	selection.append( {
			type: 'option',
			label: '合併',
			value: 'merge'
		} );
	selection.append( {
			type: 'option',
			label: '移動至其他計畫',
			value: 'vm'
		} );

	var selection2 = form.append( {
			type: 'select',
			name: 'vm-option',
			label: '移動至:'
		} );
	selection2.append( {
			type: 'option',
			label: '維基辭典',
			value: 'vmd'
		} );
	selection2.append( {
			type: 'option',
			label: '維基文庫',
			value: 'vms'
		} );
	selection2.append( {
			type: 'option',
			label: '維基教科書',
			value: 'vmb'
		} );
	selection2.append( {
			type: 'option',
			label: '維基語錄',
			value: 'vmq'
		} );

	var mergedest = form.append( {
			type: 'input',
			name: 'mergepage',
			label: '合併頁面:'
		} );
	form.append( {
			type: 'textarea',
			name: 'reason',
			label: '刪除理據:'
		} );
	form.append( { type:'submit', label:'提交刪除' } );
	selection2.hide();
	mergedest.hide();
	var result = form.render();
	Window.setContent( result );
	Window.display();
}

afd.callback.interface_adj = function afdCallbackInterfaceAdj(e) {
	var value = e.target.value;
	var root = e.target.form;

	switch( value ) {
		default:
		case 'delete':
			root.selection2.hide();
			root.mergedest.hide();
			return;
		case 'merge':
			root.selection2.hide();
			root.mergedest.show();
			return;
		case 'vm':
			root.selection2.hide();
			root.mergedest.show();
			return;
	}
}

afd.callbacks = {
	main: function( self ) {
			++Wikipedia.numberOfActionsLeft;
			var xmlDoc = self.responseXML;
			var exists = xmlDoc.evaluate( 'boolean(//pages/page[not(@missing)])', xmlDoc, null, XPathResult.BOOLEAN_TYPE, null ).booleanValue;
			if( ! exists ) {
				self.statelem.error( "It seems that the page doesn't exists, perhaps it has already been deleted" );
				return;
			}
			var query = { 
				'title': wgPageName, 
				'action': 'submit'
			};
 
			var wikipedia_wiki = new Wikipedia.wiki( 'Tagging page', query, afd.callbacks.tagPage );
			wikipedia_wiki.params = self.params;
			wikipedia_wiki.followRedirect = false;
			wikipedia_wiki.get();
		},
		tagPage: function( self ) {
			form = this.responseXML.getElementById( 'editform' );
 
			var code;
			if (wgNamespaceNumber ==  Namespace.FILE){
				code = "\{\{ifd|" + self.params.reason + "\}\}";
			} else {
				code = "\{\{afd|" + self.params.reason + "\}\}";
			}

			if( self.params.rcid != '' ) {
				var query = {
					'title': wgPageName,
					'action': 'markpatrolled',
					'rcid': self.params.rcid
				};
 
				var wikipedia_wiki = new Wikipedia.wiki( 'Marking page as patrolled', query );
				wikipedia_wiki.post();
			}
			var postData = {
				'wpMinoredit': false,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': '',
				'wpSummary': "提交刪除討論" + FriendlyConfig.summaryAd,
				'wpTextbox1': code
			};
			self.post( postData );
		}
}

afd.callback.evaluate = function afdCallbackEvaluate(e) {
	wgPageName = wgPageName.replace( /_/g, ' ' );
	//var value = e.target.value;
 
	var params = {
		source: e.target.form.source.value,
		rcid: QueryString.exists( 'rcid' ) ? QueryString.get( 'rcid' ) : ''
	};
 
	Status.init( e.target.form );
 
	Wikipedia.actionCompleted.redirect = wgPageName;
	Wikipedia.actionCompleted.notice = "Tagging complete";
 
	var query = {
		'action': 'query',
		'titles': wgPageName
	}
 
	var wikipedia_api = new Wikipedia.api( 'Checking if page exists', query, afd.callbacks.main );
	wikipedia_api.params = params;
	wikipedia_api.post();

}