User:Writ Keeper/Scripts/syntaxChecker.js: Difference between revisions
< User:Writ Keeper | Scripts
Content deleted Content added
Writ Keeper (talk | contribs) fx |
Writ Keeper (talk | contribs) fx |
||
Line 8: | Line 8: | ||
if(synIndex > 0) |
if(synIndex > 0) |
||
{ |
{ |
||
$("#wpTextbox1") |
$("#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;
});
}
});