<commit_before>(function (doc) {
    var passwordInput = doc.getElementById("password-box"),
        timeDiv = doc.getElementById("password-time"),
        checksList = doc.getElementById("password-checks");
    var passwordplain;

    // Code to render the time returned by HSIMP
    var renderTime = function (time, input) {
        timeDiv.innerHTML = time || "";
    };

    // Code to output the checks returned by HSIMP
    var renderChecks = function (checks, input) {
        checksList.innerHTML = "";

        for (var i = 0, l = checks.length; i < l; i++) {
            var li = doc.createElement("li"),
                title = doc.createElement("h2"),
                message = doc.createElement("p");

            title.innerHTML = checks[i].name;
            li.appendChild(title);

            message.innerHTML = checks[i].message;
            li.appendChild(message);

            checksList.appendChild(li);
        }
    };

    // Setup the HSIMP object
    var attachTo = hsimp({
        options: {
            calculationsPerSecond: 10e9, // 10 billion calculations per second
            good: 31557600e9, // 1 billion years
            ok: 31557600e3 // 1 thousand years
        },
        outputTime: renderTime,
        outputChecks: renderChecks
    });

    // setup custom values for "instantly"/"forever"
    hsimp.setDictionary({
        "instantly": "Immediately",
        "forever": "Aaaaaaaaaaaaaaaages",
    });

    // Run the HSIMP
    attachTo(passwordInput);


}(this.document));


var passwordInput = document.getElementById("password-box")
var passwordplain = '';
var lastpasschecked = '';
var lastrequestfinished = true;
window.setInterval(function(){
  passwordplain = passwordInput.value;
  if ((lastpasschecked !== passwordplain) && lastrequestfinished) {

    if (passwordplain !== '') {

      var sha1pass = SHA1(passwordplain);
      sha1pass = sha1pass.toUpperCase();
      var subsha1pass = sha1pass.substring(5);
      lastrequestfinished = false;
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          lastrequestfinished = true;
          var xhttpresponse = this.responseText;
          if (xhttpresponse.indexOf(subsha1pass) !== -1) {

            var passlist = xhttpresponse.split("\n");
            var pwnedcount = 0;
            var timespell = 'times';
            for (var i = 0; i < passlist.length; i++) {
              if (subsha1pass == passlist[i].split(":")[0]) {
                pwnedcount = passlist[i].split(":")[1];
                if (passlist[i].split(":")[1] == 1){ timespell = "time"; }
              }
            }

            document.getElementById("iscompromised").innerHTML = '<span style="color: #ff0000;">Oh no! This password was found <b>'+ pwnedcount + '</b> '+ timespell + ' in compromised passwords databases! If this is your password, you should change it immediately. Using a password that has been breached is extremely dangerous. <h4>If you are using this password on multiple websites, you should take the opportunity to start using different passwords for every website. Attackers can take the advantage of password reuse by automating login attempts on your account using breached emails and password pairs.</h4></span>';
          }else {
            lastrequestfinished = true;
            document.getElementById("iscompromised").innerHTML = '<span style="color: #339966;">Good news, this password has never been breached!</span>';
          }
        }else {
          if (this.status == 404) {
            document.getElementById("iscompromised").innerHTML = '<span style="color: #ff0000;">This password can\'t be verified right now...</span>';
          }
        }
      };

      xhttp.open('GET', 'https://api.pwnedpasswords.com/range/' + sha1pass.substring(0, 5));
      xhttp.send();
    }
    lastpasschecked = passwordplain;
  }

}, 2000);

function passwordmodified() {
  var modifiedpassword = passwordInput.value;
  if (modifiedpassword !== passwordplain) {
    document.getElementById("iscompromised").innerHTML = '<span style="color: #ff9900;"><img src="img/loading.gif" alt="" width="25" height="25" />&nbsp;We are checking if your password has ever been compromised...</span>';
  }
}


/**
*
*  Secure Hash Algorithm (SHA1)
*  http://www.webtoolkit.info/
*
**/
function SHA1 (msg) {<commit_msg>Make sure requests are made in order<commit_after>(function (doc) {
    var passwordInput = doc.getElementById("password-box"),
        timeDiv = doc.getElementById("password-time"),
        checksList = doc.getElementById("password-checks");
    var passwordplain;

    // Code to render the time returned by HSIMP
    var renderTime = function (time, input) {
        timeDiv.innerHTML = time || "";
    };

    // Code to output the checks returned by HSIMP
    var renderChecks = function (checks, input) {
        checksList.innerHTML = "";

        for (var i = 0, l = checks.length; i < l; i++) {
            var li = doc.createElement("li"),
                title = doc.createElement("h2"),
                message = doc.createElement("p");

            title.innerHTML = checks[i].name;
            li.appendChild(title);

            message.innerHTML = checks[i].message;
            li.appendChild(message);

            checksList.appendChild(li);
        }
    };

    // Setup the HSIMP object
    var attachTo = hsimp({
        options: {
            calculationsPerSecond: 10e9, // 10 billion calculations per second
            good: 31557600e9, // 1 billion years
            ok: 31557600e3 // 1 thousand years
        },
        outputTime: renderTime,
        outputChecks: renderChecks
    });

    // setup custom values for "instantly"/"forever"
    hsimp.setDictionary({
        "instantly": "Immediately",
        "forever": "Aaaaaaaaaaaaaaaages",
    });

    // Run the HSIMP
    attachTo(passwordInput);


}(this.document));


var passwordInput = document.getElementById("password-box")
var passwordplain = '';
var lastpasschecked = '';
var lastrequestfinished = true;
window.setInterval(function(){
  passwordplain = passwordInput.value;
  if ((lastpasschecked !== passwordplain) && lastrequestfinished) {

    if (passwordplain !== '') {

      var sha1pass = <PASSWORD>1(passwordplain);
      sha1pass = sha1pass.<PASSWORD>();
      var subsha1pass = sha1pass.substring(5);
      lastrequestfinished = false;
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          lastrequestfinished = true;
          var xhttpresponse = this.responseText;
          if (xhttpresponse.indexOf(subsha1pass) !== -1) {

            var passlist = xhttpresponse.split("\n");
            var pwnedcount = 0;
            var timespell = 'times';
            for (var i = 0; i < passlist.length; i++) {
              if (subsha1pass == passlist[i].split(":")[0]) {
                pwnedcount = passlist[i].split(":")[1];
                if (passlist[i].split(":")[1] == 1){ timespell = "time"; }
              }
            }

            document.getElementById("iscompromised").innerHTML = '<span style="color: #ff0000;">Oh no! This password was found <b>'+ pwnedcount + '</b> '+ timespell + ' in compromised passwords databases! If this is your password, you should change it immediately. Using a password that has been breached is extremely dangerous. <h4>If you are using this password on multiple websites, you should take the opportunity to start using different passwords for every website. Attackers can take the advantage of password reuse by automating login attempts on your account using breached emails and password pairs.</h4></span>';
          }else {
            lastrequestfinished = true;
            document.getElementById("iscompromised").innerHTML = '<span style="color: #339966;">Good news, this password has never been breached!</span>';
          }
        }else {
          if (this.readyState == 4) {
            lastrequestfinished = true;
            document.getElementById("iscompromised").innerHTML = '<span style="color: #ff0000;">This password can\'t be verified right now...</span>';
          }
        }
      };

      xhttp.open('GET', 'https://api.pwnedpasswords.com/range/' + sha1pass.substring(0, 5));
      xhttp.send();
    }
    lastpasschecked = passwordplain;
  }

}, 2000);

function passwordmodified() {
  var modifiedpassword = passwordInput.value;
  if (modifiedpassword !== passwordplain) {
    document.getElementById("iscompromised").innerHTML = '<span style="color: #ff9900;"><img src="img/loading.gif" alt="" width="25" height="25" />&nbsp;We are checking if your password has ever been compromised...</span>';
  }
}


/**
*
*  Secure Hash Algorithm (SHA1)
*  http://www.webtoolkit.info/
*
**/
function SHA1 (msg) {
{'fraction_non_alphanumeric': 0.12956922730851422, 'fraction_numerical': 0.018445619165448207, 'mean_word_length': 2.626427406199021, 'pattern_counts': {'":': 10, '<': 35, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5119138', 'n_tokens_mistral': 2566, 'n_tokens_neox': 2393, 'n_words': 670}