<commit_before>{% extends "layout.html" %}

{% block stylesheets %}
{{ block.super }}
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}messaging/stylesheets/messaging.css" />
{% endblock %}

{% load paginator_tags %}
{% block javascripts %}
{{ block.super }}
<script type="text/javascript" src="{{ STATIC_URL }}messaging/javascripts/jquery.simplyCountable.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}messaging/javascripts/csrf_ajax.js"></script>
<script type="text/javascript">
    var REC = "recipients";
    
    var update_ui = function() {
        rec = $("body").data(REC);
        if (rec.length == 1) {
            $("#helptext").text("Sending to 1 person.");
        } else {
            $("#helptext").text("Sending to " + rec.length + " people.");
        }
    };
    var reset = function() {
        $("tr.contact").removeClass("selected");
        $("body").data(REC, []);
        $("#compose").val("");
        $("#counter").html("140");
        update_ui();
    };

    $(function(){
        
        // countable
        $('#compose').simplyCountable();
    
        // initialize data 
        $("body").data(REC, []);
        
        // contact add/remove
        $("tr.contact").click(function() {
            id = $(this).attr("id");
            rec = $("body").data(REC);
            if (rec.indexOf(id) != -1) {
                rec.splice(rec.indexOf(id), 1);
                $(this).removeClass("selected");
            } else {
                rec.push(id);
                $(this).addClass("selected");
            }
            update_ui();
            
        });
        
        // send messages
        $("#send").click(function() {
            $("#notifications").removeClass("success error");
            $("#notifications").html("");
            rec = $("body").data(REC);
            text = $("#compose").val();
            if (rec.length > 0 && text.length > 0) {
                // do post
                $.ajax({url: "{% url 'send_message' %}", 
                        type: "POST",
                        data: {"recipients": rec, "text": text},
                        success: function(msg) {
                            $("#notifications").addClass("success");
                            $("#notifications").html(msg);
                        },
                        error: function(msg) {
                            $("#notifications").addClass("error");
                            $("#notifications").html("<strong>Problem sending message! Please contact your administrator if this keeps happening</strong>");
                        }
                       });
                reset();
            } else {
                $("#notifications").addClass("error");
                var not_html = "<strong>Message NOT sent. Please correct the errors below</strong>";
                if (rec.length == 0) {
                    not_html = not_html + "<p>" + "Please specify at least one recipient." + "</p>";<commit_msg>reverted to django 1.4 links<commit_after>{% extends "layout.html" %}

{% block stylesheets %}
{{ block.super }}
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}messaging/stylesheets/messaging.css" />
{% endblock %}

{% load paginator_tags %}
{% block javascripts %}
{{ block.super }}
<script type="text/javascript" src="{{ STATIC_URL }}messaging/javascripts/jquery.simplyCountable.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}messaging/javascripts/csrf_ajax.js"></script>
<script type="text/javascript">
    var REC = "recipients";
    
    var update_ui = function() {
        rec = $("body").data(REC);
        if (rec.length == 1) {
            $("#helptext").text("Sending to 1 person.");
        } else {
            $("#helptext").text("Sending to " + rec.length + " people.");
        }
    };
    var reset = function() {
        $("tr.contact").removeClass("selected");
        $("body").data(REC, []);
        $("#compose").val("");
        $("#counter").html("140");
        update_ui();
    };

    $(function(){
        
        // countable
        $('#compose').simplyCountable();
    
        // initialize data 
        $("body").data(REC, []);
        
        // contact add/remove
        $("tr.contact").click(function() {
            id = $(this).attr("id");
            rec = $("body").data(REC);
            if (rec.indexOf(id) != -1) {
                rec.splice(rec.indexOf(id), 1);
                $(this).removeClass("selected");
            } else {
                rec.push(id);
                $(this).addClass("selected");
            }
            update_ui();
            
        });
        
        // send messages
        $("#send").click(function() {
            $("#notifications").removeClass("success error");
            $("#notifications").html("");
            rec = $("body").data(REC);
            text = $("#compose").val();
            if (rec.length > 0 && text.length > 0) {
                // do post
                $.ajax({url: "{% url send_message %}", 
                        type: "POST",
                        data: {"recipients": rec, "text": text},
                        success: function(msg) {
                            $("#notifications").addClass("success");
                            $("#notifications").html(msg);
                        },
                        error: function(msg) {
                            $("#notifications").addClass("error");
                            $("#notifications").html("<strong>Problem sending message! Please contact your administrator if this keeps happening</strong>");
                        }
                       });
                reset();
            } else {
                $("#notifications").addClass("error");
                var not_html = "<strong>Message NOT sent. Please correct the errors below</strong>";
                if (rec.length == 0) {
                    not_html = not_html + "<p>" + "Please specify at least one recipient." + "</p>";
{'fraction_non_alphanumeric': 0.18086696562032886, 'fraction_numerical': 0.0036538780933399765, 'mean_word_length': 1.6205395996518712, 'pattern_counts': {'":': 4, '<': 27, '<?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': '2014714', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1549, 'n_words': 307}