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

{% block dynamic_javascripts %}
    var postId = null;
    var groupId = null;

    var groups = {
        state0: {
            title: 'Move Post',
            html:'<label>Move post to</label>'+
                '<select name="groupId">'+
                {% for group in groups %}
                    '<option value="{{ group.shortUrl }}">{{ group.title }}</option>'+
                {% endfor %}
                '</select>',
            buttons: { Submit: 1 },
            focus: 1,
            submit:function(e,v,m,f){
                e.preventDefault();
            
                var data = {};
                data["postId"] = postId;
                data["groupId"] = f.groupId;
            
                // fire off the request
                request = $.ajax({
                    url: "{{ path('CobaseAppBundle_post_move')}}",
                    type: "post",
                    data: data
                });
        
                // callback handler that will be called on success
                request.done(function (response, textStatus, jqXHR){
                    var data = jQuery.parseJSON(response);
                    window.location.href = data.url;
                });
        
                // callback handler that will be called on failure
                request.fail(function (jqXHR, textStatus, errorThrown){
                    alert("An error occured. Could not move post to selected group.");
                });
        
                if(v==1) $.prompt.close();
                if(v==-1) $.prompt.goToState('state0');
            }
        },
    };

    var deletes = {
        state0: {
            title: 'Delete Post ',
            html:'<label>Are you sure you want to delete this post?</label>',
            buttons: { OK: 1 },
            focus: 1,
            submit:function(e,v,m,f){
                e.preventDefault();
            
                var data = {};
                data["postId"] = postId;
                data["groupId"] = groupId;
    
                // fire off the request
                request = $.ajax({
                    url: "{{ path('CobaseAppBundle_post_delete')}}",
                    type: "post",
                    data: data
                });
            
                // callback handler that will be called on success
                request.done(function (response, textStatus, jqXHR){
                    var data = jQuery.parseJSON(response);
                    window.location.href = data.url;
                });
            
                // callback handler that will be called on failure
                request.fail(function (jqXHR, textStatus, errorThrown){
                    alert("An error occured. Could not delete post.");
                });
        
                if(v==1) $.prompt.close();
                if(v==-1) $.prompt.goToState('state0');
            }
        },
    };

    $( ".move-post-link" )
        .click(function(e) {
            e.preventDefault();
            postId = $(this).attr("data-id");
            $.prompt(groups);
    });

    $( ".delete-post-link" )
        .click(function(e) {
            e.preventDefault();
            postId = $(this).attr("data-id");
            groupId = $(this).attr("data-group-id");
            $.prompt(deletes);
    });
{% endblock %}

{% block content %}
    <h2>Home
        <span class="info">Overview of latest activity in groups you have subcribed to.</span>
    </h2>

    {% for flashMessage in app.session.flashbag.get('subscription.transaction') %}
        <div class="alert alert-success fade in">
            {{ flashMessage }}
        </div>
    {% endfor %}
    <commit_msg>Renamed variable<commit_after>{% extends 'CobaseAppBundle::layout.html.twig' %}

{% block dynamic_javascripts %}
    var postId = null;
    var groupId = null;

    var moves = {
        state0: {
            title: 'Move Post',
            html:'<label>Move post to</label>'+
                '<select name="groupId">'+
                {% for group in groups %}
                    '<option value="{{ group.shortUrl }}">{{ group.title }}</option>'+
                {% endfor %}
                '</select>',
            buttons: { Submit: 1 },
            focus: 1,
            submit:function(e,v,m,f){
                e.preventDefault();
            
                var data = {};
                data["postId"] = postId;
                data["groupId"] = f.groupId;
            
                // fire off the request
                request = $.ajax({
                    url: "{{ path('CobaseAppBundle_post_move')}}",
                    type: "post",
                    data: data
                });
        
                // callback handler that will be called on success
                request.done(function (response, textStatus, jqXHR){
                    var data = jQuery.parseJSON(response);
                    window.location.href = data.url;
                });
        
                // callback handler that will be called on failure
                request.fail(function (jqXHR, textStatus, errorThrown){
                    alert("An error occured. Could not move post to selected group.");
                });
        
                if(v==1) $.prompt.close();
                if(v==-1) $.prompt.goToState('state0');
            }
        },
    };

    var deletes = {
        state0: {
            title: 'Delete Post ',
            html:'<label>Are you sure you want to delete this post?</label>',
            buttons: { OK: 1 },
            focus: 1,
            submit:function(e,v,m,f){
                e.preventDefault();
            
                var data = {};
                data["postId"] = postId;
                data["groupId"] = groupId;
    
                // fire off the request
                request = $.ajax({
                    url: "{{ path('CobaseAppBundle_post_delete')}}",
                    type: "post",
                    data: data
                });
            
                // callback handler that will be called on success
                request.done(function (response, textStatus, jqXHR){
                    var data = jQuery.parseJSON(response);
                    window.location.href = data.url;
                });
            
                // callback handler that will be called on failure
                request.fail(function (jqXHR, textStatus, errorThrown){
                    alert("An error occured. Could not delete post.");
                });
        
                if(v==1) $.prompt.close();
                if(v==-1) $.prompt.goToState('state0');
            }
        },
    };

    $( ".move-post-link" )
        .click(function(e) {
            e.preventDefault();
            postId = $(this).attr("data-id");
            $.prompt(moves);
    });

    $( ".delete-post-link" )
        .click(function(e) {
            e.preventDefault();
            postId = $(this).attr("data-id");
            groupId = $(this).attr("data-group-id");
            $.prompt(deletes);
    });
{% endblock %}

{% block content %}
    <h2>Home
        <span class="info">Overview of latest activity in groups you have subcribed to.</span>
    </h2>

    {% for flashMessage in app.session.flashbag.get('subscription.transaction') %}
        <div class="alert alert-success fade in">
            {{ flashMessage }}
        </div>
    {% endfor %}
    
{'fraction_non_alphanumeric': 0.13226452905811623, 'fraction_numerical': 0.0037408149632598532, 'mean_word_length': 1.2440047961630696, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '933947', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1875, 'n_words': 447}