Участник:Aleksandrit/summary-2.js

Материал из Википедии — свободной энциклопедии
/* На основе [[:pl:MediaWiki:Common-edit.js]] */

$(function()
{
	if (window.NoSummaryWarningDone)
		return;
 
	var button = document.getElementById('wpSave');
	if (button)
		button.onclick = FormValidation
	;
});
 
function FormValidation()
{
	var input_el = document.getElementById('wpSummary');
	var summary = input_el.value;
 
	// user has been warned
	if (input_el.warningSet)
		return true;
 
	// empty or nothing but section comment
	if (summary == '' || summary.substring(summary.indexOf('*/'))=='*/ ')
	{
		// ignore redirects - there is autosummary
		var wpTextbox1 = document.getElementById('wpTextbox1');
		if (wpTextbox1.value.match(/^#(?:REDIRECT|PRZEKIERUJ|TAM)/i))
			return true;
 
		// do not check titles of sections on non-talk pages
		if (mw.config.get('wgNamespaceNumber') % 2 == 0 && input_el.form.wpSection.value == 'new') 
			return true;
 
		// set warning, do not submit form
		input_el.warningSet = true;
		input_el.className = 'warning';
		document.getElementById('wpSummaryLabel').className = 'warning';
		return false;
	}	
	return true;
}