<commit_before>$('document').ready(function () {
    'use strict';

    var FD = {};

    FD.P_3072 = '8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006119df';

    FD.DEFAULT_RAND_LENGTH = 768;
    FD.DEFAULT_SERVER = 'http://localhost:8081/api/modexp/';

    FD.randHexString = function (length) {
        length = length === undefined ? FD.DEFAULT_RAND_LENGTH : length;
        var retval = '';
        while (retval.length < length) {
            var value = Math.floor(Math.random() * 256);
            retval += value < 10 ? '0' + value.toString(16) : value.toString(16);
        }
        return retval;
    };

    FD.appendTo = function (field, value) {
        var curval = $(field).val().toString();
        if (curval.length === 0) {
            $(field).val(value);
        } else if (curval.endsWith(',')) {
            $(field).val(curval + '\n' + value);
        } else if (curval.endsWith(',\n')) {
            $(field).val(curval + value);
        } else if (curval.endsWith('\n')) {
            $(field).val(curval + ',' + value);
        } else {
            $(field).val(curval + ',\n' + value);
        }
    };

    FD.injectVerificatum = function () {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'http://www.verificatum.com/files/vjsc-1.1.0.js'; // @todo errorhandling!
        $('body').append(script);
        window.BigInt.modexp = window.BigInt.modexpVerificatum;
        $('#btn-verificatum').prop('disabled', true);
    };

    FD.stringToList = function (val) {
        if (val.length === 0) {
            return [];
        } else {
            return val.replace(/\s+/gm, '').split(',');
        }
    };

    FD.parseFields = function() {
        var data = {};
        data.defaultBase = $('#input-base-default').val().length > 0 ? $('#input-base-default').val() : undefined;
        data.defaultExponent = $('#input-exponent-default').val().length > 0 ? $('#input-exponent-default').val() : undefined;
        data.defaultModulus = $('#input-modulus-default').val().length > 0 ? $('#input-modulus-default').val() : undefined;

        var bases = FD.stringToList($('#input-bases').val());
        var exponents = FD.stringToList($('#input-exponents').val());
        var moduli = FD.stringToList($('#input-moduli').val());

        if (bases.length !== exponents.length || bases.length !== moduli.length) {
            throw 'Inequal amount of bases, exponents and moduli entered!';
        }

        data.modexps = [];
        for (var i = 0; i < bases.length; i++) {
            data.modexps.push([bases[i], exponents[i], moduli[i]]);
        }

        return data;
    };

    FD.getServer = function (field) {
        return $(field).val().length > 0 ? $(field).val() : FD.DEFAULT_SERVER;
    };

    FD.createGlyph = function (glyph) {
        var s = document.createElement('span');
        s.setAttribute('aria-hidden', true);

        switch (glyph) {
            case 'ok':
                s.setAttribute('class', 'glyphicon glyphicon-ok');
                break;
            case 'nok':
                s.setAttribute('class', 'glyphicon glyphicon-remove');
                break;
            case 'time':
                s.setAttribute('class', 'glyphicon glyphicon-time');
                break;
            case 'down':
                s.setAttribute('class', 'glyphicon glyphicon-arrow-down');
                break;
            case 'up':
                s.setAttribute('class', 'glyphicon glyphicon-arrow-up');
                break;

        }
        return s;
    };

    FD.showResults = function () {
        $('#div-no-results').hide();
        $('#div-results').show();
    };

    FD.hideResults = function () {
        $('#div-results').hide();
        $('#div-no-results').show();
    };

    FD.resetResults = function () {
        $('#form-results').trigger('reset');
        $('#div-results').hide();
        $('#div-no-results').show();

        $('#div-time-remote').hide();
        $('#p-time-remote').remove();
        $('#div-time-local').hide();
        $('#p-time-local').remove();
        $('#div-time-difference').hide();
        $('#p-time-difference').remove();
        $('#div-equal').hide();
        $('#p-equal').remove();

        $('#div-results-remote').hide();
        $('#h-results-remote').remove();
        $('#input-results-remote').val('');
        $('#div-results-local').hide();
        $('#h-results-local').remove();
        $('#input-results-local').val('');
    };

    FD.showRemoteTime = function (time, better) {
        $('#p-time-remote').remove();
        var p = document.createElement('p');
        p.id = 'p-time-remote';

        if (better === undefined) {
            p.appendChild(document.createTextNode('Remote calculation took ' + time + ' ms.'));
        } else if (better) {
            p.setAttribute('class', 'text-success');
            p.appendChild(FD.createGlyph('down'));
            p.appendChild(document.createTextNode('\xa0Remote calculation took ' + time + ' ms.'));
        } else {
            p.setAttribute('class', 'text-danger');
            p.appendChild(FD.createGlyph('up'));
            p.appendChild(document.createTextNode('\xa0Remote calculation took ' + time + ' ms.'));
        }
        $('#div-time-remote').append(p);
        $('#div-time-remote').show();
    };

    FD.showLocalTime = function (time, better) {
        $('#p-time-local').remove();
        var p = document.createElement('p');
        p.id = 'p-time-local';

        if (better === undefined) {
            p.appendChild(document.createTextNode('In-browser calculation took ' + time + ' ms.'));
        } else if (better) {
            p.setAttribute('class', 'text-success');
            p.appendChild(FD.createGlyph('down'));
            p.appendChild(document.createTextNode('\xa0In-browser calculation took ' + time + ' ms.'));
        } else {
            p.setAttribute('class', 'text-danger');
            p.appendChild(FD.createGlyph('up'));
            p.appendChild(document.createTextNode('\xa0In-browser calculation took ' + time + ' ms.'));
        }
        $('#div-time-local').append(p);
        $('#div-time-local').show();
    };

    FD.showDifference = function (time1, time2) {
        var factor = time1 >= time2 ? Math.ceil(time1/time2*100)/100 : Math.ceil(time2/time1*100)/100;

        $('#p-time-difference').remove();
        var p = document.createElement('p');
        p.id = 'p-time-difference';
        p.appendChild(FD.createGlyph('time'));
        p.appendChild(document.createTextNode('\xa0Difference: ' + Math.abs(time1 - time2) + ' ms (' + factor +' times).'));
        $('#div-time-difference').append(p);
        $('#div-time-difference').show();
    };

    FD.showEqual = function (result1, result2) {
        $('#p-equal').remove();<commit_msg>implemented overriding with default values<commit_after>$('document').ready(function () {
    'use strict';

    var FD = {};

    FD.P_3072 = '8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006119df';

    FD.DEFAULT_RAND_LENGTH = 768;
    FD.DEFAULT_SERVER = 'http://localhost:8081/api/modexp/';

    FD.randHexString = function (length) {
        length = length === undefined ? FD.DEFAULT_RAND_LENGTH : length;
        var retval = '';
        while (retval.length < length) {
            var value = Math.floor(Math.random() * 256);
            retval += value < 10 ? '0' + value.toString(16) : value.toString(16);
        }
        return retval;
    };

    FD.appendTo = function (field, value) {
        var curval = $(field).val().toString();
        if (curval.length === 0) {
            $(field).val(value);
        } else if (curval.endsWith(',')) {
            $(field).val(curval + '\n' + value);
        } else if (curval.endsWith(',\n')) {
            $(field).val(curval + value);
        } else if (curval.endsWith('\n')) {
            $(field).val(curval + ',' + value);
        } else {
            $(field).val(curval + ',\n' + value);
        }
    };

    FD.injectVerificatum = function () {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'http://www.verificatum.com/files/vjsc-1.1.0.js'; // @todo errorhandling!
        $('body').append(script);
        window.BigInt.modexp = window.BigInt.modexpVerificatum;
        $('#btn-verificatum').prop('disabled', true);
    };

    FD.stringToList = function (val) {
        if (val.length === 0) {
            return [];
        } else {
            return val.replace(/\s+/gm, '').split(',');
        }
    };

    FD.parseFields = function () {
        var data = {};
        data.defaultBase = $('#input-base-default').val().length > 0 ? $('#input-base-default').val() : undefined;
        data.defaultExponent = $('#input-exponent-default').val().length > 0 ? $('#input-exponent-default').val() : undefined;
        data.defaultModulus = $('#input-modulus-default').val().length > 0 ? $('#input-modulus-default').val() : undefined;

        var bases = FD.stringToList($('#input-bases').val());
        var exponents = FD.stringToList($('#input-exponents').val());
        var moduli = FD.stringToList($('#input-moduli').val());

        if (bases.length !== exponents.length || bases.length !== moduli.length) {
            throw 'Inequal amount of bases, exponents and moduli entered!';
        }

        data.modexps = [];
        for (var i = 0; i < bases.length; i++) {
            data.modexps.push([bases[i] === '' ? data.defaultBase : bases[i],
                exponents[i] === '' ? data.defaultExponent : exponents[i],
                moduli[i] === '' ? data.defaultModulus : moduli[i]]);
        }
        return data;
    };

    FD.getServer = function (field) {
        return $(field).val().length > 0 ? $(field).val() : FD.DEFAULT_SERVER;
    };

    FD.createGlyph = function (glyph) {
        var s = document.createElement('span');
        s.setAttribute('aria-hidden', true);

        switch (glyph) {
            case 'ok':
                s.setAttribute('class', 'glyphicon glyphicon-ok');
                break;
            case 'nok':
                s.setAttribute('class', 'glyphicon glyphicon-remove');
                break;
            case 'time':
                s.setAttribute('class', 'glyphicon glyphicon-time');
                break;
            case 'down':
                s.setAttribute('class', 'glyphicon glyphicon-arrow-down');
                break;
            case 'up':
                s.setAttribute('class', 'glyphicon glyphicon-arrow-up');
                break;

        }
        return s;
    };

    FD.showResults = function () {
        $('#div-no-results').hide();
        $('#div-results').show();
    };

    FD.hideResults = function () {
        $('#div-results').hide();
        $('#div-no-results').show();
    };

    FD.resetResults = function () {
        $('#form-results').trigger('reset');
        $('#div-results').hide();
        $('#div-no-results').show();

        $('#div-time-remote').hide();
        $('#p-time-remote').remove();
        $('#div-time-local').hide();
        $('#p-time-local').remove();
        $('#div-time-difference').hide();
        $('#p-time-difference').remove();
        $('#div-equal').hide();
        $('#p-equal').remove();

        $('#div-results-remote').hide();
        $('#h-results-remote').remove();
        $('#input-results-remote').val('');
        $('#div-results-local').hide();
        $('#h-results-local').remove();
        $('#input-results-local').val('');
    };

    FD.showRemoteTime = function (time, better) {
        $('#p-time-remote').remove();
        var p = document.createElement('p');
        p.id = 'p-time-remote';

        if (better === undefined) {
            p.appendChild(document.createTextNode('Remote calculation took ' + time + ' ms.'));
        } else if (better) {
            p.setAttribute('class', 'text-success');
            p.appendChild(FD.createGlyph('down'));
            p.appendChild(document.createTextNode('\xa0Remote calculation took ' + time + ' ms.'));
        } else {
            p.setAttribute('class', 'text-danger');
            p.appendChild(FD.createGlyph('up'));
            p.appendChild(document.createTextNode('\xa0Remote calculation took ' + time + ' ms.'));
        }
        $('#div-time-remote').append(p);
        $('#div-time-remote').show();
    };

    FD.showLocalTime = function (time, better) {
        $('#p-time-local').remove();
        var p = document.createElement('p');
        p.id = 'p-time-local';

        if (better === undefined) {
            p.appendChild(document.createTextNode('In-browser calculation took ' + time + ' ms.'));
        } else if (better) {
            p.setAttribute('class', 'text-success');
            p.appendChild(FD.createGlyph('down'));
            p.appendChild(document.createTextNode('\xa0In-browser calculation took ' + time + ' ms.'));
        } else {
            p.setAttribute('class', 'text-danger');
            p.appendChild(FD.createGlyph('up'));
            p.appendChild(document.createTextNode('\xa0In-browser calculation took ' + time + ' ms.'));
        }
        $('#div-time-local').append(p);
        $('#div-time-local').show();
    };

    FD.showDifference = function (time1, time2) {
        var factor = time1 >= time2 ? Math.ceil(time1 / time2 * 100) / 100 : Math.ceil(time2 / time1 * 100) / 100;

        $('#p-time-difference').remove();
        var p = document.createElement('p');
        p.id = 'p-time-difference';
        p.appendChild(FD.createGlyph('time'));
        p.appendChild(document.createTextNode('\xa0Difference: ' + Math.abs(time1 - time2) + ' ms (' + factor + ' times).'));
        $('#div-time-difference').append(p);
        $('#div-time-difference').show();
    };

    FD.showEqual = function (result1, result2) {
        $('#p-equal').remove();
{'fraction_non_alphanumeric': 0.1761145460462089, 'fraction_numerical': 0.10751708428246014, 'mean_word_length': 2.4522579195686363, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6885442', 'n_tokens_mistral': 5755, 'n_tokens_neox': 4111, 'n_words': 687}