User:1234qwer1234qwer4/warnings.js

Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
  • Konqueror: simply click the Reload button, or press F5;
  • Opera users may need to completely clear their cache in Tools→Preferences.
//Warning: Does not work with syntax highlighting
//Fork of [[ru:Участник:OneLittleMouse/warnings.js]]
//Автор исходного скрипта - DerLetzteRegenbogen
( function () {
function warnbuttons() {
	if (!$('#warnbuttonselect').length) {
		$('<div id="warnbuttonselect">').append([
			$('<input type="button" value="Vandalism" />').click(qwarnVandalism)[0],
			$('<input type="button" value="Spam" />').click(qwarnSpam)[0],
			$('<input type="button" value="Spam page" />').click(qwarnSpamPage)[0],
			$('<input type="button" value="Test" />').click(qwarnTest)[0],
			$('<input type="button" value="TestAnon" />').click(qwarnTestAnon)[0],
			$('<input type="button" value="Blanking" />').click(qwarnBlanking)[0],
			$('<input type="button" value="Please stop" />').click(qwarnStop)[0],
			$('<input type="button" value="Blocked" />').click(qwarnBlocked)[0],
			$('<input type="button" value="NPOV" />').click(qwarnNPOV)[0],
			$('<input type="button" value="Facts" />').click(qwarnFacts)[0],
			$('<input type="button" value="Use categories" />').click(qwarnUseCategories)[0],
			$('<input type="button" value="Use talk page" />').click(qwarnUseTalk)[0],
			$('<input type="button" value="Use edit summary" />').click(qwarnUseEditSum)[0],
			$('<input type="button" value="Welcome" />').click(qwarnWelcome)[0],
			$('<input type="button" value="Welcome-copyright" />').click(qwarnWelcomeCopyright)[0]
		]).prependTo($('#editform'));
	} else {
		$('#warnbuttonselect').toggle();
	}
}
 
function hideInitialWarnbuttonselect() {
	document.getElementById('warnbuttonselect').style.display = 'none';
}
 
function postWarn(sumString, warnString) {
	var text = document.getElementById('wpTextbox1');
	text.value += warnString+'\n';
	var minorcb = document.getElementById('wpMinoredit');
	if (minorcb && minorcb.checked) minorcb.checked = false;
        var section = document.getElementsByName('wpSection')[0];
	var sum = document.getElementById('wpSummary');
	if (sum && (section.value != "new")) sum.value = sumString + ' (using [[User:1234qwer1234qwer4/warnings.js|warnings.js]])';
}
 
function qwarnVandalism() {
	postWarn('Warning: Blatant vandalism', '\n== Vandalism ==\n\{\{subst:Blatantvandal|1=\~\~\~\~\}\}');
}
 
function qwarnSpam() {
	postWarn('Warning: Spamming or promotional content', '\n== Spamming or promotion ==\n\{\{subst:spam|1=\~\~\~\~\}\}');
}

function qwarnSpamPage() {
	postWarn('Warning: Promotional page', '\n== Spamming or promotion ==\n\{\{subst:spam page|1=\~\~\~\~\}\}');
}

function qwarnTest() {
	postWarn('Warning: Please use the [[Wikibooks:Sandbox|sandbox]] for testing', '\n== Editing tests ==\n\{\{subst:test|1=\~\~\~\~\}\}');
}

function qwarnTestAnon() {
	postWarn('Warning: Please use the [[Wikibooks:Sandbox|sandbox]] for testing', '\n== Editing tests ==\n\{\{subst:TestAnon|1=\~\~\~\~\}\}');
}

function qwarnBlanking() {
	postWarn('Warning: Do not blank pages', '\n== Blanking ==\n\{\{subst:Blanking|1=\~\~\~\~\}\}');
}

function qwarnStop() {
	postWarn('Warning: Please contribute constructively', '\n== Vandalism ==\n\{\{subst:Please stop|2=\~\~\~\~\}\}');
}

function qwarnBlocked() {
	postWarn('You have been blocked from editing Wikibooks', '\n== Blocked ==\n\{\{subst:blocked|time=|reason=|sig=yes\}\}');
}

function qwarnNPOV() {
	postWarn('Warning: Please maintain a neutral point of view', '\n== Neutral point of view ==\n\{\{subst:NPOV note|1=\~\~\~\~\}\}');
}

function qwarnFacts() {
	postWarn('Warning: Please only introduce factual information', '\n== Factual information ==\n\{\{subst:Please facts|1=\~\~\~\~\}\}');
}

function qwarnUseCategories() {
	postWarn('Warning: Please use categories', '\n== Using categories ==\n\{\{subst:Use categories|1=\~\~\~\~\}\}');
}

function qwarnUseTalk() {
	postWarn('Warning: Please use the talk page', '\n== Talk pages ==\n\{\{subst:Use talk page|2=\~\~\~\~\}\}');
}

function qwarnUseEditSum() {
	postWarn('Warning: Please use edit summaries', '\n== Edit summaries ==\n\{\{subst:Edit summary|1=\~\~\~\~\}\}');
}

function qwarnWelcome() {
	postWarn('Welcome!', '\n== Welcome ==\n\{\{subst:welcome\}\} \~\~\~\~');
}

function qwarnWelcomeCopyright() {
	postWarn('Welcome! Please respect copyrights.', '\n== Welcome ==\n\{\{subst:welcome-copyright\}\} \~\~\~\~');
}

var customizeToolbar = function () {
/*start*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'main',
        'group': 'insert',
	'tools': {
		'warnbuttons': {
			label: 'Warnings', // or use labelMsg for a localized label, see above
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/6/6d/Button_exclamation_1.png',
			filters: [ 'body.ns-3' ],
			action: {
				type: 'callback',
				execute: function(context){
					warnbuttons();
				}
			}
		}
	}
} );

/*end*/
};


if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
			if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
}() );