<commit_before>var API_URL = '127.0.0.1:8000/backend'
//var API_URL = '192.168.10.1'

function get_id(search_term) {
    var regex = new RegExp('\\?' + search_term + '=');
    var parser = document.createElement('a');
    parser.href = window.location.href;
    // Take the 'search' part of the URL (the keyword arguments) and get rid of everything except the ID.
    // Then delete the trailing slash in case one is inserted by the browser
    return parser.search.replace(regex, '').replace('/', '');
}

function beep(){
    // lets the user know that a step finished or the program is over
    var audio = new Audio('../smb_coin.wav');
    audio.play();
}

function to_hhmmss(seconds) {
    if (seconds === null || seconds === undefined) {
        return "---";
    }
    seconds = parseInt(seconds, 10);
    var hours = Math.floor(seconds / 3600);
    var minutes = Math.floor((seconds - (hours * 3600)) / 60);
    var seconds = seconds - (hours * 3600) - (minutes * 60);
    var result = "";
    // only use HH:MM:SS if total time is less than 60 minutes
    if (hours) {
        result += hours + ":"
    }
    // only show leading zero in minute column if we have an hour preceding it
    result += ((minutes < 10 && hours) ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
    return result;
}

function http(endpoint, verb, d, func){
    $.ajax({
      type: verb,
      crossDomain: true,
      url: "http://" + API_URL + "/" + endpoint,
      contentType: "application/json; charset=utf-8",
      data: JSON.stringify(d),
      dataType: "json",
      success: function(return_data){
          func(return_data);
      },
      failure: function(return_data) {
        alert("The API could not be reached.");
      },
    });
    if (verb == "POST") {
        return false;
    }
}
<commit_msg>#134 JS comments<commit_after>var API_URL = '127.0.0.1:8000/backend'
//var API_URL = '192.168.10.1'

function get_id(search_term) {
    var regex = new RegExp('\\?' + search_term + '=');
    var parser = document.createElement('a');
    parser.href = window.location.href;
    // Take the 'search' part of the URL (the keyword arguments) and get rid of everything except the ID.
    // Then delete the trailing slash in case one is inserted by the browser
    return parser.search.replace(regex, '').replace('/', '');
}

function beep(){
    // lets the user know that a step finished or the program is over
    var audio = new Audio('../smb_coin.wav');
    audio.play();
}

function to_hhmmss(seconds) {
    if (seconds === null || seconds === undefined) {
        return "---";
    }
    seconds = parseInt(seconds, 10);
    var hours = Math.floor(seconds / 3600);
    var minutes = Math.floor((seconds - (hours * 3600)) / 60);
    var seconds = seconds - (hours * 3600) - (minutes * 60);
    var result = "";
    // only use HH:MM:SS if total time is less than 60 minutes
    if (hours) {
        result += hours + ":"
    }
    // only show leading zero in minute column if we have an hour preceding it
    result += ((minutes < 10 && hours) ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
    return result;
}

function http(endpoint, verb, d, func){
    // verb is an HTTP verb.
    // d is the data, which may be null.
    // func is a function to execute using the *return* data as an argument. usually this is an anonymous function.

    $.ajax({
      type: verb,
      crossDomain: true,
      url: "http://" + API_URL + "/" + endpoint,
      contentType: "application/json; charset=utf-8",
      data: JSON.stringify(d),
      dataType: "json",
      success: function(return_data){
          func(return_data);
      },
      failure: function(return_data) {
        alert("The API could not be reached.");
      },
    });
    if (verb == "POST") {
        // necessary for some stupid reason I forget. Don't remove this.
        return false;
    }
}

{'fraction_non_alphanumeric': 0.14591291061879297, 'fraction_numerical': 0.024191494779730073, 'mean_word_length': 2.526032315978456, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '4694870', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1185, 'n_words': 408}