<commit_before>var list_tag = []

//Suggestion tags when create or edit post
Array.prototype.remove = function() {
    var what, a = arguments, L = a.length, ax;
    while (L && this.length) {
        what = a[--L];
        while ((ax = this.indexOf(what)) !== -1) {
            this.splice(ax, 1);
        }
    }
    return this;
};

function updateTags(){
    $("#tags").val(window.list_tag.join(","));
    $(".post-tag").remove();
    for(var i = 0;i < window.list_tag.length; i++){
        $('<span class="post-tag">'+window.list_tag[i]+'<span class="delete-tag" title="remove this tag"></span></span>').insertBefore("#tag-input");
    }
    $(".delete-tag").click(function(){
        $(this).parent().remove();
        tag = $(this).parent().html()
        tag = tag.split("<span")[0];
        tag = tag.replace(/\s+/g, '');
        window.list_tag.remove(tag);
        updateTags();
    });
}
$(document).ready(function() {
    $("#tag-input").bind( "keyup", function( event ) {
        $.ajax({
            type: 'GET',
            url: baseUri + controller + '/' + 'tags-suggestions',
            dataType: 'html',
            data: {
                'q': $(this).val()
            },
            success: function (data) {
                $('.tag-suggestion-wrapper').html(data)
            },
            error: function( xhr, status ) {
            },
            complete: function( xhr, status ) {
            }
        });
    });

    $(document).on("click",".item-multiplier",function(){
        var content = $(this).html();
        tag = content.split("<span")[0];
        tag = tag.replace(/\s+/g, '');
        if(window.list_tag.indexOf(tag) == -1){
            window.list_tag.push(tag);
        }
        updateTags();
        $("#tag-input").val("");
    });
    //Separate each tag
    $("#tag-input").keypress(function(event){
        if(event.which == 32){
            tag = $(this).val();
            tag = tag.replace(/\s+/g, '');
            if(window.list_tag.indexOf(tag) == -1){
                window.list_tag.push(tag);
            }
            updateTags();
            $(this).val("");

        }
    });
    //Remove lats item comma when edit a posts
    if ($('#tags').val()) {
        var tagValues = $('#tags').val().replace(/,\s*$/, "");
        $('#tags').val(tagValues);
        var tagArray = tagValues.split(','), name = [];
        tagArray.forEach(function (element, index){
            var val= '<span class="post-tag">' + element + '<span title="remove this tag" class="delete-tag"></span></span>';
            $('.tag-editor').prepend(val);
        });
    };<commit_msg>Improve tag suggest display<commit_after>var list_tag = []

//Suggestion tags when create or edit post
Array.prototype.remove = function() {
    var what, a = arguments, L = a.length, ax;
    while (L && this.length) {
        what = a[--L];
        while ((ax = this.indexOf(what)) !== -1) {
            this.splice(ax, 1);
        }
    }
    return this;
};

function updateTags(){
    $("#tags").val(window.list_tag.join(","));
    $(".post-tag").remove();
    for(var i = 0;i < window.list_tag.length; i++){
        $('<span class="post-tag">'+window.list_tag[i]+'<span class="delete-tag" title="remove this tag"></span></span>').insertBefore("#tag-input");
    }
    $(".delete-tag").click(function(){
        $(this).parent().remove();
        tag = $(this).parent().html()
        tag = tag.split("<span")[0];
        tag = tag.replace(/\s+/g, '');
        window.list_tag.remove(tag);
        updateTags();
    });
}
$(document).ready(function() {
    $("#tag-input").bind( "keyup", function( event ) {
        $.ajax({
            type: 'GET',
            url: baseUri + controller + '/' + 'tags-suggestions',
            dataType: 'html',
            data: {
                'q': $(this).val()
            },
            success: function (data) {
                $('.tag-suggestion-wrapper').html(data)
            },
            error: function( xhr, status ) {
            },
            complete: function( xhr, status ) {
            }
        });
    });

    $(document).on("click",".item-multiplier",function(){
        var content = $(this).html();
        tag = content.split("<span")[0];
        tag = tag.replace(/\s+/g, '');
        if(window.list_tag.indexOf(tag) == -1){
            window.list_tag.push(tag);
        }
        updateTags();
        $("#tag-input").val("");
    });
    //Separate each tag
    $("#tag-input").keyup(function(event){
        if(event.which == 32){
            tag = $(this).val();
            tag = tag.replace(/\s+/g, '');
            if(tag.length > 0){
                if(window.list_tag.indexOf(tag) == -1){
                    window.list_tag.push(tag);
                }
                updateTags();
            }
            $(this).val("");

        }
        if(event.which == 8){
            if($(this).val() == ""){
                window.list_tag.pop();
                updateTags();
            }
        }
    });
    //Remove lats item comma when edit a posts
    if ($('#tags').val()) {
        var tagValues = $('#tags').val().replace(/,\s*$/, "");
        $('#tags').val(tagValues);
        var tagArray = tagValues.split(','), name = [];
        tagArray.forEach(function (element, index){
            var val= '<span class="post-tag">' + element + '<span title="remove this tag" class="delete-tag"></span></span>';
            $('.tag-editor').prepend(val);
        });
    };
{'fraction_non_alphanumeric': 0.21226501186347874, 'fraction_numerical': 0.003650301149844862, 'mean_word_length': 1.8174807197943446, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 20, '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': '5492787', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1658, 'n_words': 300}