<commit_before>/*
 * LocalStore key => "gh_search_text"
 *
 * FORMAT
 *      "gh_search_text" : {
 *          "text_search" : {
 *              "value" :  "SEARCH_STRING",
 *              "matches" : [ "FILENAME", "FILENAME" ]
 *          }
 *      }
 *
 * */



window.addEventListener ("load", main, false);

// global variable used to loop on focus elements
var current_focus_index = 0;
var total_matches = 0;

function first_focus()
{
    if (total_matches == 0)
        return;

    var id_name = "gh_ext_match_0";

    document.getElementById(id_name).focus();
}


function update_focus_infos()
{

    var span_infos = document.getElementById("focus_infos");
    var text = "[" + (current_focus_index + 1 ) + "/" + total_matches + "]";
    span_infos.innerHTML = text;
}

function go_to_prev_focus()
{

    if (total_matches == 0)
        return;

    var tmp_index = current_focus_index - 1;

    if (tmp_index < 0) {
        tmp_index = total_matches - 1;
    }

    current_focus_index = tmp_index;

    var id_name = "gh_ext_match_" + current_focus_index;

    document.getElementById(id_name).focus();
    update_focus_infos();
}


function go_to_next_focus()
{

    if (total_matches == 0)
        return;

    var tmp_index = current_focus_index + 1;
    if (tmp_index > (total_matches - 1))
        tmp_index = 0;

    current_focus_index = tmp_index;

    var id_name = "gh_ext_match_" + current_focus_index;

    document.getElementById(id_name).focus();
    update_focus_infos();

}

function focus_keyUp(e) {


    if (navigator.appVersion.indexOf("Mac")!=-1)
    {
        // on MAC use j.k like Vi
        // j   move down one line
        // k   move up one line
        // command  + k
        if (e.metaKey && (e.keyCode == 75)) {
            go_to_next_focus();
        }
        // command + j
        if (e.metaKey && (e.keyCode == 74)) {
            go_to_prev_focus();
        }

    } else {

        // ctrl + arrow_right
        if (e.ctrlKey && (e.keyCode == 39)) {
            go_to_next_focus();
        }
        // ctrl + arrow_left
        if (e.ctrlKey && (e.keyCode == 37)) {
            go_to_prev_focus();
        }

    }

}

document.addEventListener('keyup', focus_keyUp, false);
<commit_msg>use shift key for MAC user<commit_after>/*
 * LocalStore key => "gh_search_text"
 *
 * FORMAT
 *      "gh_search_text" : {
 *          "text_search" : {
 *              "value" :  "SEARCH_STRING",
 *              "matches" : [ "FILENAME", "FILENAME" ]
 *          }
 *      }
 *
 * */



window.addEventListener ("load", main, false);

// global variable used to loop on focus elements
var current_focus_index = 0;
var total_matches = 0;

function first_focus()
{
    if (total_matches == 0)
        return;

    var id_name = "gh_ext_match_0";

    document.getElementById(id_name).focus();
}


function update_focus_infos()
{

    var span_infos = document.getElementById("focus_infos");
    var text = "[" + (current_focus_index + 1 ) + "/" + total_matches + "]";
    span_infos.innerHTML = text;
}

function go_to_prev_focus()
{

    if (total_matches == 0)
        return;

    var tmp_index = current_focus_index - 1;

    if (tmp_index < 0) {
        tmp_index = total_matches - 1;
    }

    current_focus_index = tmp_index;

    var id_name = "gh_ext_match_" + current_focus_index;

    document.getElementById(id_name).focus();
    update_focus_infos();
}


function go_to_next_focus()
{

    if (total_matches == 0)
        return;

    var tmp_index = current_focus_index + 1;
    if (tmp_index > (total_matches - 1))
        tmp_index = 0;

    current_focus_index = tmp_index;

    var id_name = "gh_ext_match_" + current_focus_index;

    document.getElementById(id_name).focus();
    update_focus_infos();

}

function focus_keyUp(e) {

    /*  MAC:
     *
     *  Next  shift + arrow right
     *  Prev  shift + arrow left
     *
     *  Othres:
     *
     *  Next  ctrl + arrow right
     *  Prev  ctrl + arrow left
     *
     * */
    if (navigator.appVersion.indexOf("Mac")!=-1)
    {

        // on MAC we're using shift instead of ctrl
        if (e.shiftKey && (e.which == 39)) {
            go_to_next_focus();
        }
        if (e.shiftKey && (e.wchich == 37)) {
            go_to_prev_focus();
        }

    } else {

        if (e.ctrlKey && (e.keyCode == 39)) {
            go_to_next_focus();
        }
        if (e.ctrlKey && (e.keyCode == 37)) {
            go_to_prev_focus();
        }

    }

}

document.addEventListener('keyup', focus_keyUp, false);

{'fraction_non_alphanumeric': 0.1307131817178185, 'fraction_numerical': 0.009715168911459484, 'mean_word_length': 2.1634078212290504, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2161284', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1521, 'n_words': 311}