User:Writ Keeper/Scripts/syntaxChecker.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
fx
fx
Line 8: Line 8:
if(synIndex > 0)
if(synIndex > 0)
{
{
$("#wpTextbox1")[0].focus().prop({'selectionStart': synIndex+1, 'selectionEnd': synIndex+3})
$("#wpTextbox1").focus().prop({'selectionStart': synIndex+1, 'selectionEnd': synIndex+3})
return(confirm("Mismatched curly and square braces detected! Are you sure you want to save this edit?"));
return(confirm("Mismatched curly and square braces detected! Are you sure you want to save this edit?"));
}
}

Revision as of 17:08, 23 April 2024

$(document).ready(function()
{
	if((mw.config.get("wgAction") == "edit" || mw.config.get("wgAction") == "submit") && $("#editform").length > 0)
	{
		$("#editform").on("submit", function(event) 
		{
			var synIndex = $("#wpTextbox1").text().search(/[^\{\]](\{\[|\]\}|\[\{|\}\])/);
			if(synIndex > 0)
			{
				$("#wpTextbox1").focus().prop({'selectionStart': synIndex+1, 'selectionEnd': synIndex+3})
				return(confirm("Mismatched curly and square braces detected! Are you sure you want to save this edit?"));
			}
			return true;
		});
	}
});