MediaWiki:User Rights Reasons Dropdown/code.js

$(document).ready(function {       if (mw.config.get("wgPageName").substr(0,19) == "Special:UserRights/" || mw.config.get("wgPageName") == "Special:UserRights") {                $("td.mw-input").load('/index.php?title=MediaWiki:Userrightsreason&action=raw&ctype=text/html', function { $("select#user-reason-dropdown").load("/index.php?title=MediaWiki:Userrightsreason/reasons&action=raw&ctype=text/plain", function {                               userReasonDropdownArray = $("select#user-reason-dropdown").text.substr(1).split("\n\*");                                for (var userReasonDropdownArrayI = 0; userReasonDropdownArrayI < userReasonDropdownArray.length; userReasonDropdownArrayI++) {										if (userReasonDropdownArray[userReasonDropdownArrayI].replace(/ /g,"").charAt(0) != "*") {											// this is a section											userReasonDropdownArray[userReasonDropdownArrayI] = '\' + userReasonDropdownArray[userReasonDropdownArrayI] + '\';										} else {											// this is a reason											userReasonDropdownArray[userReasonDropdownArrayI] = '\' + userReasonDropdownArray[userReasonDropdownArrayI].substr(1) + '\'; }                                       if (userReasonDropdownArrayI + 1 == userReasonDropdownArray.length) { $("select#user-reason-dropdown").html('Please select a reason \n' + userReasonDropdownArray); }                               }                        });                });                function promoteUserReason { if ($("input#user-reason-override").val.length > 0) { // reason given $("input#user-reason-override").attr("name","user-reason"); $("select#user-reason-dropdown").removeAttr("name"); } else if ($("select#user-reason-dropdown").val != "none_selected") { // no reason given & dropdown option selected $("select#user-reason-dropdown").attr("name","user-reason"); $("input#user-reason-override").removeAttr("name"); } else { // no reason given & no dropdown option selected $("input#user-reason-override").attr("name","user-reason"); $("select#user-reason-dropdown").removeAttr("name"); }               }                $('input[name="saveusergroups"]').mousedown(function {                        promoteUserReason;                }); } });