<commit_before>var contentify;

$(document).ready(function()
{
    function Contentify() 
    {
        var frameWork = this;

        /*
         * Initizalize meta variables
         */
        this.baseUrl    = $('meta[name="base-url"]').attr('content') + '/';
        this.csrfToken  = $('meta[name="csrf-token"]').attr('content');
        this.locale     = $('meta[name="locale"]').attr('content');
        this.dateFormat = $('meta[name="date-format"]').attr('content');

        this.urlParam = function(name) 
        {
            return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)')
                .exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
        }

        /*
         * Add CSRF token
         */
        jQuery.ajaxPrefilter(function(options, request, xhr) 
        {
            if (! xhr.crossDomain) {
                options.data += '&_token=' + frameWork.csrfToken;
            }
        });

        /*
         * Template Manager
         */
        this.templateManager = new function() 
        {
            this.templates = { };

            /*
             * Adds a template
             */
            this.add = function(name, template) 
            {
                this.templates[name] = template;
            };

            /*
             * Returns true if the template exists
             */
            this.has = function(name) 
            {
                return (typeof this.templates[name] !== 'undefined');
            };

            /*
             * Returns a rendered template
             */
            this.get = function(name, vars) 
            {
                if (typeof this.templates[name] === 'undefined') {
                    return;
                }

                if (typeof vars !== 'object') {
                    return this.templates[name];
                }

                // Note: It's possible to use {{ }} but this will confuse Blade.
                return this.templates[name].replace(/%%(.*?)%%/g, function() 
                {
                    return vars[arguments[1]];
                });
            };
        };

        /*
         * Numeric inputs
         */
        $('.numeric-input').keypress(function()
        {
            if (! isNaN($(this).val())) {
                $(this).attr('valid-value', $(this).val());
            }
        }).focusout(function()
        {
            if (isNaN($(this).val())) {
                var valid = $(this).attr('valid-value');

                if (valid) {
                    $(this).val(valid);
                } else {
                    $(this).val(0);
                }
            }
        });

        /**
         * Creates an alert HTML node inside the alert area.
         *
         * @param string type     The alert type e. g. sucess, alert
         * @param string text     The text that should be shown
         * @param bool   clearAll If true, this will hide all other alerts
         * @return void
         */
        this.alert = function (type, title, clearAll)
        {
            if (! frameWork.templateManager.has('alert')) {
                frameWork.templateManager.add('alert', 
                    '<div class="alert alert-%%type%%">\
                    <button type="button" class="close">&times;</button>\
                    <h2>%%title%%</h2>\
                    </div>'
                );
            }

            var $template = $(frameWork.templateManager.get('alert', {
                type: type,
                title: title
            }));

            $template.find('button').click(function()
            {
                $(this).parent().remove();
            });

            if (clearAll) {
                $('.alert-area').html('');
            }
            $('.alert-area').append($template);

            $(window).scrollTop($('.alert-area').offset().top);
        };

        /*
         * Add delete confirm dialogue<commit_msg>Added shortcut alert methods<commit_after>var contentify;

$(document).ready(function()
{
    function Contentify() 
    {
        var framework = this;

        /*
         * Initizalize meta variables
         */
        this.baseUrl    = $('meta[name="base-url"]').attr('content') + '/';
        this.csrfToken  = $('meta[name="csrf-token"]').attr('content');
        this.locale     = $('meta[name="locale"]').attr('content');
        this.dateFormat = $('meta[name="date-format"]').attr('content');

        this.urlParam = function(name) 
        {
            return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)')
                .exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
        }

        /*
         * Add CSRF token
         */
        jQuery.ajaxPrefilter(function(options, request, xhr) 
        {
            if (! xhr.crossDomain) {
                options.data += '&_token=' + framework.csrfToken;
            }
        });

        /*
         * Template Manager
         */
        this.templateManager = new function() 
        {
            this.templates = { };

            /*
             * Adds a template
             */
            this.add = function(name, template) 
            {
                this.templates[name] = template;
            };

            /*
             * Returns true if the template exists
             */
            this.has = function(name) 
            {
                return (typeof this.templates[name] !== 'undefined');
            };

            /*
             * Returns a rendered template
             */
            this.get = function(name, vars) 
            {
                if (typeof this.templates[name] === 'undefined') {
                    return;
                }

                if (typeof vars !== 'object') {
                    return this.templates[name];
                }

                // Note: It's possible to use {{ }} but this will confuse Blade.
                return this.templates[name].replace(/%%(.*?)%%/g, function() 
                {
                    return vars[arguments[1]];
                });
            };
        };

        /*
         * Numeric inputs
         */
        $('.numeric-input').keypress(function()
        {
            if (! isNaN($(this).val())) {
                $(this).attr('valid-value', $(this).val());
            }
        }).focusout(function()
        {
            if (isNaN($(this).val())) {
                var valid = $(this).attr('valid-value');

                if (valid) {
                    $(this).val(valid);
                } else {
                    $(this).val(0);
                }
            }
        });

        /**
         * Creates an alert HTML node inside the alert area.
         *
         * @param string type     The alert type e. g. sucess, alert
         * @param string text     The text that should be shown
         * @param bool   clearAll If true, this will hide all other alerts
         * @return void
         */
        this.alert = function (type, title, clearAll)
        {
            if (! framework.templateManager.has('alert')) {
                framework.templateManager.add('alert', 
                    '<div class="alert alert-%%type%%">\
                    <button type="button" class="close">&times;</button>\
                    <h2>%%title%%</h2>\
                    </div>'
                );
            }

            var $template = $(framework.templateManager.get('alert', {
                type: type,
                title: title
            }));

            $template.find('button').click(function()
            {
                $(this).parent().remove();
            });

            var $alertArea = $('.alert-area');

            if (clearAll) {
                $alertArea.html('');
            }
            $alertArea.append($template);

            $(window).scrollTop($alertArea.offset().top);
        };

        this.alertSuccess = function (title, clearAll)
        {
            framework.alert('success', title, clearAll);
        }

        this.alertWarning = function (title, clearAll)
        {
            framework.alert('warning', title, clearAll);
        }

        this.alertError = function (title, clearAll)
        {
            framework.alert('error', title, clearAll);
        }

        /*
         * Add delete confirm dialogue
{'fraction_non_alphanumeric': 0.15148986889153754, 'fraction_numerical': 0.00166865315852205, 'mean_word_length': 1.2046768260641092, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4299242', 'n_tokens_mistral': 2228, 'n_tokens_neox': 2091, 'n_words': 406}