<commit_before>(function($) {
    $.Redactor.prototype.imagemanager = function() {
        return {
            init: function() {

                var button = this.button.add('image', 'Insert Image');

                this.button.setIcon(button, '<i class="fa fa-picture-o"></i>');

                this.button.addDropdown(
                    button, {
                        select: {
                            title: 'Select Image',
                            func: this.imagemanager.select
                        },
                        upload: {
                            title: 'Upload Image',
                            func: this.imagemanager.upload
                        }
                    }
                );

                $('#' + this.opts.element.attr('name') + '-modal').on(
                    'click',
                    '[data-select="image"]',
                    this.imagemanager.insert
                );
            },
            select: function() {

                this.selection.save();

                var params = this.imagemanager.params();

                $('#' + this.opts.element.attr('name') + '-modal')
                    .modal('show')
                    .find('.modal-content')
                    .load('/streams/wysiwyg-field_type/index?' + params);
            },
            upload: function() {

                this.selection.save();

                var params = this.imagemanager.params();

                $('#' + this.opts.element.attr('name') + '-modal')
                    .modal('show')
                    .find('.modal-content')
                    .load('/streams/wysiwyg-field_type/choose?' + params);
            },
            insert: function(e) {

                this.selection.restore();

                this.buffer.set();
                this.air.collapsed();

                var file = $(e.target).data('entry');

                if (file == undefined) {

                    console.log(e);

                    alert('There was a problem attaching this image. Please try again.');

                    return false;
                }

                var url = '/files/' + file;

                this.insert.node($('<img />').attr('src', url));

                $(e.target).closest('.modal').modal('hide');

                return false;
            },
            params: function() {
                return $.param({
                    mode: 'image',
                    folders: this.opts.folders
                });
            }
        };
    };
})(jQuery);
<commit_msg>Making work in subfolder installations<commit_after>(function($) {
    $.Redactor.prototype.imagemanager = function() {
        return {
            init: function() {

                var button = this.button.add('image', 'Insert Image');

                this.button.setIcon(button, '<i class="fa fa-picture-o"></i>');

                this.button.addDropdown(
                    button, {
                        select: {
                            title: 'Select Image',
                            func: this.imagemanager.select
                        },
                        upload: {
                            title: 'Upload Image',
                            func: this.imagemanager.upload
                        }
                    }
                );

                $('#' + this.opts.element.attr('name') + '-modal').on(
                    'click',
                    '[data-select="image"]',
                    this.imagemanager.insert
                );
            },
            select: function() {

                this.selection.save();

                var params = this.imagemanager.params();

                $('#' + this.opts.element.attr('name') + '-modal')
                    .modal('show')
                    .find('.modal-content')
                    .load(REQUEST_ROOT_PATH + '/streams/wysiwyg-field_type/index?' + params);
            },
            upload: function() {

                this.selection.save();

                var params = this.imagemanager.params();

                $('#' + this.opts.element.attr('name') + '-modal')
                    .modal('show')
                    .find('.modal-content')
                    .load(REQUEST_ROOT_PATH + '/streams/wysiwyg-field_type/choose?' + params);
            },
            insert: function(e) {

                this.selection.restore();

                this.buffer.set();
                this.air.collapsed();

                var file = $(e.target).data('entry');

                if (file == undefined) {

                    console.log(e);

                    alert('There was a problem attaching this image. Please try again.');

                    return false;
                }

                var url = REQUEST_ROOT_PATH + '/files/' + file;

                this.insert.node($('<img />').attr('src', url));

                $(e.target).closest('.modal').modal('hide');

                return false;
            },
            params: function() {
                return $.param({
                    mode: 'image',
                    folders: this.opts.folders
                });
            }
        };
    };
})(jQuery);

{'fraction_non_alphanumeric': 0.1368421052631579, 'fraction_numerical': 0.0, 'mean_word_length': 0.9938954597481877, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1671045', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1188, 'n_words': 209}