<commit_before>$(document).ready(function() {
  /* Functions */

  // Reset progress bar
  function resetProgress(){
    $('.progress-bar').css({ 'width': '0%', 'transition': 'none' });
    $('.progress-bar span').html('');
  }

  function updateProgress(current, max){
    // Calculate percent
    var percent = 100 / max * current;
    // Adjust width
    $('.progress-bar').css('width', Math.round(percent) + '%');
    $('.progress-bar span').html(current + ' / ' + max);
  }

  function countTableRows(){
    // Return the current amount of rows in our result table
    return $('.results tbody tr').length;
  }

  function updateListingBadge(){
    /* jshint ignore:start */
    var listings = $(".results tbody tr:contains('Listed')").length;
    if (listings > 0) {
      $('.label-listings').show();
      $('.label-listings').html(listings + ' listings');
    } else {
      $('.label-listings').hide();
    }
    /* jshint ignore:end */
  }

  // Enable general inputs
  function enableInputs(){
    $('.spinner').hide();
    $('.results').hide();
    $('.btn-cancel-check').hide();
    $('input#inputMailserverHost').prop('disabled', false);
    $('.btn-submit-check').prop('disabled', false);
  }

  // Disable general inputs
  function disableInputs(){
    $('.spinner').fadeIn();
    $('.results').show();
    $('.btn-cancel-check').show();
    $('input#inputMailserverHost').prop('disabled', true);
    $('.btn-submit-check').prop('disabled', true);
  }

  // Enable inputs on page load
  enableInputs();

  // Hide progress bar
  $('.progress').hide();

  // Initialize table sorter
  $('.results table').tablesorter();

  // Function to start the blacklist probes
  var startBlacklistProbes = function (hostToCheck, obj) {
    $('.results tbody').html('');
    resetProgress();
    $('.progress').show();
    $('.results').show();

    var requests = [];
    $.each(obj.blacklists, function(key, value) {
      var promise = $.get('api/?dnsbl=' + value + '&host=' + hostToCheck, function(data, status) {
        if (status === 'success') {
          var jsonProbe = $.parseJSON(data);
          if (jsonProbe.success === true) {
            if (jsonProbe.payload.result === 200) {
              console.log(hostToCheck + ': not listed on "' + jsonProbe.payload.dnsbl + '"');
              $('.results table > tbody').append('<tr><th scope="row">' + key + '</th><td>' + jsonProbe.payload.dnsbl + '</td><td>OK</td></tr>');
            } else if (jsonProbe.payload.result === 300) {
              console.log(hostToCheck + ': listed on "' + jsonProbe.payload.dnsbl + '"');
              $('.results table > tbody').append('<tr><th scope="row">' + key + '</th><td>' + jsonProbe.payload.dnsbl + '</td><td class="bg-danger">Listed</td></tr>');
            }
          } else {
            console.log('Error: ' + jsonProbe.error);
            $('.results table > tbody').append('<tr><th scope="row">' + key + '</th><td>' + value + '</td><td class="bg-danger">Error: ' + jsonProbe.error + '</td></tr>');
          }
          updateProgress(countTableRows(), obj.blacklists.length);
          updateListingBadge();
        }
      });

      $('.btn-cancel-check').on('click', function(e) {
        e.preventDefault();
        promise.abort();
        /* jshint ignore:start */
        delete requests;
        /* jshint ignore:end */
        resetProgress();
        enableInputs()
      });

      requests.push(promise);
    });

    // Enable stuff again, when all API calls are finished
    $.when.apply($, requests).done(function() {
      enableInputs();
      $('.results').show();
      $('.progress').fadeOut();
      $('.btn-submit-check').text('Check another'); // Adjust text of submit button
      $('.results table').trigger('update')
        .trigger('appendCache')
        .trigger('sorton',[ [ [ 2,0 ], [ 0,0 ] ] ]); // Sort table
    });
  }

  // Show RBL count in jumbotron
  $.getJSON('dnsbl.json', function(json) {
    var jsonObj = json;
    $('.a-tooltip').attr('data-original-title', 'Currently testing agaist ' + jsonObj.blacklists.length + ' RBLs.').tooltip();

    // Validate input form
    $('form.form-input').formValidation({
      framework: 'bootstrap'
      , icon: {
        valid: 'glyphicon glyphicon-ok'
        , invalid: 'glyphicon glyphicon-remove'
        , validating: 'glyphicon glyphicon-refresh'
      }
      , fields: {
        inputMailserverHost: {
          validators: {
            notEmpty: {
              message: 'The full name is required'
            }
          }
        }
      }
    }).on('success.form.fv', function(e) {
      // Prevent form submission
      e.preventDefault();

      // // instances, we can use at a later point
      // var $form = $(e.target) // The form instance
      // , fv    = $(e.target).data('formValidation'); // FormValidation instance

      // Disable inputs during the check
      disableInputs();
      // As well as prepare some other elements
      $('.alert-hint').hide();
      $('.btn-submit-check').text('Checking...');
      startBlacklistProbes($('input#inputMailserverHost').val(), jsonObj);
    });
  });
});
<commit_msg>Adjust progress bar label<commit_after>$(document).ready(function() {
  /* Functions */

  // Reset progress bar
  function resetProgress(){
    $('.progress-bar').css({ 'width': '0%', 'transition': 'none' });
    $('.progress-bar span').html('');
  }

  function updateProgress(current, max){
    // Calculate percent
    var percent = 100 / max * current;
    // Adjust width
    $('.progress-bar').css('width', Math.round(percent) + '%');
    $('.progress-bar span').html('RBL check ' + current + ' / ' + max);
  }

  function countTableRows(){
    // Return the current amount of rows in our result table
    return $('.results tbody tr').length;
  }

  function updateListingBadge(){
    /* jshint ignore:start */
    var listings = $(".results tbody tr:contains('Listed')").length;
    if (listings > 0) {
      $('.label-listings').show();
      $('.label-listings').html(listings + ' listings');
    } else {
      $('.label-listings').hide();
    }
    /* jshint ignore:end */
  }

  // Enable general inputs
  function enableInputs(){
    $('.spinner').hide();
    $('.results').hide();
    $('.btn-cancel-check').hide();
    $('input#inputMailserverHost').prop('disabled', false);
    $('.btn-submit-check').prop('disabled', false);
  }

  // Disable general inputs
  function disableInputs(){
    $('.spinner').fadeIn();
    $('.results').show();
    $('.btn-cancel-check').show();
    $('input#inputMailserverHost').prop('disabled', true);
    $('.btn-submit-check').prop('disabled', true);
  }

  // Enable inputs on page load
  enableInputs();

  // Hide progress bar
  $('.progress').hide();

  // Initialize table sorter
  $('.results table').tablesorter();

  // Function to start the blacklist probes
  var startBlacklistProbes = function (hostToCheck, obj) {
    $('.results tbody').html('');
    resetProgress();
    $('.progress').show();
    $('.results').show();

    var requests = [];
    $.each(obj.blacklists, function(key, value) {
      var promise = $.get('api/?dnsbl=' + value + '&host=' + hostToCheck, function(data, status) {
        if (status === 'success') {
          var jsonProbe = $.parseJSON(data);
          if (jsonProbe.success === true) {
            if (jsonProbe.payload.result === 200) {
              console.log(hostToCheck + ': not listed on "' + jsonProbe.payload.dnsbl + '"');
              $('.results table > tbody').append('<tr><th scope="row">' + key + '</th><td>' + jsonProbe.payload.dnsbl + '</td><td>OK</td></tr>');
            } else if (jsonProbe.payload.result === 300) {
              console.log(hostToCheck + ': listed on "' + jsonProbe.payload.dnsbl + '"');
              $('.results table > tbody').append('<tr><th scope="row">' + key + '</th><td>' + jsonProbe.payload.dnsbl + '</td><td class="bg-danger">Listed</td></tr>');
            }
          } else {
            console.log('Error: ' + jsonProbe.error);
            $('.results table > tbody').append('<tr><th scope="row">' + key + '</th><td>' + value + '</td><td class="bg-danger">Error: ' + jsonProbe.error + '</td></tr>');
          }
          updateProgress(countTableRows(), obj.blacklists.length);
          updateListingBadge();
        }
      });

      $('.btn-cancel-check').on('click', function(e) {
        e.preventDefault();
        promise.abort();
        /* jshint ignore:start */
        delete requests;
        /* jshint ignore:end */
        resetProgress();
        enableInputs()
      });

      requests.push(promise);
    });

    // Enable stuff again, when all API calls are finished
    $.when.apply($, requests).done(function() {
      enableInputs();
      $('.results').show();
      $('.progress').fadeOut();
      $('.btn-submit-check').text('Check another'); // Adjust text of submit button
      $('.results table').trigger('update')
        .trigger('appendCache')
        .trigger('sorton',[ [ [ 2,0 ], [ 0,0 ] ] ]); // Sort table
    });
  }

  // Show RBL count in jumbotron
  $.getJSON('dnsbl.json', function(json) {
    var jsonObj = json;
    $('.a-tooltip').attr('data-original-title', 'Currently testing agaist ' + jsonObj.blacklists.length + ' RBLs.').tooltip();

    // Validate input form
    $('form.form-input').formValidation({
      framework: 'bootstrap'
      , icon: {
        valid: 'glyphicon glyphicon-ok'
        , invalid: 'glyphicon glyphicon-remove'
        , validating: 'glyphicon glyphicon-refresh'
      }
      , fields: {
        inputMailserverHost: {
          validators: {
            notEmpty: {
              message: 'The full name is required'
            }
          }
        }
      }
    }).on('success.form.fv', function(e) {
      // Prevent form submission
      e.preventDefault();

      // // instances, we can use at a later point
      // var $form = $(e.target) // The form instance
      // , fv    = $(e.target).data('formValidation'); // FormValidation instance

      // Disable inputs during the check
      disableInputs();
      // As well as prepare some other elements
      $('.alert-hint').hide();
      $('.btn-submit-check').text('Checking...');
      startBlacklistProbes($('input#inputMailserverHost').val(), jsonObj);
    });
  });
});

{'fraction_non_alphanumeric': 0.19809948608552314, 'fraction_numerical': 0.002908949869097256, 'mean_word_length': 2.479757085020243, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '871971', 'n_tokens_mistral': 3143, 'n_tokens_neox': 3054, 'n_words': 641}