<commit_before>var writeChar = function(someOutput, characterToWrite) {
    someOutput.append(characterToWrite); 
}

var delayFunction = function(INITIAL_MULTIPLIER) { return Math.round(Math.random() * INITIAL_MULTIPLIER) + 10};
var writePrompt = function(listOfPrompts, listOfAnswers, someOutput, someContent) {
    if(someContent == undefined || someContent == "") {
        var toOutput = null;
        var newPrompts = null;
        var newAnswers = null;
        if(listOfPrompts.length < listOfAnswers.length) {
            toOutput = listOfAnswers[0];
            newAnswers = listOfAnswers.slice(1);
            newPrompts = listOfPrompts;
        } else if(listOfPrompts.length > listOfAnswers.length) {
            toOutput = listOfPrompts[0];
            newAnswers = listOfAnswers;
            newPrompts = listOfPrompts.slice(1);
        } else {
            if(listOfPrompts.length != 0) {
                toOutput = listOfPrompts[0];
                newAnswers = listOfAnswers;
                newPrompts = listOfPrompts.slice(1);
            } else{
                return;
            }
        }
        if(someOutput != undefined) {
            someOutput.removeClass("active");
        }
        var promptDom = $("<p><p>");
        $('body').append(promptDom);
        writePrompt(newPrompts, newAnswers, promptDom, toOutput);
        return;

    }
    var INITIAL_MULTIPLIER = 20;
    setTimeout(function() {
        var currentChar = someContent.charAt(0);
        someOutput.addClass("active");
        writeChar(someOutput, currentChar);
        writePrompt(listOfPrompts, listOfAnswers, someOutput, someContent.substring(1));
    }, delayFunction(INITIAL_MULTIPLIER));
}

var cleanup = function() {
    var prompts = $('.prompts');
    var answers = $('.answers');
    prompts.remove();
    answers.remove();
}

$(document).ready(function() {
    
    var prompts = $('.prompts p');
    var answers = $('.answers p')
    var promptContents = new Array();
    var answerContents = new Array();
    promptContents = prompts.map(function(index) {
        var currentText = $(this).text();
        return currentText;
    });

    answerContents = answers.map(function(index) {
        var currentText = $(this).text();
        return currentText;
    });
    cleanup();

    writePrompt(promptContents, answerContents);
});<commit_msg>Fix js bugs and improve it to use span.<commit_after>var writeChar = function(someOutput, characterToWrite) {
    someOutput.append(characterToWrite); 
}

var globalMultiplier = 1;
var delayFunction = function(INITIAL_MULTIPLIER) {
    globalMultiplier = 1/Math.pow(2,globalMultiplier);
    return Math.round(Math.random() * INITIAL_MULTIPLIER * globalMultiplier);
};
var writePrompt = function(listOfPrompts, listOfAnswers, someOutput, someContent, isAnswer) {
    if(someContent == undefined) {
        toOutput = listOfPrompts[0];
        newAnswers = listOfAnswers;
        newPrompts = listOfPrompts.slice(1);
        var promptDom = $("<span></span>");
        promptDom.append("<br>");
        $('termcontainer').append(promptDom);
        writePrompt(newPrompts, newAnswers, promptDom, toOutput);
    } else if(someContent == "") {
        var toOutput = null;
        var newPrompts = null;
        var newAnswers = null;
        
        if(listOfPrompts.length < listOfAnswers.length) {
            toOutput = listOfAnswers[0];
            newAnswers = listOfAnswers.slice(1);
            newPrompts = listOfPrompts;
        } else if(listOfPrompts.length > listOfAnswers.length) {
            toOutput = listOfPrompts[0];
            newAnswers = listOfAnswers;
            newPrompts = listOfPrompts.slice(1);
        } else if(listOfPrompts.length != 0){
            toOutput = listOfPrompts[0];
            newAnswers = listOfAnswers;
            newPrompts = listOfPrompts.slice(1);
        } else {
            return;
        }

        if(isAnswer) {
            someOutput.addClass("answer")
        }
        someOutput.removeClass("active");

        var promptDom = $("<span></span>");
        promptDom.append("<br>");
        $('.termcontainer').append(promptDom);
        writePrompt(newPrompts, newAnswers, promptDom, toOutput);
        return;

    }
    var INITIAL_MULTIPLIER = 5;
    setTimeout(function() {
        var currentChar = someContent.charAt(0);
        someOutput.addClass("active");
        writeChar(someOutput, currentChar);
        writePrompt(listOfPrompts, listOfAnswers, someOutput, someContent.substring(1));
        someOutput.removeClass("active");
    }, delayFunction(INITIAL_MULTIPLIER));
}

var cleanup = function() {
    var prompts = $('.prompts');
    var answers = $('.answers');
    prompts.remove();
    answers.remove();
}

$(document).ready(function() {
    var prompts = $('.prompts p');
    var answers = $('.answers p')
    promptContents = prompts.map(function(index) {
        var currentText = $(this).text();
        return currentText;
    });

    answerContents = answers.map(function(index) {
        var currentText = $(this).text();
        return currentText;
    });
    cleanup();

    writePrompt(promptContents, answerContents);
});
{'fraction_non_alphanumeric': 0.12659451101662156, 'fraction_numerical': 0.005411673753382296, 'mean_word_length': 2.6443661971830985, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2695533', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1505, 'n_words': 284}