<commit_before>/*!
 * Bootstrap Fileselect v1.1
 * https://github.com/Neoflow/Bootstrap-Fileselect
 *
 * Released under the MIT license
 * https://github.com/Neoflow/Bootstrap-Fileselect/blob/master/LICENSE.md
 */
(function (window, $) {

    var Fileselect = function (fileInput, options) {
        this.$fileInput = $(fileInput);
        this.options = options;
        this.metadata = this.$fileInput.data();
        this.$inputGroup = $('<div>').addClass('input-group');
        this.$inputGroupBtn = $('<label>').addClass('input-group-btn');
        this.$browseBtn = $('<span>');
        this.$labelInput = $('<input>').attr('type', 'text').attr('readonly', true).addClass('form-control');
        this.translations = {
            'en': {
                'browse': 'Browse',
                'rules': {
                    'limit': 'The number of uploadable files is limited to [num] file(s)',
                    'filelimit': 'The files are restricted to following file extensions: [ext]'
                }
            },
            'de': {
                'browse': 'Durchsuchen',
                'rules': {
                    'limit': 'Die Anzahl der hochladbaren Dateien ist limitiert auf [num] Datei(en)',
                    'extensions': 'Die Dateien sind eingeschränkt auf folgende Dateierweiterungen: [ext]',
                }
            }
        };
    };
    Fileselect.prototype = {
        defaults: {
            browseBtnClass: 'btn btn-primary',
            browseIcon: '<i class="glyphicon glyphicon-folder-open"></i>',
            limit: false,
            extensions: false,
            language: false
        },
        init: function () {
            this.config = this.loadConfig();
            this.translations = this.loadTranslation();

            this.$fileInput
                    .hide()
                    .after(this.$inputGroup);

            this.$inputGroup
                    .append(this.$inputGroupBtn, this.$labelInput);

            this.$inputGroupBtn
                    .append(this.$browseBtn)
                    .append(this.$fileInput);

            this.$browseBtn
                    .addClass(this.config.browseBtnClass)
                    .text(this.translations.browse)
                    .append(' &hellip;');

            if (this.config.browseIcon) {
                this.$browseBtn.prepend(this.config.browseIcon, '&nbsp;&nbsp;');
            }

            this.$fileInput.on('change', $.proxy(this.changeEvent, this));

            return this;
        },
        changeEvent: function (e) {
            var files = this.$fileInput[0].files,
                    label = $.map(files, function (file) {
                        return file.name;
                    }).join(', ');

            if (this.validateLimit(files) && this.valiateExtensions(files)) {
                this.$labelInput.val(label);
                return true;
            }
            this.$fileInput.val(null);
            return false;
        },
        loadConfig: function () {
            this.config = $.extend({}, this.defaults, this.options, this.metadata);
            if (typeof this.config.extensions === 'string') {
                this.config.extensions = this.config.extensions.split(',');
            }
        },
        loadTranslation: function () {
            var userLanguage = this.config.language || navigator.language || navigator.userLanguage,
                    translatedLanguages = $.map(this.translations, function (translations, key) {
                        return key;
                    });

            if ($.inArray(userLanguage, translatedLanguages) === -1) {
                userLanguage = 'en';
            }
            return this.translations[userLanguage];
        },
        validateLimit: function (files) {
            if (this.config.limit && files.length > parseInt(this.config.limit)) {
                alert(this.translations.rules.limit.replace('[num]', this.config.limit));
                return false;
            }
            return true;
        },
        valiateExtensions: function (files) {
            var result = true;
            if (this.config.extensions) {
                $.each(files, $.proxy(function (i, file) {<commit_msg>Updated fileselect<commit_after>/*!
 * Bootstrap Fileselect v1.1
 * https://github.com/Neoflow/Bootstrap-Fileselect
 *
 * Released under the MIT license
 * https://github.com/Neoflow/Bootstrap-Fileselect/blob/master/LICENSE.md
 */
(function (window, $) {

    var Fileselect = function (fileInput, options) {
        this.$fileInput = $(fileInput);
        this.options = options;
        this.metadata = this.$fileInput.data();
        this.$inputGroup = $('<div>').addClass('input-group');
        this.$inputGroupBtn = $('<label>').addClass('input-group-btn');
        this.$browseBtn = $('<span>');
        this.$labelInput = $('<input>').attr('type', 'text').attr('readonly', true).addClass('form-control');
        this.translations = {
            'en': {
                'browse': 'Browse',
                'rules': {
                    'limit': 'The number of uploadable files is limited to [num] file(s)',
                    'filelimit': 'The files are restricted to following file extensions: [ext]'
                }
            },
            'de': {
                'browse': 'Durchsuchen',
                'rules': {
                    'limit': 'Die Anzahl der hochladbaren Dateien ist limitiert auf [num] Datei(en)',
                    'extensions': 'Die Dateien sind eingeschränkt auf folgende Dateierweiterungen: [ext]',
                }
            }
        };
    };
    Fileselect.prototype = {
        defaults: {
            browseBtnClass: 'btn btn-primary',
            browseIcon: '<i class="glyphicon glyphicon-folder-open"></i>',
            limit: false,
            extensions: false,
            language: false
        },
        init: function () {
            this.config = this.loadConfig();
            this.translations = this.loadTranslation();

            this.$fileInput
                    .hide()
                    .after(this.$inputGroup);

            this.$inputGroup
                    .append(this.$inputGroupBtn, this.$labelInput);

            this.$inputGroupBtn
                    .append(this.$browseBtn)
                    .append(this.$fileInput);

            this.$browseBtn
                    .addClass(this.config.browseBtnClass)
                    .text(this.translations.browse)
                    .append(' &hellip;');

            if (this.config.browseIcon) {
                this.$browseBtn.prepend(this.config.browseIcon, '&nbsp;&nbsp;');
            }

            this.$fileInput.on('change', $.proxy(this.changeEvent, this));

            return this;
        },
        changeEvent: function (e) {
            var files = this.$fileInput[0].files,
                    label = $.map(files, function (file) {
                        return file.name;
                    }).join(', ');

            if (this.validateLimit(files) && this.valiateExtensions(files)) {
                this.$labelInput.val(label);
                return true;
            }
            this.$fileInput.val(null);
            return false;
        },
        loadConfig: function () {
            var config = $.extend({}, this.defaults, this.options, this.metadata);
            if (typeof config.extensions === 'string') {
                config.extensions = config.extensions.split(',');
            }
            return config;
        },
        loadTranslation: function () {
            var userLanguage = this.config.language || navigator.language || navigator.userLanguage,
                    translatedLanguages = $.map(this.translations, function (translations, key) {
                        return key;
                    });

            if ($.inArray(userLanguage, translatedLanguages) === -1) {
                userLanguage = 'en';
            }
            return this.translations[userLanguage];
        },
        validateLimit: function (files) {
            if (this.config.limit && files.length > parseInt(this.config.limit)) {
                alert(this.translations.rules.limit.replace('[num]', this.config.limit));
                return false;
            }
            return true;
        },
        valiateExtensions: function (files) {
            var result = true;
            if (this.config.extensions) {
                $.each(files, $.proxy(function (i, file) {
{'fraction_non_alphanumeric': 0.13349800047047752, 'fraction_numerical': 0.0009409550693954364, 'mean_word_length': 1.5790112223233241, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 4, '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': '4122706', 'n_tokens_mistral': 2270, 'n_tokens_neox': 2153, 'n_words': 424}