MediaWiki:Gadget-subpages.js

// Show list of subpages below deletion form

function showSubpagesCB(obj) { var pages = obj.query && obj.query.allpages; if ( !pages || pages.length === 0) { $('#mw-content-text').find('h2').before(' Subpages \n No subpages exist for this page. '); return; }	var cut = mw.config.get('wgPageName').length+1; var path = mw.config.get('wgArticlePath'); pages = '\n' + ($.map( pages, function(page, id) { return '' + page.title.substr(cut) + '' + ' (delete)'; })).join('\n') + '\n'; $('#mw-content-text').find('h2').before(' Subpages \n' + pages); }

mw.hook( 'wikipage.content' ).add(function($content) {	if ( mw.config.get('wgAction') !== 'delete' ) {		return;	}	$.getJSON( mw.util.wikiScript( 'api' ), { format:			'json', action:			'query', list:			'allpages', aplimit:		500, apnamespace:	mw.config.get('wgNamespaceNumber'), apprefix:		mw.config.get('wgTitle') + '/' }, showSubpagesCB ); });