<commit_before>var dictionaryFileId = null;
var mainContainer = "#content";
var filesContainer = "#files";
var dictionary = [];

$(document).ready(function () {
    var mode = {};
    $("#nextBtn").css("visibility", "hidden");
    $("#prevBtn").css("visibility", "hidden");

    $("#learnBtn").bind("click", function() {
        learnDictionary();
    });
    $("#examineBtn").bind("click", function() {
        examineDictionary();
    });
});

function startApp() {
    if (!dictionaryFileId) {
        $(filesContainer).css("display", "block");
        $(mainContainer).css("display", "none");
        list().then(function (res) {
            var files = $(filesContainer + " .body");
            for (var i = 0; i < res.items.length; i++) {
                var item = res.items[i]
                var actor = $(document.createElement("a"));
                actor.attr("href", "JavaScript:void(0)");
                actor.attr("class", "list-group-item");
                actor.bind("click", item.id, function (evt) {
                    setFile(evt.data);
                });
                actor.text(item.title);

                files.append(actor);
            }
        });
    }
}

function setFile(id) {
    dictionaryFileId = id;

    readDictionary();
}


function readDictionary() {
    getFile(dictionaryFileId).then(function (res) {
        downloadFile(res.exportLinks['text/csv']).then(function (res) {
            $(filesContainer).css("display", "none");
            $(mainContainer).css("display", "block");
            dictionary = JSON.parse(res);
            learnDictionary();
        });
    });
}

var setActiveButton  = function(btn){
    $("#learnBtn").parent().removeClass("active");
    $("#examineBtn").parent().removeClass("active");
    $(btn).parent().addClass("active");
};

var learnDictionary = function () {
    var idx = 0;

    var render = function() {
        var item = dictionary[idx];
        var content = "";
        if (item.phonetics.trim() != '') {
            content += '<div><b>Phonetics:</b> ' + item.phonetics + '</div>';
        }
        if (item.definition.trim() != '') {
            content += '<div><b>Definition:</b> ' + item.definition + '</div>';
        }
        if (item.example.trim() != '') {
            content += '<div><b>Example:</b> ' + item.example + '</div>';
        }
        if (item.translation.trim() != '') {
            content += '<div><b>Translation:</b> ' + item.translation + '</div>';
        }
        $("#body").html(content);
        $("#title").html(item.word);
    };
    render();

    $("#nextBtn").css("visibility", "visible");
    $("#prevBtn").css("visibility", "visible");
    setActiveButton("#learnBtn");
    $("#nextBtn").unbind("click")
    $("#prevBtn").unbind("click")
    $("#nextBtn").bind("click", function () {
        idx = (idx + 1) % dictionary.length;
        render();
    });
    $("#prevBtn").bind("click", function () {
        idx = idx - 1 < 0 ? dictionary.length - 1 : idx - 1;
        render();
    });

};

function examineDictionary() {
    var shuffledDictionary = shuffle(dictionary);
    var idx = 0;
    var render = function () {
        var item = shuffledDictionary[idx];

        var puzzleOptions = [];
        var content = "";
        content += '<div class="blurred" id="solution">';
        if (item.word.trim() != '') {
            content += '<div><b>Word:</b> ' + item.word + '</div>';
            puzzleOptions.push(item.word);
        }
        if (item.phonetics.trim() != '') {
            content += '<div><b>Phonetics:</b> ' + item.phonetics + '</div>';<commit_msg>removed word out of the puzzle options<commit_after>var dictionaryFileId = null;
var mainContainer = "#content";
var filesContainer = "#files";
var dictionary = [];

$(document).ready(function () {
    var mode = {};
    $("#nextBtn").css("visibility", "hidden");
    $("#prevBtn").css("visibility", "hidden");

    $("#learnBtn").bind("click", function() {
        learnDictionary();
    });
    $("#examineBtn").bind("click", function() {
        examineDictionary();
    });
});

function startApp() {
    if (!dictionaryFileId) {
        $(filesContainer).css("display", "block");
        $(mainContainer).css("display", "none");
        list().then(function (res) {
            var files = $(filesContainer + " .body");
            for (var i = 0; i < res.items.length; i++) {
                var item = res.items[i]
                var actor = $(document.createElement("a"));
                actor.attr("href", "JavaScript:void(0)");
                actor.attr("class", "list-group-item");
                actor.bind("click", item.id, function (evt) {
                    setFile(evt.data);
                });
                actor.text(item.title);

                files.append(actor);
            }
        });
    }
}

function setFile(id) {
    dictionaryFileId = id;

    readDictionary();
}


function readDictionary() {
    getFile(dictionaryFileId).then(function (res) {
        downloadFile(res.exportLinks['text/csv']).then(function (res) {
            $(filesContainer).css("display", "none");
            $(mainContainer).css("display", "block");
            dictionary = JSON.parse(res);
            learnDictionary();
        });
    });
}

var setActiveButton  = function(btn){
    $("#learnBtn").parent().removeClass("active");
    $("#examineBtn").parent().removeClass("active");
    $(btn).parent().addClass("active");
};

var learnDictionary = function () {
    var idx = 0;

    var render = function() {
        var item = dictionary[idx];
        var content = "";
        if (item.phonetics.trim() != '') {
            content += '<div><b>Phonetics:</b> ' + item.phonetics + '</div>';
        }
        if (item.definition.trim() != '') {
            content += '<div><b>Definition:</b> ' + item.definition + '</div>';
        }
        if (item.example.trim() != '') {
            content += '<div><b>Example:</b> ' + item.example + '</div>';
        }
        if (item.translation.trim() != '') {
            content += '<div><b>Translation:</b> ' + item.translation + '</div>';
        }
        $("#body").html(content);
        $("#title").html(item.word);
    };
    render();

    $("#nextBtn").css("visibility", "visible");
    $("#prevBtn").css("visibility", "visible");
    setActiveButton("#learnBtn");
    $("#nextBtn").unbind("click")
    $("#prevBtn").unbind("click")
    $("#nextBtn").bind("click", function () {
        idx = (idx + 1) % dictionary.length;
        render();
    });
    $("#prevBtn").bind("click", function () {
        idx = idx - 1 < 0 ? dictionary.length - 1 : idx - 1;
        render();
    });

};

function examineDictionary() {
    var shuffledDictionary = shuffle(dictionary);
    var idx = 0;
    var render = function () {
        var item = shuffledDictionary[idx];

        var puzzleOptions = [];
        var content = "";
        content += '<div class="blurred" id="solution">';
        if (item.word.trim() != '') {
            content += '<div><b>Word:</b> ' + item.word + '</div>';
        }
        if (item.phonetics.trim() != '') {
            content += '<div><b>Phonetics:</b> ' + item.phonetics + '</div>';
{'fraction_non_alphanumeric': 0.20746600055509298, 'fraction_numerical': 0.002497918401332223, 'mean_word_length': 2.2729336966394187, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3677581', 'n_tokens_mistral': 2084, 'n_tokens_neox': 2047, 'n_words': 378}