<commit_before>{% extends "colorbox/popup_form_base.html" %}
{% load i18n %}

{% block title %}{% trans "Edit fragments" %}{% endblock %}

{% block extra_head %}
    <script type="text/javascript">
    $(function() {
        $(document).bind('cbox_complete', function() {
            var extra_ids = {};
            parent.$(".coop-fragment-type").each(function (idx, elt) {
                $("select#fragment-types").append('<option value="' + $(elt).attr("rel") + '">' + $(elt).text() + '</option>');
                ;
                extra_ids[$(elt).attr('rel')] = $(elt).attr('data-filter');
            });
            $("select#fragment-types").change(function () {
                var type_id = $(this).val();
                var extra_id = extra_ids[type_id];
                $("tr.field-row").hide();
                $("tr td.ft-id").each(function (idx, elt) {
                    var ff_id = $(elt).closest("tr").find("td.ff-id input").val();
                    if (extra_id && extra_id != '0') {
                        if ($(elt).find("input").val() == type_id && (extra_id == ff_id)) {
                            $(elt).closest("tr").show();
                        }
                    } else {
                        if ($(elt).find("input").val() == type_id) {
                            $(elt).closest("tr").show();
                        }
                    }
                })
                parent.$.colorbox.resize();
            });
            $("select#fragment-types").change();

            $("select").chosen();
            $(".chosen-container").css({width: '140px'});
            //$(".chosen-container input").css({width: '140px'});
        });
    });
    </script>
{% endblock %}

{% block form_url %}{% url "coop_cms_edit_fragments" %}{% endblock %}


{% block form_fields %}
<table class="popup_form">
    <select id="fragment-types">
        
    </select>
    {% for f in form %}
        {% if forloop.counter0 == 0 %}
        <tr>
            {% for field in f %}
                <th>{% if not field.is_hidden %}{{field.label}}{% endif %}</th>
            {% endfor %}
        </tr>
        {% endif %}
        <tr class="field-row">
        {% for field in f %}
            <td class="{% if forloop.counter0 == 0 %}ft-id{% endif %}{% if forloop.counter0 == 1 %}ff-id{% endif %}"><commit_msg>clean js code on popup_edit_fragments<commit_after>{% extends "colorbox/popup_form_base.html" %}
{% load i18n %}

{% block title %}{% trans "Edit fragments" %}{% endblock %}

{% block extra_head %}
    <script type="text/javascript">
    $(function() {
        $(document).bind('cbox_complete', function() {
            var extra_ids = {};
            parent.$(".coop-fragment-type").each(function (idx, elt) {
                $("select#fragment-types").append(
                  '<option value="' + $(elt).attr("rel") + '">' + $(elt).text() + '</option>'
                );
                extra_ids[$(elt).attr('rel')] = $(elt).attr('data-filter');
            });
            $("select#fragment-types").change(function () {
                var type_id = $(this).val();
                var extra_id = extra_ids[type_id];
                $("tr.field-row").hide();
                $("tr td.ft-id").each(function (idx, elt) {
                    var ff_id = $(elt).closest("tr").find("td.ff-id input").val();
                    if (extra_id && extra_id != '0') {
                        if ($(elt).find("input").val() == type_id && (extra_id == ff_id)) {
                            $(elt).closest("tr").show();
                        }
                    } else {
                        if ($(elt).find("input").val() == type_id) {
                            $(elt).closest("tr").show();
                        }
                    }
                });
                parent.$.colorbox.resize();
            });
            $("select#fragment-types").change();

            $("select").chosen();
            $(".chosen-container").css({width: '140px'});
            //$(".chosen-container input").css({width: '140px'});
        });
    });
    </script>
{% endblock %}

{% block form_url %}{% url "coop_cms_edit_fragments" %}{% endblock %}


{% block form_fields %}
<table class="popup_form">
    <select id="fragment-types">
        
    </select>
    {% for f in form %}
        {% if forloop.counter0 == 0 %}
        <tr>
            {% for field in f %}
                <th>{% if not field.is_hidden %}{{field.label}}{% endif %}</th>
            {% endfor %}
        </tr>
        {% endif %}
        <tr class="field-row">
        {% for field in f %}
            <td class="{% if forloop.counter0 == 0 %}ft-id{% endif %}{% if forloop.counter0 == 1 %}ff-id{% endif %}">
{'fraction_non_alphanumeric': 0.20453101842049545, 'fraction_numerical': 0.0063518949820029645, 'mean_word_length': 1.5842450765864333, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '6884234', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1359, 'n_words': 251}