<commit_before>/*
    Written by <NAME>
    HOW TO USE :
        >> Load JQuery library
        >> Load autocomplete-lite-img.js library
        >> Initialize autocomplete on element and pass autocomplete list as an array
     
           EXAMPLE :
               <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
               <script src="autocomplete-lite-img.js"></script>
               <input type="text" id="autocomplete_input">
               <script>
                   var autocomplete_items = ["person1", "person2", "person3", "person4", "person5", "person6"];
                   var autocomplete_images = ["person1.png", "person2.png", "person3.png", "person4.png", "person5", "person6.png"];
                   
                   // initializing
                   $('#autocomplete_input').autocomplete_img_init(autocomplete_items, autocomplete_images);
               </script>
*/

(function($) {

jQuery.fn.extend({
    autocomplete_img_init: function (item_data, image_data, callback) {
        me = $(this);

        if(callback === undefined)
        {
            callback = callback_dummy;
        }
        else
        {
           if(! typeof callback == 'function')
           {
                console.error('Error : autocomplete-lite ' + callback + ' is not a function.');
                return;
           }
        }

        var item_data_length = item_data.length; 

        if(item_data_length === image_data.length)
        {
            var img_map = {};
            for(var i=0; i<item_data_length; i++)
            {
                img_map[item_data[i].toLowerCase()] = image_data[i];
            }

            mridautocomplete(me, item_data, img_map, callback);
        }
        else
            console.error('Error : autocomplete-lite item count does not match the images count.');


    }
});

function callback_dummy() {}

function mridautocomplete(input, item_data, image_data, callback) {

    var mridautocomplete_timer = 0;

    if(!$('#mridautocomplete_css').length )
    {
        var img_dimensions = (parseInt(input.css('font-size')) - 2 ) + 'px';
        $('body').prepend('<style id="mridautocomplete_css">.mridautocomplete-list::-webkit-scrollbar{width: 12px;}.mridautocomplete-list::-webkit-scrollbar-track{-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);border-radius: 2px;}.mridautocomplete-list::-webkit-scrollbar-thumb{border-radius: 2px;-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);} .mridautocomplete-item-image{height: ' + img_dimensions + '; width: ' + img_dimensions + ';} </style>');
    }

    var item_dataList = [];

    if (Array.isArray(item_data)) {
        item_dataList = item_dataList.concat(item_data);
    } else {
        console.error('Error : autocomplete-lite takes an array as parameter. ' + typeof item_data + ' given');
        return;
    }

    var matchitem_data = function(input, item_dataList) {
        var reg = new RegExp(input.split('').join('\\w*').replace(/\W/, ""), 'i');
        return item_dataList.filter(function(item_data) {
            if (item_data.match(reg)) {
                return item_data;
            }
        });
    };

    var changeInput = function(input, item_dataList) {
        var val = input.val().toLowerCase();
        var res = input.next();

        res.empty().hide();

        var autoCompleteResult = matchitem_data(val, item_dataList);
        if (val == "" || autoCompleteResult.length == 0) {
            return;
        }

        autoCompleteResult.forEach(function(e) {
            var p = $('<p />');
            p.css({
              'margin': '0px',
              'padding-left': parseInt(input.css('padding-left'),10) + parseInt(input.css('border-left-width'),10),
              'text-align': 'left',
              'font-size': input.css('font-size'),
              'cursor': 'default'
            });
<commit_msg>Update autocomplete-lite-img.js<commit_after>/*
    Written by <NAME>
    HOW TO USE :
        >> Load JQuery library
        >> Load autocomplete-lite-img.js library
        >> Initialize autocomplete on element and pass autocomplete list as an array
     
           EXAMPLE :
               <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
               <script src="autocomplete-lite-img.js"></script>
               <input type="text" id="autocomplete_input">
               <script>
                   var autocomplete_items = ["person1", "person2", "person3", "person4", "person5", "person6"];
                   var autocomplete_images = ["person1.png", "person2.png", "person3.png", "person4.png", "person5", "person6.png"];
                   
                   // initializing
                   $('#autocomplete_input').autocomplete_img_init(autocomplete_items, autocomplete_images);
               </script>
*/

(function($) {

jQuery.fn.extend({
    autocomplete_img_init: function (item_data, image_data, callback) {
        me = $(this);

        if(callback === undefined)
        {
            callback = callback_dummy;
        }
        else
        {
           if(! typeof callback == 'function')
           {
                console.error('Error : autocomplete-lite ' + callback + ' is not a function.');
                return;
           }
        }

        var item_data_length = item_data.length; 

        if(item_data_length === image_data.length)
        {
            var img_map = {};
            for(var i=0; i<item_data_length; i++)
            {
                img_map[item_data[i].toLowerCase()] = image_data[i];
            }

            mridautocomplete(me, item_data, img_map, callback);
        }
        else
            console.error('Error : autocomplete-lite item count does not match the images count.');


    }
});

function callback_dummy() {}

function mridautocomplete(input, item_data, image_data, callback) {

    var mridautocomplete_timer = 0;

    if(!$('#mridautocomplete_css').length )
    {
        var img_dimensions = (parseInt(input.css('font-size')) - 2 ) + 'px';
        $('body').prepend('<style id="mridautocomplete_css">.mridautocomplete-list::-webkit-scrollbar{width: 12px;}.mridautocomplete-list::-webkit-scrollbar-track{-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);border-radius: 2px;}.mridautocomplete-list::-webkit-scrollbar-thumb{border-radius: 2px;-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);} .mridautocomplete-item-image{height: ' + img_dimensions + '; width: ' + img_dimensions + ';} </style>');
    }

    var item_dataList = [];

    if (Array.isArray(item_data)) {
        item_dataList = item_dataList.concat(item_data);
    } else {
        console.error('Error : autocomplete-lite takes an array as parameter. ' + typeof item_data + ' given');
        return;
    }

    var matchitem_data = function(input, item_dataList) {
        var reg = new RegExp(input.split('').join('\\w*').replace(/\W/, ""), 'i');
        return item_dataList.filter(function(item_data) {
            if (item_data.match(reg)) {
                return item_data;
            }
        });
    };

    var changeInput = function(input, item_dataList) {
        var val = input.val().toLowerCase();
        var res = input.next(); /* res is the autocomplete div which is added immediately after the input */

        res.empty().hide();

        var autoCompleteResult = matchitem_data(val, item_dataList);
        if (val == "" || autoCompleteResult.length == 0) {
            return;
        }

        autoCompleteResult.forEach(function(e) {
            var p = $('<p />');
            p.css({
              'margin': '0px',
              'padding-left': parseInt(input.css('padding-left'),10) + parseInt(input.css('border-left-width'),10),
              'text-align': 'left',
              'font-size': input.css('font-size'),
              'cursor': 'default'
            });

{'fraction_non_alphanumeric': 0.14528182393920203, 'fraction_numerical': 0.011146295123495884, 'mean_word_length': 2.1420612813370474, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '1335069', 'n_tokens_mistral': 2457, 'n_tokens_neox': 2309, 'n_words': 437}