<commit_before>{% extends 'HUBerlinEPLiteProBundle::layout.html.twig' %}

{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('bundles/huberlineplitepro/css/groups.css') }}" />
<link rel="stylesheet" href="{{ asset('bundles/huberlineplitepro/css/grouppic.css') }}" />
<link rel="stylesheet" href="{{ asset('bundles/huberlineplitepro/css/pad.css') }}" />
{% endblock %}

{% block javascript %}
{{ parent() }}
<script src="{{ asset('bundles/huberlineplitepro/js/jquery.iframe-post-form.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/jquery.blockUI.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/groupPicture.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/flashmessages.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/pad.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/groups.js') }}" ></script>

<script type="text/javascript">
$(function() {
	// Collapse other groups 
    $('.group-content').hide();

    // Hide actions
    $('.actions').hide();

    // Hide usernames and enable showUsernamesHandler
    usernamesHandler();
    // Add Submithandler to the newuser form
    newUserHandler();

    // Hide flash messages with a click
    flashmessages.clickHandler();

    // Add Handler for "remove group"
    $('.group_delete').each(function() {
        removeGroupHandler($(this));
    });
    

    // initialise group picture upload
	var uploadGroupPicture = new UploadGroupPicture({
	    pathRemovePic: "{{ asset('bundles/huberlineplitepro/images/delete_red.png') }}",
	    pathOrigPic: $('#headerpic').attr('src')
	});

    // Click handler for "new pad"
    $('.pads .newpadlink').show();
	$('.pads .newpadlink').click(function(e) {
		e.preventDefault();
	    var obj = $(this);
	    obj.parent().find('.newpadform').slideToggle();
		});
	
    // Prepare newpadform 
	var newpadform = $('.pads .newpadform');
	
    // Add submit handler for this form
    newpadform.submit(function(e){
        e.preventDefault();
        var obj = $(this);
        var padsloader = obj.parent().find('.loader'); 
        padsloader.show();

    	var $form = $(this), 
        fname = $form.find('input[name="form[name]"]').val(), 
        ftoken = $form.find('input[name="form[_token]"]').val(), 
        url = $form.attr('action');

    	// Hide the form
    	$form.find('input[name="form[name]"]').val('');
    	newpadform.slideUp();

        var posting = $.post (url, {'form[name]':fname, 'form[_token]':ftoken })
        .done(function (data) {
            data = $(data);
            padsloader.hide();
            var padscontent = obj.parent().parent().find('.content');
            padscontent.append(data.find('#pads .pad').last().hide());
            padscontent.find('.pad:last').show('drop');
            removePadHandler(padscontent);
            openPadAndGroupHandler(padscontent, padscontent.closest('.group'), uploadGroupPicture);
        });
    
    });

    // Ajax call for expanding group, if clicked
    $('.group-link').click(function(e) {
        e.preventDefault();
        
        var obj = $(this);
        var parent = obj.parent();
        var group = obj.parent().parent();
        var group_content = group.find('.group-content');

        if (group_content.hasClass('expanded-new')) {
            group_content.slideUp();
            group_content.removeClass('expanded-new');
        }
        else if (!group_content.hasClass('expanded')) {

            // Close other new expanded groups
            $('.group-content.expanded-new').slideUp();
            $('.group-content.expanded-new').removeClass('expanded-new');

        	// Prepare loading process
            parent.find('.loader').show();
            group_content.slideUp();
    
            // Get the pads
            $.get(obj.attr('href'), function(data) {
                data = $(data);
    
                // Add the pads in this page
                var padscontent = group.find('.pads .content');
                padscontent.empty();
                padscontent.append(data.find('#pads').html());
    
                // Add click handler for openPad
                openPadAndGroupHandler(padscontent, group, uploadGroupPicture);
                
                // Add click handler for removePad
                removePadHandler(padscontent);
                parent.find('.loader').hide();

                // Hide Removepad icon
                padscontent.find('.actions').hide();
    
                // Add "new pad" form under the pads
                newpadform.empty().append(data.find('#newpad').html());
                newpadform.hide();
    
                // expand actual group
                group_content.slideDown();
                group_content.addClass('expanded-new');
    
                // If no pad is open yet, open first one
                if($('#pad-content').hasClass('empty')) {
                    padscontent.find('a:first').click();    
                }
                
            });
        }
    });

    // Trigger click for first group
    $('.group:first .group-link').click();

    // Show group_edit
    var editgroup = $('.group .editgroup');
    editgroup.show();

    // Edit group, form click handler
    editgroup.click(function(e) {
        e.preventDefault();
        var groupname = $(this).parent().parent();
        var name = groupname.find('.group-link').text();
        groupname.find('.editform input[name="groupname"]').val(name);
        groupname.find('.group-link').toggle();
        groupname.find('.editform').toggle();
        groupname.find('.editform input[name="groupname"]').focus();
    });

    // form submit handler
    $('.group .editform').submit(function(e) {
        e.preventDefault();
        
        var $form = $(this), 
        fname = $form.find('input[name="groupname"]').val(), 
        url = $form.attr('action');

        var groupname = $form.parent(); 

        var editloader = $form.find('.editloader');
        editloader.show();
        
        $.post (url, {'groupname':fname })
        .done(function (data) {
            groupname.find('.group-link').text(data.newname);
            editloader.hide();
            groupname.find('.group-link').toggle();
            groupname.find('.editform').toggle();
        });
    });

    $('#togglegroups').click(function(e){
        e.preventDefault();
        $('#groups-menu').toggle();
        $('#pad').toggleClass('fullwidth');
        $(this).find('img').toggle();
    });
    
});
</script>
{% endblock %}

{% block content %}
<div id="groups-menu">
    <div id="groups">
    {% for group in groups %}
    <div id="group-{{ group.id }}" class="group">
        <div class="group-name">
            <a class="group-link" href="{{ path('group', {id: group.id}) }}">{{ group.name }}</a>
            <form class="editform" action="{{ path('group_rename', {id: group.id}) }}" method="post" style="display: none">
                <input type="text" name="groupname" maxlength="45" >
                <img width="20" class="editloader" style="display: none" src="{{ asset('bundles/huberlineplitepro/images/loader.gif') }}"/>
            </form>
            <span class="actions">
                <a href="#" style="display: none" class="editgroup" ><img src="{{ asset('bundles/huberlineplitepro/images/edit.png') }}" /> </a>
                <a href="{{ path('group_delete', {id: group.id}) }}" class="group_delete {% if group.user.count == 1 %}last{% endif %}"> <img src="{{ asset('bundles/huberlineplitepro/images/delete.png') }}" /> </a>
            </span>
            <img width="20" class="loader" style="display: none" src="{{ asset('bundles/huberlineplitepro/images/loader.gif') }}"/>
        </div>
        <div class="group-content">
            <div class="info">
                <span class="creationdate">({{ group.creationdate.date | date('d.m.Y')}})</span>
            </div>
            <div class="user">
                <a href="#" class="userinfo" style="display: none">{{ 'user'|trans }} ({{ group.user.count }}) <img alt="plus" src="{{ asset('bundles/huberlineplitepro/images/plus.png') }}" /><img alt="minus" src="{{ asset('bundles/huberlineplitepro/images/minus.png') }}" style="display:none"/></a>
                <div class="usernames">
                    <span>{% for user in group.user %} <span class="{% if user.isactivated == false %}notactivated{% endif %}" title="{{ user.uid }}{% if user.isactivated == false %} (not activated){% endif %}">{{ user.name }}</span>&nbsp;{% endfor %}</span>
                    <form class="adduserform" action="{{ path('group_addUser', {id: group.id}) }}" method="post">
                        <input type="text" placeholder="{{ 'newuser'|trans }}" name="username" maxlength="45" />
                        <input type="submit" />
                    </form>
                </div>
            </div>
            <div class="pads">
                <div class="content"></div>
                <div class="newpad">
                    <div><img width="20" class="loader" style="display: none" src="{{ asset('bundles/huberlineplitepro/images/loader.gif') }}"/></div>
                    <a href="#" class="newpadlink" style="display: none;" >{{ 'newpad'|trans }}</a>
                    <form class="newpadform" action="{{ path('group', {id: group.id}) }}" method="post" {{ form_enctype(form) }}>
                    </form>
                </div>
            </div>
            <input type="hidden" name="pathAdd" value="{{ path('group_addPicture', {id: group.id}) }}" />
            <input type="hidden" name="pathRemove" value="{{ path('group_removePicture', {id: group.id}) }}" />
            <input type="hidden" name="picUrl" value="{% if group.getWebPath is not null %}{{ group.getWebPath }}{% endif %}" />
        </div>
    </div>
    {% endfor %}
    </div>    
    <br/>

    <h2>{{ 'newgroup'|trans }}</h2>
    <form action="{{ path('base') }}" method="post" {{ form_enctype(form) }}>
        {{ form_errors(form) }}
        <div>
            {{ form_errors(form.name) }}
            {{ form_widget(form.name) }}
        </div>
        {{ form_rest(form) }}
        <input type="submit" />
    </form>
    </div>
    
    <div id="pad">
        <div id="togglegroups" >
            <a href="#">
                <img class="left" alt="Hide Groups" src="{{ asset('bundles/huberlineplitepro/images/left.png') }}" />
                <img class="right" alt="Show Groups" src="{{ asset('bundles/huberlineplitepro/images/right.png') }}" style="display:none"/>
                </a>
        </div>
        <div id="pad-content" class="empty"></div>
    </div>

    <img src="{{ asset('bundles/huberlineplitepro/images/loader-bar.gif') }}" id="loader-bar" style="display: none"></img>
    
    <div id="removeDialogs" style="display: none">
        <div id="removeGroupDialog" style="display: none">{{ 'removeGroupDialog'|trans }}</div>
        <div id="removeGroupLastDialog" style="display: none">{{ 'removeGroupLastDialog'|trans }}</div>
        <div id="removePadDialog" style="display: none">{{ 'removePadDialog'|trans }}</div>
        <input type="button" class="yes" value="{{ 'yes'|trans }}"/>
        <input type="button" class="no" value="{{ 'no'|trans }}"/>
    </div>
{% endblock %}<commit_msg>better comments<commit_after>{% extends 'HUBerlinEPLiteProBundle::layout.html.twig' %}

{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('bundles/huberlineplitepro/css/groups.css') }}" />
<link rel="stylesheet" href="{{ asset('bundles/huberlineplitepro/css/grouppic.css') }}" />
<link rel="stylesheet" href="{{ asset('bundles/huberlineplitepro/css/pad.css') }}" />
{% endblock %}

{% block javascript %}
{{ parent() }}
<script src="{{ asset('bundles/huberlineplitepro/js/jquery.iframe-post-form.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/jquery.blockUI.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/groupPicture.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/flashmessages.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/pad.js') }}"></script>
<script src="{{ asset('bundles/huberlineplitepro/js/groups.js') }}" ></script>

<script type="text/javascript">
$(function() {
	// Collapse other groups 
    $('.group-content').hide();

    // Hide actions
    $('.actions').hide();

    // Hide usernames and enable showUsernamesHandler
    usernamesHandler();
    // Add Submithandler to the newuser form
    newUserHandler();

    // Hide flash messages with a click
    flashmessages.clickHandler();

    // Add Handler for "remove group"
    $('.group_delete').each(function() {
        removeGroupHandler($(this));
    });
    

    // initialise group picture upload
	var uploadGroupPicture = new UploadGroupPicture({
	    pathRemovePic: "{{ asset('bundles/huberlineplitepro/images/delete_red.png') }}",
	    pathOrigPic: $('#headerpic').attr('src')
	});

    // Click handler for "new pad"
    $('.pads .newpadlink').show();
	$('.pads .newpadlink').click(function(e) {
		e.preventDefault();
	    var obj = $(this);
	    obj.parent().find('.newpadform').slideToggle();
		});
	
    // Prepare newpadform 
	var newpadform = $('.pads .newpadform');
	
    // Add submit handler for this form
    newpadform.submit(function(e){
        e.preventDefault();
        var obj = $(this);
        var padsloader = obj.parent().find('.loader'); 
        padsloader.show();

    	var $form = $(this), 
        fname = $form.find('input[name="form[name]"]').val(), 
        ftoken = $form.find('input[name="form[_token]"]').val(), 
        url = $form.attr('action');

    	// Hide the form
    	$form.find('input[name="form[name]"]').val('');
    	newpadform.slideUp();

        var posting = $.post (url, {'form[name]':fname, 'form[_token]':ftoken })
        .done(function (data) {
            data = $(data);
            padsloader.hide();
            var padscontent = obj.parent().parent().find('.content');
            padscontent.append(data.find('#pads .pad').last().hide());
            padscontent.find('.pad:last').show('drop');
            removePadHandler(padscontent);
            openPadAndGroupHandler(padscontent, padscontent.closest('.group'), uploadGroupPicture);
        });
    
    });

    // Ajax call for expanding group, if clicked
    $('.group-link').click(function(e) {
        e.preventDefault();
        
        var obj = $(this);
        var parent = obj.parent();
        var group = obj.parent().parent();
        var group_content = group.find('.group-content');

        if (group_content.hasClass('expanded-new')) {
            group_content.slideUp();
            group_content.removeClass('expanded-new');
        }
        else if (!group_content.hasClass('expanded')) {

            // Close other new expanded groups
            $('.group-content.expanded-new').slideUp();
            $('.group-content.expanded-new').removeClass('expanded-new');

        	// Prepare loading process
            parent.find('.loader').show();
            group_content.slideUp();
    
            // Get the pads
            $.get(obj.attr('href'), function(data) {
                data = $(data);
    
                // Add the pads in this page
                var padscontent = group.find('.pads .content');
                padscontent.empty();
                padscontent.append(data.find('#pads').html());
    
                // Add click handler for openPad
                openPadAndGroupHandler(padscontent, group, uploadGroupPicture);
                
                // Add click handler for removePad
                removePadHandler(padscontent);
                parent.find('.loader').hide();

                // Hide Removepad icon
                padscontent.find('.actions').hide();
    
                // Add "new pad" form under the pads
                newpadform.empty().append(data.find('#newpad').html());
                newpadform.hide();
    
                // expand actual group
                group_content.slideDown();
                group_content.addClass('expanded-new');
    
                // If no pad is open yet, open first one
                if($('#pad-content').hasClass('empty')) {
                    padscontent.find('a:first').click();    
                }
                
            });
        }
    });

    // Trigger click for first group
    $('.group:first .group-link').click();

    // Show group_edit button
    var editgroup = $('.group .editgroup');
    editgroup.show();

    // Edit groupname click handler
    editgroup.click(function(e) {
        e.preventDefault();
        var groupname = $(this).parent().parent();
        var name = groupname.find('.group-link').text();
        groupname.find('.editform input[name="groupname"]').val(name);
        groupname.find('.group-link').toggle();
        groupname.find('.editform').toggle();
        groupname.find('.editform input[name="groupname"]').focus();
    });

    // groupname form submit handler
    $('.group .editform').submit(function(e) {
        e.preventDefault();
        
        var $form = $(this), 
        fname = $form.find('input[name="groupname"]').val(), 
        url = $form.attr('action');

        var groupname = $form.parent(); 

        var editloader = $form.find('.editloader');
        editloader.show();
        
        $.post (url, {'groupname':fname })
        .done(function (data) {
            groupname.find('.group-link').text(data.newname);
            editloader.hide();
            groupname.find('.group-link').toggle();
            groupname.find('.editform').toggle();
        });
    });

    $('#togglegroups').click(function(e){
        e.preventDefault();
        $('#groups-menu').toggle();
        $('#pad').toggleClass('fullwidth');
        $(this).find('img').toggle();
    });
    
});
</script>
{% endblock %}

{% block content %}
<div id="groups-menu">
    <div id="groups">
    {% for group in groups %}
    <div id="group-{{ group.id }}" class="group">
        <div class="group-name">
            <a class="group-link" href="{{ path('group', {id: group.id}) }}">{{ group.name }}</a>
            <form class="editform" action="{{ path('group_rename', {id: group.id}) }}" method="post" style="display: none">
                <input type="text" name="groupname" maxlength="45" >
                <img width="20" class="editloader" style="display: none" src="{{ asset('bundles/huberlineplitepro/images/loader.gif') }}"/>
            </form>
            <span class="actions">
                <a href="#" style="display: none" class="editgroup" ><img src="{{ asset('bundles/huberlineplitepro/images/edit.png') }}" /> </a>
                <a href="{{ path('group_delete', {id: group.id}) }}" class="group_delete {% if group.user.count == 1 %}last{% endif %}"> <img src="{{ asset('bundles/huberlineplitepro/images/delete.png') }}" /> </a>
            </span>
            <img width="20" class="loader" style="display: none" src="{{ asset('bundles/huberlineplitepro/images/loader.gif') }}"/>
        </div>
        <div class="group-content">
            <div class="info">
                <span class="creationdate">({{ group.creationdate.date | date('d.m.Y')}})</span>
            </div>
            <div class="user">
                <a href="#" class="userinfo" style="display: none">{{ 'user'|trans }} ({{ group.user.count }}) <img alt="plus" src="{{ asset('bundles/huberlineplitepro/images/plus.png') }}" /><img alt="minus" src="{{ asset('bundles/huberlineplitepro/images/minus.png') }}" style="display:none"/></a>
                <div class="usernames">
                    <span>{% for user in group.user %} <span class="{% if user.isactivated == false %}notactivated{% endif %}" title="{{ user.uid }}{% if user.isactivated == false %} (not activated){% endif %}">{{ user.name }}</span>&nbsp;{% endfor %}</span>
                    <form class="adduserform" action="{{ path('group_addUser', {id: group.id}) }}" method="post">
                        <input type="text" placeholder="{{ 'newuser'|trans }}" name="username" maxlength="45" />
                        <input type="submit" />
                    </form>
                </div>
            </div>
            <div class="pads">
                <div class="content"></div>
                <div class="newpad">
                    <div><img width="20" class="loader" style="display: none" src="{{ asset('bundles/huberlineplitepro/images/loader.gif') }}"/></div>
                    <a href="#" class="newpadlink" style="display: none;" >{{ 'newpad'|trans }}</a>
                    <form class="newpadform" action="{{ path('group', {id: group.id}) }}" method="post" {{ form_enctype(form) }}>
                    </form>
                </div>
            </div>
            <input type="hidden" name="pathAdd" value="{{ path('group_addPicture', {id: group.id}) }}" />
            <input type="hidden" name="pathRemove" value="{{ path('group_removePicture', {id: group.id}) }}" />
            <input type="hidden" name="picUrl" value="{% if group.getWebPath is not null %}{{ group.getWebPath }}{% endif %}" />
        </div>
    </div>
    {% endfor %}
    </div>    
    <br/>

    <h2>{{ 'newgroup'|trans }}</h2>
    <form action="{{ path('base') }}" method="post" {{ form_enctype(form) }}>
        {{ form_errors(form) }}
        <div>
            {{ form_errors(form.name) }}
            {{ form_widget(form.name) }}
        </div>
        {{ form_rest(form) }}
        <input type="submit" />
    </form>
    </div>
    
    <div id="pad">
        <div id="togglegroups" >
            <a href="#">
                <img class="left" alt="Hide Groups" src="{{ asset('bundles/huberlineplitepro/images/left.png') }}" />
                <img class="right" alt="Show Groups" src="{{ asset('bundles/huberlineplitepro/images/right.png') }}" style="display:none"/>
                </a>
        </div>
        <div id="pad-content" class="empty"></div>
    </div>

    <img src="{{ asset('bundles/huberlineplitepro/images/loader-bar.gif') }}" id="loader-bar" style="display: none"></img>
    
    <div id="removeDialogs" style="display: none">
        <div id="removeGroupDialog" style="display: none">{{ 'removeGroupDialog'|trans }}</div>
        <div id="removeGroupLastDialog" style="display: none">{{ 'removeGroupLastDialog'|trans }}</div>
        <div id="removePadDialog" style="display: none">{{ 'removePadDialog'|trans }}</div>
        <input type="button" class="yes" value="{{ 'yes'|trans }}"/>
        <input type="button" class="no" value="{{ 'no'|trans }}"/>
    </div>
{% endblock %}
{'fraction_non_alphanumeric': 0.19442122398697698, 'fraction_numerical': 0.0011439130626072417, 'mean_word_length': 2.401167140505761, 'pattern_counts': {'":': 0, '<': 219, '<?xml version=': 0, '>': 219, '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': '982527', 'n_tokens_mistral': 6917, 'n_tokens_neox': 6603, 'n_words': 1268}