<commit_before>
//Ajax processing
(function() {
    if (!window.cng) {
        window.cng = {};
    }

    /**
     * Processes request.
     * @var method {String}
     * @var url {String}
     * @var callback {Function}
     */
    function request(method, url, callback) {
      var xhttp = new XMLHttpRequest();
      xhttp.open(method, url, true);

      xhttp.onreadystatechange = function(e) {
        if (this.readyState === 4 && this.status === 200) {
          callback(this);
        }
      };
      xhttp.send();
    }

    /**
     * Serializes form.
     * @var {Node}
     */
    function serialize(form) {
        if (!form || form.nodeName !== "FORM") {
            return;
        }
        var i, q = [];
        for (i = form.elements.length - 1; i >= 0; i = i - 1) {
            if (form.elements[i].name === "") {
                continue;
            }
            q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
        }
        return q.join("&");
    }
    
    /**
     * Takes a form node and sends it over AJAX.
     * @param {HTMLFormElement} form - Form node to send
     * @param {function} callback - Function to handle onload.
     *                              this variable will be bound correctly.
     */
    function submit (form) {
      function validate(xhttp) {
        var response = JSON.parse(xhttp.response);
        if (response.email) {
          document.getElementById("email").style.borderColor = "red";
        }
        if (response.password) {
          document.getElementById("password").style.borderColor = "red";
        }
      }

      var xhttp = new XMLHttpRequest();
      xhttp.open("POST", form.action, true);
      xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

      xhttp.onreadystatechange = function(e) {
        if (this.readyState === 4) {
          validate(xhttp);
        }
      }
      xhttp.send(serialize(form));
    }
<commit_msg>Code style improvements.<commit_after>
//Ajax processing
(function() {
    if (!window.cng) {
        window.cng = {};
    }

    /**
     * Processes request.
     * @var method {String}
     * @var url {String}
     * @var callback {Function}
     */
    function request(method, url, callback) {
      var xhttp = new XMLHttpRequest();
      xhttp.open(method, url, true);

      xhttp.onreadystatechange = function(e) {
        if (this.readyState === 4 && this.status === 200) {
          callback(this);
        }
      };
      xhttp.send();
    }

    /**
     * Serializes form.
     * @var {Node}
     */
    function serialize(form) {
        var q = [];
        for (var i = 0; i < form.elements.length; i++) {
            q.push(form.elements[i].name + "=" + encodeURIComponent(form.elements[i].value));
        }
        return q.join("&");
    }

    /**
     * Takes a form node and sends it over AJAX.
     * @param {HTMLFormElement} form - Form node to send
     * @param {function} callback - Function to handle onload.
     *                              this variable will be bound correctly.
     */
    function submit (form) {
      function validate(xhttp) {
        var response = JSON.parse(xhttp.response);
        if (response.email) {
          document.getElementById("email").style.borderColor = "red";
        }
        if (response.password) {
          document.getElementById("password").style.borderColor = "red";
        }
      }

      var xhttp = new XMLHttpRequest();
      xhttp.open("POST", form.action, true);
      xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

      xhttp.onreadystatechange = function(e) {
        if (this.readyState === 4) {
          validate(xhttp);
        }
      }
      xhttp.send(serialize(form));
    }

{'fraction_non_alphanumeric': 0.14361140443505807, 'fraction_numerical': 0.003695881731784583, 'mean_word_length': 1.8297236743838685, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1759241', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1120, 'n_words': 249}