User:Brunoy Anastasiya Seryozhenko/common.js

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// *****************************************************************
// Load various external scripts
// *****************************************************************
mw.loader.load('//www.wikia.com/index.php?title=User:Splarka/fastdelete.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.js&action=raw&ctype=text/javascript');

/***********************************************************************
                         EXTRA EDIT BUTTONS
***********************************************************************/
// Extra edit page buttons [[Wikipedia:Tools/Editing_tools#Misc._Editing_tools]]

// This is based on the original code on Wikipedia:Tools/Editing tools
//
// The original code was on the project page and needed to be cut and paste to the user's
// monobook.js page. However, this caused problems with the quote marks. So I have moved
// it to its own page.
//
// I do not know a lot about Javascript so please do not ask for a complicated change
//
// See the [[User:MarkS/Extra edit buttons]] for changes log
// <nowiki>
$(function InsertButtonsToToolBar() {
	d = new Date();
	todayISO = d.getFullYear()+"-";
	if (d.getMonth() > 8)
		todayISO += (d.getMonth()+1)+"-";
	else
		todayISO += "0"+(d.getMonth()+1)+"-";
	if (d.getDate() > 9)
		todayISO += d.getDate();
	else
		todayISO += "0"+d.getDate();

	if(mw.toolbar) {
		$('#wpTextbox1').wikiEditor('addToToolbar', {
			section: 'main',
			group: 'format',
			tools: {
				//Strike-Out Button
				'custom-Strike': {
					label: 'Strike',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<s>',
							post: '</s>',
							sampleText: 'Strike-through text'
						}
					}
				},

				//Table button
				'custom-Table': {
					label: 'Table',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '\n{| border=\'1\' \n|- \n| 1 || 2\n|- \n| 3 || 4',
							post: '\n|}\n',
							sampleText: ''
						}
					}
				},

				//Line break button
				'custom-Line break': {
					label: 'Line break',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<br />',
							post: '',
							sampleText: ''
						}
					}
				},

				//Gallery
				'custom-Insert a picture gallery': {
					label: 'Insert a picture gallery',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '\n<gallery>\n',
							post: '\n</gallery>',
							sampleText: 'Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2'
						}
					}
				},

				//Category button
				'custom-Category': {
					label: 'Category',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/5/5a/Button_category_alt.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '[[Category:',
							post: ']]',
							sampleText: 'Category title'
						}
					}
				},

				//Reference link button
				'custom-ref': {
					label: '<ref>',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<ref>',
							post: '</ref>',
							sampleText: 'Insert reference material'
						}
					}
				},

				//Reference button
				'custom-Reference footer': {
					label: 'Reference footer',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '==References==\n{{reflist}}',
							post: '',
							sampleText: ''
						}
					}
				},

				//ref+cite web
				'custom-Reference footer': {
					label: 'Reference footer',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/b/b8/Button_Globe.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '<ref>{{cite web|url=',
							post: '|title=|publisher=|accessdate=' + todayISO + '}}</ref>',
							sampleText: ''
						}
					}
				},

				//redirect
				'custom-Redirect': {
					label: 'Redirect',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '#REDIRECT [[',
							post: ']]',
							sampleText: ''
						}
					}
				},

				//welcome
				'custom-Welcome message': {
					label: 'Welcome message',
					type: 'button',
					icon: '//upload.wikimedia.org/wikipedia/commons/8/83/Button_biocitas.png',
					action: {
						type: 'encapsulate',
						options: {
							pre: '{{sub' + 'st:welcome}}',
							post: '',
							sampleText: ''
						}
					}
				}
			}
		});
	}
});
// </nowiki>

// *****************************************************************
// Custom automatic delete buttons
// *****************************************************************
// Adds customizable one-click deletion buttons to any deletable page.
// Requires w:User:Splarka/fastdelete.js in appendScript();
// <nowiki>
var fdButtons = [
	{
		'summary': '[[uncyclopedia:nobody cares|nobody cares]]',
		'label': 'UN:N'
	},
	{
		'summary': 'Test, please use the [[sandbox]]',
		'label': 'test'
	},
	{
		'summary': 'Please read [[About this site]]',
		'label': 'site'
	},
	{
		'summary': 'Author/User Request',
		'label': 'req'
	}
];
// </nowiki>

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:pathoschild/templatescript.js]]
 */
// <nowiki>
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	pathoschild.TemplateScript.add([
		{ name:'T', template:'{{subst:test|1=}}--~~~~', editSummary:'{{Test}}' },
		{ name:'encyc', template:'{{subst:not an encyclopedia|1=}}--~~~~', editSummary:'{{not an encyclopedia}}' },
		{ name:'non', template:'{{subst:nonsense|1=}}--~~~~', editSummary:'{{nonsense}}' },
		{ name:'Upload', template:'{{subst:upload warning}}--~~~~', editSummary:'{{uploadwarning}}' }
	]);
});
// </nowiki>