User:Tamzin/AN3 report.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// In the spirit of [[MediaWiki:Gadget-DRN-wizard.js]] and [[User:Timotheus_Canens/SPIW.js]], from which this is adapted. I'm pretty much
// clueless with javascript, and the framework of this script is the intelectual property of the contributors listed at those scripts' history
// pages.

/**
 * This is the main object that holds the state for everything
 */
function AN3W() {

    //Keep track of what step we are on
    this.wizard_step = 0;

    //User(s) being reported
    this.user = '';

    //Locus of edit war
    this.page = '';

    //Diff of user being warned
    this.warning = '';

    //blah blah blah... fill in rest later... I get the idea

    //User
    this.drawUserInput = function() {
        //Appends to $("#AN3WContent1")

        $("#AN3WContent1").append("<h3>User(s)</h3>");
        $("#AN3WContent1").append("<p>The user(s) who you are reporting. If you are reporting more than one user, separate their names with commas." +
            "Enter the username or usernames only, without the \"User:\" prefix. </p>");

        var inputbox = $( document.createElement('input') );
        inputbox.attr({
            type: "text",
            name: "User",
            value: this.user
        }};

        inputbox.change( function() { gAN3W.user = this.value.replace("https://", "http://").replace("http://en.wikipedia.org/wiki/", "").replace("_", " ").replace("[[", '').replace("]]", '').replace("User:", ''); } )

        $("AN3WContent1").append( inputbox );
    }

    //Page
    this.drawPageInput = function() {
        //Appends to $("#AN3WContent1")

        $("#AN3WContent1").append("<h3>Page</h3>");
        $("#AN3WContent1").append("<p>The page at which the edit war has occurred.</p>");

        var inputbox = $( document.createElement('input') );
        inputbox.attr({
            type: "text",
            name: "Page",
            value: this.page
        }};

        inputbox.change( function() { gAN3W.page = this.value; } );

        ${"#AN3WContent1").append( inputbox );