User:Juliancolton/usernames.js

In today's world, User:Juliancolton/usernames.js has become a topic of great relevance and interest to many people. Over time, User:Juliancolton/usernames.js has gained significant importance in various areas, generating debates, controversies, research and in-depth analysis. In this article, we will explore in detail the different aspects related to User:Juliancolton/usernames.js, analyzing its impact on society, its evolution over the years and its relevance in the current context. Through research and detailed examination of various sources, we seek to shed light on User:Juliancolton/usernames.js and provide the reader with a deep and enriching understanding of this highly relevant topic.
//Written by ]
importScript("User:Animum/formatresponse.js");

var warn = {
    "edit": 
        function(reason) {
            if(!reason) {
                document.getElementById("contentSub").innerHTML = "<br /><b>No reason was provided.</b>";
                return; //Abort if no reason was provided.
            }
            var req = sajax_init_object();
            req.open("POST", wgScriptPath + "/api.php", true);
            var postdata = "format=json"
                         + "&action=query"
                         + "&prop=info"
                         + "&intoken=edit" /* Request edit token from the API */
                         + "&titles=" + wgPageName;
            req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            req.setRequestHeader("Content-length", postdata.length);
            req.send(postdata);
            delete postdata;
            req.onreadystatechange = function() {
                if(req.status == 200 && req.readyState == 4) {
                    document.getElementById("content").style.backgroundColor = "#EFE"; //Change the document's background color
                    var info = formatResponse(eval("(" + req.responseText + ")")); //Format the response to make it usable
                    var postdata = "action=edit"
                                 + "&title=" + wgPageName
                                 + "&summary=" + encodeURIComponent("Notifying user of possible username violation.  Reason: " + reason + ".")
                                 + "&minor"
                                 + "&appendtext=" + encodeURIComponent("\n== Hello! ==\n\n\{\{uw-username\|" + reason + "\}\} \~\~\~\~")
                                 + "&token=" + encodeURIComponent(info.edittoken);
                    var req2 = sajax_init_object();
                    req2.open("POST", wgScriptPath + "/api.php", true);
                    req2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    req2.setRequestHeader("Content-length", postdata.length);
                    req2.send(postdata); //Submit the edit to the API
                    req2.onreadystatechange = function() {
                        if(req2.status == 200 && req2.readyState == 4) {
                            document.getElementById("content").style.backgroundColor = "#EEF"; //Change the document's background color
                            window.setTimeout(function() { location.href = location.href; }, 500); //Reload the page
                        }
                    }
                }
            }
        },
    "init":
        function() { 
            document.getElementById("contentSub").innerHTML = '<br /><table style="background-color: transparent; font-size: 10pt"><tr><td>Reason: </td><td><input type="text" id="wpWarnReason" /></td></tr><tr><td><input type="button" value="Submit" id="wpWarnSubmit" /></table>'; //Build the form
            document.getElementById("wpWarnSubmit").onclick = function() {
                var wpWarnReason = document.getElementById("wpWarnReason");
                document.getElementById("wpWarnSubmit").disabled = true;
                wpWarnReason.disabled = true;
                warn.edit(wpWarnReason.value); //Start the edit process
            }
        }
};
 
$(function() {
    if(wgNamespaceNumber == 3 && wgPageName.indexOf("/") == -1) mw.util.addPortletLink("p-cactions", "javascript:warn.init()", "uw-name", "ca-usernamewarning"); //Add the tab
});