User:Quibik/vector.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// <nowiki>
// --- user information ---
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Anomie/useridentifier.js&action=raw&ctype=text/javascript'); // [[:en:User:Anomie/useridentifier.js]]
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Fran Rogers/dimorphism.js&action=raw&ctype=text/javascript'); // [[:en:User:Fran Rogers/dimorphism.js]]

mw.util.addPortletLink('p-tb', 'javascript:importScript("MediaWiki:VisualFileChange.js");', 'Perform batch task', 't-AjaxQuickDeleteOnDemand');

mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');

// --- files ---
// Adapted from https://commons.wikimedia.org/wiki/User:Perhelion/common.js
var ns = mw.config.get('wgNamespaceNumber'), //  global [[Bugzilla:33837]] <nowiki>
	ul = mw.config.get('wgUserLanguage'),
	pn = mw.config.get('wgPageName'),
	un = mw.config.get('wgUserName'),
	ac = mw.config.get('wgAction'),
	ti = mw.config.get('wgTitle'),
	convertToSVGTypes = "diagram, geology, meteorology, road sign",
	GlobalReplaceDefaultReason = '',
	AjaxDeleteExtraButtons = [];
if (ns === 6) { /** Files only **/
	var ext = ti.slice(-3).toUpperCase();
	var bSVG = ( ext.indexOf("SVG") === 0 );
	
	importScript('User:Perhelion/JustReplace+.js');
	importScript('User:Perhelion/cleanup.js'); // File desc. cleanup
	
	if ( bSVG ) { /** SVG only **/
		
		// simple SVG edit (beta)
		importScript('User:Rillke/SVGedit.js');
		
		// W3C-Validator check-link for every SVG (by [[User: Perhelion]] fixed also now for admins); + detailed byte-size
		importScript('User:Perhelion/simpleSVGcheck.js');
		
		AjaxDeleteExtraButtons.push({
			'label' : 'PoorSVG', // TracedSVG
			'tag' : '{{PoorSVG|1=%PARAMETER%}}', // Raster file
			'img_summary' : 'This SVG contains poor traced elements, please revectorize',
			'talk_tag' : '{{subst:TracedSVG/notify|1=%FILE%|2=%PARAMETER%}}',
			'talk_summary' : 'Poor SVG note',
			'prompt_text' : 'Which file is the original of?'
		}, {
			'label' : 'PoorSVG tag only', // TracedSVG
			'tag' : '{{PoorSVG|1=%PARAMETER%}}', // Raster file
			'img_summary' : 'This SVG contains poor traced elements, please revectorize',
			'prompt_text' : 'Which file is the original of?'
		}, {
			'label' : 'BadSVG',
			'tag' : '{{BadSVG}}',
			'img_summary' : 'This file contains raster graphics that should be removed',
			'talk_tag' : '{{subst:BadSVG/notification|1=%FILE%}}',
			'talk_summary' : 'Bad SVG note',
			'prompt_text' : 'Please remove embedded raster graphics?'
		}, {
			'label' : 'BadSVG tag only',
			'tag' : '{{BadSVG}}',
			'img_summary' : 'This file contains raster graphics that should be removed',
			'prompt_text' : 'Please remove embedded raster graphics?'
		}, {
			'label' : 'SVGbug', // SVGbug
			'tag' : '{{SVGbug|1=%PARAMETER%}}', // Raster file
			'img_summary' : 'This SVG contains one or more libRSVG bugs',
			'prompt_text' : 'Description of the bug or a link?'
		});
	} else {
		AjaxDeleteExtraButtons.push({
			'label' : 'CleanFFT',
			'tag' : '{{CleanFFT}}',
			'img_summary' : '{{CleanFFT}}',
		}, {
			'label' : 'ToSVG',
			'tag' : '{{Convert to SVG|1=%PARAMETER%}}',
			'img_summary' : 'This file should be better a SVG',
			'talk_tag' : '{{subst:Please use SVG|1=%FILE%}}',
			'talk_summary' : 'Use SVG note',
			'prompt_text' : 'Please use SVG insteed of raster graphics. Which type?'
		}, {
			'label' : 'ToSVG tag only ',
			'tag' : '{{Convert to SVG|1=%PARAMETER%}}',
			'img_summary' : 'This file should be better a SVG',
			'prompt_text' : 'Please use SVG insteed of raster graphics. Which type?'
		});
		GlobalReplaceDefaultReason = ext + ' → SVG';
	}
	
	// [[Help:QuickDelete]]
	//To watch user talk pages, to which you add tags
	var AjaxDeleteWatchUserTalk = true;
	//To watch file pages, to which you add tags
	var AjaxDeleteWatchFile = true;
	// adding more buttons :
	AjaxDeleteExtraButtons.push({
		'label' : 'DW No Source',
		'tag' : '{{subst:dw-nsd}}',
		'img_summary' : 'This is a [[COM:DW|derivative work]] and no source is provided',
		'talk_tag' : '{{subst:dw image source|1=%FILE%}}',
		'talk_summary' : 'Original source is missing for %FILE%'
	}, 
	{ //notice talk_tag and talk_summary must be '' (void string) if uploader must not be notified
		'label' : 'Speedy',
		'tag' : '{{Speedydelete|1=%PARAMETER%}}',
		'img_summary' : 'Tagging as speedy delete because: %PARAMETER%',
		'talk_tag' : '{{subst:Speedynote|1=%FILE%|2=%PARAMETER%}}',
		'talk_summary' : 'Speedy notification',
		'prompt_text' : 'Speedy: why ? MUST PREVENT UPLOADER'
	}, {
		'label' : 'Wrong License',
		'tag' : '{{wl|1=%PARAMETER%}}',
		'img_summary' : 'Tagging as wrongly licensed because: %PARAMETER%',
		'talk_tag' : '{{subst:Wrong license note|2=%PARAMETER%|1=%FILE%}}',
		'talk_summary' : 'Notification of possible wrong license',
		'prompt_text' : 'Incorrect license: reason?'
	}, {
		'label' : 'Thumbnail',
		'tag' : '{{Thumbnail}}',
		'img_summary' : 'Tagging as thumbnail',
		'talk_tag' : '{{subst:Do not upload thumbnails|1=%FILE%}}',
		'talk_summary' : 'Thumb note',
		'prompt_text' : 'Please re-upload the full resolution version?'
	}, {
		'label' : 'Watermark',
		'tag' : '{{Watermark|1=}}',
		'img_summary' : 'This file contains a watermark that should be removed',
	}, {
		'label' : 'Watermark with notice',
		'tag' : '{{Watermark|1=}}',
		'img_summary' : 'This file contains a watermark that should be removed',
		'talk_tag' : '{{subst:No watermarks|1=:%FILE%}}',
		'talk_summary' : 'Watermarks note',
	});
	// [[MediaWiki:Gadget-AjaxQuickDelete.js]]

	importScript('User:Sreejithk2000/JustReplace.js');

	// make editing and adding descriptions easier
	importScript('User:MarkTraceur/editDescriptions.js');
} /** Files only end **/


(function($, mw) {
'use strict';

if (!window.AjaxQuickDelete) return;
var AQD = AjaxQuickDelete;

AQD.doInsertTagButtons = function() {

   var runInsert = function(buttons) {
      $.each(buttons, function(k, v) {
         mw.util.addPortletLink('p-tb', 'javascript:AjaxQuickDelete.insertTagOnPage("' + v.tag + '","' + v.img_summary + '","' + v.talk_tag + '","' + v.talk_summary + '","' + v.prompt_text + '");', v.label);
      });
   };

   if (6 === mw.config.get('wgNamespaceNumber')) {
      // Merge the user defined buttons ([[Help:AjaxQuickDelete]]) into the optional buttons
      if (window.AjaxDeleteExtraButtons) AQD.insertTagButtons = AQD.insertTagButtons.concat(window.AjaxDeleteExtraButtons);
      runInsert(AQD.insertTagButtons);
   }

   $(document).bind('AjaxQuickDeleteExtraButtonsReady', function() {
      runInsert(window.AjaxDeleteExtraButtons);
   });
};
})(jQuery, mediaWiki);

// </nowiki>