<commit_before>jQuery(function($) {
    "use strict";

    var $modal = null;
    var $body  = $(document.body);

    /**
     * Handles the element click
     *
     * @param event {jQuery.Event}
     */
    function onElementClick (event)
    {
        // there is an open modal already
        if ($modal !== null)
        {
            return;
        }

        var $link = $(event.currentTarget);
        $body.append(renderModalContent($link));
        $modal = $("#becklyn-bootstrap-modal");
        $modal
            .on("click", "[data-dismiss=modal]", onHide)
            .modal();

        event.stopPropagation();
        event.preventDefault();
    }

    /**
     * Callback, when the modal should be hidden
     */
    function onHide ()
    {
        if ($modal !== null)
        {
            $modal
                .on("hidden.bs.modal", onHidden)
                .modal("hide");
        }
    }

    /**
     * Callback for when the element is hidden
     */
    function onHidden ()
    {
        if ($modal !== null)
        {
            $modal.remove();
            $modal = null;
        }
    }

    function renderModalContent ($link)
    {
        var title   = $link.data("original-title") || $link.attr("title");
        var url     = $link.attr("href");
        var message = $link.data("confirm");

        return [
            '<div class="modal fade" id="becklyn-bootstrap-modal" role="dialog">',
                '<div class="modal-dialog">',
                    '<div class="modal-content">',
                        '<div class="modal-header">',
                            '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>',
                            '<h4 class="modal-title">', escapeHtml(title), '</h4>',
                        '</div>',
                        '<div class="modal-body">',
                            '<p>', escapeHtml(message), '</p>',
                        '</div>',
                        '<div class="modal-footer">',
                            '<button class="btn btn-default" data-dismiss="modal">Abbrechen</button>',
                            '<a href="', url, '" class="btn btn-danger">Fortfahren</a>',
                        '</div>',
                    '</div>',
                '</div>',
            '</div>'
        ].join("");
    }

    /**
     * Escapes inline HTML
     *
     * Inspired by underscore.js's _.escape
     *
     * @param string
     * @returns {string}
     */
    function escapeHtml (string)
    {
        if ((string === null) || !string.length)
        {
            return '';
        }

        var entityMap = {<commit_msg>Added optional data-confirm-label and data-cancel-label for JS modal dialog<commit_after>jQuery(function($) {
    "use strict";

    var $modal = null;
    var $body  = $(document.body);

    /**
     * Handles the element click
     *
     * @param event {jQuery.Event}
     */
    function onElementClick (event)
    {
        // there is an open modal already
        if ($modal !== null)
        {
            return;
        }

        var $link = $(event.currentTarget);
        $body.append(renderModalContent($link));
        $modal = $("#becklyn-bootstrap-modal");
        $modal
            .on("click", "[data-dismiss=modal]", onHide)
            .modal();

        event.stopPropagation();
        event.preventDefault();
    }

    /**
     * Callback, when the modal should be hidden
     */
    function onHide ()
    {
        if ($modal !== null)
        {
            $modal
                .on("hidden.bs.modal", onHidden)
                .modal("hide");
        }
    }

    /**
     * Callback for when the element is hidden
     */
    function onHidden ()
    {
        if ($modal !== null)
        {
            $modal.remove();
            $modal = null;
        }
    }

    function renderModalContent ($link)
    {
        var title        = $link.data("original-title") || $link.attr("title");
        var url          = $link.attr("href");
        var message      = $link.data("confirm");
        var confirmLabel = $link.data("confirm-label") || "Continue";
        var cancelLabel  = $link.data("cancel-label") || "Cancel";

        return [
            '<div class="modal fade" id="becklyn-bootstrap-modal" role="dialog">',
                '<div class="modal-dialog">',
                    '<div class="modal-content">',
                        '<div class="modal-header">',
                            '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>',
                            '<h4 class="modal-title">', escapeHtml(title), '</h4>',
                        '</div>',
                        '<div class="modal-body">',
                            '<p>', escapeHtml(message), '</p>',
                        '</div>',
                        '<div class="modal-footer">',
                            '<button class="btn btn-default" data-dismiss="modal">', cancelLabel ,'</button>',
                            '<a href="', url, '" class="btn btn-danger">', confirmLabel ,'</a>',
                        '</div>',
                    '</div>',
                '</div>',
            '</div>'
        ].join("");
    }

    /**
     * Escapes inline HTML
     *
     * Inspired by underscore.js's _.escape
     *
     * @param string
     * @returns {string}
     */
    function escapeHtml (string)
    {
        if ((string === null) || !string.length)
        {
            return '';
        }

        var entityMap = {
{'fraction_non_alphanumeric': 0.16164874551971326, 'fraction_numerical': 0.0007168458781362007, 'mean_word_length': 1.379957356076759, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, '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': '2749529', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1513, 'n_words': 322}