Welcome to the DFO World Wiki. With many major updates since the release of DFO, many items are missing. Visit Item Database Project to learn more.
Please remember to click "show preview" before saving the page.
Thanks for the updated logo snafuPop!

Difference between revisions of "MediaWiki:Gadget-instantDelete.js"

From DFO World Wiki
Jump to: navigation, search
m
m (New default reason)
 
(One intermediate revision by the same user not shown)
Line 75: Line 75:
 
   
 
   
 
function veryQuickDelete (){
 
function veryQuickDelete (){
var form, inputbox, submit, container, filetoc;
+
var form, inputbox, submit, container, filetoc, cattoc;
 
   
 
   
 
form = document.createElement('form');
 
form = document.createElement('form');
Line 82: Line 82:
 
   
 
   
 
inputbox = document.createElement('input');
 
inputbox = document.createElement('input');
inputbox.value = 'Copyright violation, see [[Commons:Licensing]]';
+
inputbox.value = 'Requested Deletion';
 
inputbox.id = 'vqdReason';
 
inputbox.id = 'vqdReason';
 
inputbox.size = '60';
 
inputbox.size = '60';
Line 100: Line 100:
 
if (filetoc) {
 
if (filetoc) {
 
filetoc.appendChild(container);
 
filetoc.appendChild(container);
 +
}
 +
//dfoplayer. allows pages with category footer to add
 +
                cattoc = document.getElementById('catlinks');
 +
if (cattoc) {
 +
cattoc.appendChild(container);
 
}
 
}
 
}
 
}

Latest revision as of 10:53, 27 February 2015

/*  _____________________________________________________________________________
 * |                                                                             |
 * |                    === WARNING: GLOBAL GADGET FILE ===                      |
 * |                  Changes to this page affect many users.                    |
 * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
 * |_____________________________________________________________________________|
 *
 * Due to the convenience of instant delete, sysops should have this disabled in their preferences until many pages needed to be deleted. //dfoplayer
 *
 */

/**
 * Instantly delete a page in the file namespace.
 * @author Krinkle, 2011
 * @author Bryan, 2007
 * @source commons.wikimedia.org/wiki/MediaWiki:Gadget-instantDelete.js
 * @version 1.0 (2011-12-28)
 * @compatible MediaWiki 1.18
 */
( function () {
"use strict";
 
	function vqdNow(){
		var reason, container;
		reason = document.getElementById('vqdReason').value;
		container = document.getElementById('vqdContainer');
		$(container).text('Loading...');
 
		$.getJSON( mw.util.wikiScript( 'api' ), {
			format: 'json',
			action: 'query',
			prop: 'info',
			intoken: 'delete',
			titles: mw.config.get( 'wgPageName' )
		}, function ( data ) {
			var id, page, token;
			if ( !data || !data.query || !data.query.pages ) {
				return;
			}
			for ( id in data.query.pages ) {
				page = data.query.pages[id];
				if ( page.deletetoken ) {
					token = page.deletetoken;
					break;
				}
			}
			if ( !token ) {
				return;
			}
 
			$.ajax({
				url: mw.util.wikiScript( 'api' ),
				data: {
					format: 'json',
					action: 'delete',
					title: mw.config.get( 'wgPageName' ),
					reason: reason,
					token: token
				},
				type: 'POST',
				success: function(data){
					if(data && !data.error){
						$(container).text('Page deleted.');
					} else {
						$(container).text('Deletion failed.');
					}
				},
				error: function(){
						$(container).text('Deletion failed.');
				}
			});
 
		});
	}
 
	function veryQuickDelete (){
		var form, inputbox, submit, container, filetoc, cattoc;
 
		form = document.createElement('form');
		form.onsubmit = function () { return false; };
		form.style.display = 'inline';
 
		inputbox = document.createElement('input');
		inputbox.value = 'Requested Deletion';
		inputbox.id = 'vqdReason';
		inputbox.size = '60';
		form.appendChild(inputbox);
 
		submit = document.createElement('input');
		submit.type = 'submit';
		submit.value = 'Delete';
		submit.onclick = vqdNow;
		form.appendChild(submit);
 
		container = document.createElement('li');
		container.id = 'vqdContainer';
		container.appendChild(form);
 
		filetoc = document.getElementById('filetoc');
		if (filetoc) {
			filetoc.appendChild(container);
		}
//dfoplayer. allows pages with category footer to add
                cattoc = document.getElementById('catlinks');
		if (cattoc) {
			cattoc.appendChild(container);
		}
	}

//dfoplayer. 0 is main. 6 is files. 10 is templates. 14 is categories
	if ( mw.config.get( 'wgNamespaceNumber' ) >= 0  ) //Get anything above 0, or main
        {
		$( document ).ready( veryQuickDelete );
	}
 
}());