<commit_before>$.fn.lists = function (lists) {
    var element = $(this),

        sectionContainer,

        templateArticle,
        templateWrapper,
        templateName,
        templateButton,
        templateInput,
        templateList,
        templateItem,
        templateItemAnchor,

        urlTemplateString = 'https://www.google.com/search?q=',

        numberOfLists,
        numberOfItems,
        list, item,
        newListArticle,
        newItem,

        dragged;

    // Element wrapper
    sectionContainer = $('<section />')
        .addClass('lists-wrapper')
        .appendTo(element);

    // List Wrapper
    templateArticle = $('<article />')
        .addClass('items-section');

    // Strong Label
    templateName = $('<strong />')
        .appendTo(templateArticle);

    // Input 
    templateWrapper = $('<div />')
        .addClass('add-item-wrapper')
        .appendTo(templateArticle);
    templateButton = $('<a />')
        .addClass('visible')
        .addClass('add-btn')
        .appendTo(templateWrapper);
    templateInput = $('<input />')
        .attr('type', 'text')
        .addClass('add-input')
        .appendTo(templateWrapper);

    // List
    templateList = $('<ul />')
        .appendTo(templateArticle);
    // Inidividual Item
    templateItem = $('<li />')
        .attr('draggable', 'true');
    templateItemAnchor = $('<a />')
        .attr('target', '_blank')
        .appendTo(templateItem);

    // Fill in lists
    numberOfLists = lists.length;
    for (list = 0; list < numberOfLists; list += 1) {
        numberOfItems = lists[list].length;
        newListArticle = templateArticle.clone();
        newListArticle.children('strong').first().html(lists[list][0]);

        for (item = 1; item < numberOfItems; item += 1) {
            templateItemAnchor
                .html(lists[list][item])
                .attr('href', urlTemplateString + lists[list][item]);
            newItem = templateItem.clone();
            newListArticle.children('ul').first().append(newItem);
        }
        newListArticle.find('input').on('keydown', addNewItem);
        newListArticle.appendTo(sectionContainer);
    }

    sectionContainer.on('click', displayInputElement);
    $('li').on('drop', test);
    $('li').on('dragstart', function (event) {
        dragged = $(this);
    });

    function test(event) {
        var target = $(event.target);
        if (target.is('ul')) {

        } else if (target.parents('ul').length > 0) {
            target = target.parents('ul').first();
        } else {
            return;
        }
        dragged.remove();
        dragged.appendTo(target);
    }

    $('li').on('dragenter', function (event) {
        event.preventDefault();
    });
    $('li').on('dragover', function (event) {
        event.preventDefault();
    });

    function displayInputElement(event) {
        var clicked = $(event.target);
        if (!clicked.hasClass('add-btn')) {
            return;
        }
        clicked.removeClass('visible');
        clicked.siblings('input').first().addClass('visible');
    }

    function addNewItem(event) {
        var clicked = $(event.target),
            newItemText,
            newItem;
        if (event.keyCode !== 13) {
            return;
        }
        newItemText = clicked.val();<commit_msg>update: working drag&drop<commit_after>$.fn.lists = function (lists) {
    var element = $(this),

        sectionContainer,

        templateArticle,
        templateWrapper,
        templateName,
        templateButton,
        templateInput,
        templateList,
        templateItem,
        templateItemAnchor,

        urlTemplateString = 'https://www.google.com/search?q=',

        numberOfLists,
        numberOfItems,
        list, item,
        newListArticle,
        newItem,

        dragged;

    // Element wrapper
    sectionContainer = $('<section />')
        .addClass('lists-wrapper')
        .appendTo(element);

    // List Wrapper
    templateArticle = $('<article />')
        .addClass('items-section');

    // Strong Label
    templateName = $('<strong />')
        .appendTo(templateArticle);

    // Input 
    templateWrapper = $('<div />')
        .addClass('add-item-wrapper')
        .appendTo(templateArticle);
    templateButton = $('<a />')
        .addClass('visible')
        .addClass('add-btn')
        .appendTo(templateWrapper);
    templateInput = $('<input />')
        .attr('type', 'text')
        .addClass('add-input')
        .appendTo(templateWrapper);

    // List
    templateList = $('<ul />')
        .appendTo(templateArticle);
    // Inidividual Item
    templateItem = $('<li />')
        .attr('draggable', 'true');
    templateItemAnchor = $('<a />')
        .attr('target', '_blank')
        .appendTo(templateItem);

    // Fill in lists
    numberOfLists = lists.length;
    for (list = 0; list < numberOfLists; list += 1) {
        numberOfItems = lists[list].length;
        newListArticle = templateArticle.clone();
        newListArticle.children('strong').first().html(lists[list][0]);

        for (item = 1; item < numberOfItems; item += 1) {
            templateItemAnchor
                .html(lists[list][item])
                .attr('href', urlTemplateString + lists[list][item]);
            newItem = templateItem.clone();
            newListArticle.children('ul').first().append(newItem);
        }
        newListArticle.find('input').on('keydown', addNewItem);
        newListArticle.appendTo(sectionContainer);
    }

    sectionContainer.on('click', '.add-btn', displayInputElement);
    sectionContainer.on('drop', dropItem);
    sectionContainer.on('dragstart', 'li', function (event) {
        dragged = $(this);
    });
    sectionContainer.on('dragend', 'li', function (event) {
        console.log(event);
    });

    function dropItem(event) {
        var target = $(event.target);
        if (target.is('ul')) {

        } else if (target.parents('.items-section').length > 0) {
            target = target.parents('.items-section').children('ul').first();
        } else {
            return;
        }
        dragged.remove();
        dragged.appendTo(target);
    }

    sectionContainer.on('dragenter', function (event) {
        event.preventDefault();
        event.stopPropagation();
    });
    sectionContainer.on('dragover', function (event) {
        event.preventDefault();
        event.stopPropagation();
    });

    function displayInputElement(event) {
        var clicked = $(event.target);
        clicked.removeClass('visible');
        clicked.siblings('input').first().addClass('visible');
    }

    function addNewItem(event) {
        var clicked = $(event.target),
            newItemText,
            newItem;
        if (event.keyCode !== 13) {
            return;
        }
        newItemText = clicked.val();
{'fraction_non_alphanumeric': 0.1555166885293689, 'fraction_numerical': 0.0023320215711995335, 'mean_word_length': 2.139066788655078, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1561470', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1876, 'n_words': 333}