<commit_before>/**
 * Created by atan on 9/14/16.
 */

"use strict";

$(document).ready(function () {

    $("input[name='tz-name']").val(jstz.determine().name());


    // Prevent user from entering a non numeric value into phone and fax field
    $("#phone").keypress(function (key) {
        if (key.charCode != 0) {
            if (key.charCode < 48 || key.charCode > 57) {
                key.preventDefault();
            }
        }
    });
    $("#fax").keypress(function (key) {
        if (key.charCode != 0) {
            if (key.charCode < 48 || key.charCode > 57) {
                key.preventDefault();
            }
        }
    });

    // ajax call to get additional information for the specified agency
    var selectedAgency = $("#request-agency").val();
    var requestInstructionsDiv = $("#request-agency-instructions");
    var requestInstructionsContentDiv = $("#request-agency-instructions-content");
    $.ajax({
        url: "/agency/feature/" + selectedAgency + "/" + "specific_request_instructions",
        type: "GET",
        success: function (data) {
            if (data["specific_request_instructions"]["text"] !== "") {
                requestInstructionsContentDiv.html("<p>" + data["specific_request_instructions"]["text"] + "</p>");
                requestInstructionsDiv.show();
            }
            else {
                requestInstructionsDiv.hide();
            }
        },
        error: function () {
            requestInstructionsDiv.hide();
        }

    });

    $("#request-agency-instructions-toggle").click(function () {
        var el = $("#request-agency-instructions-toggle");
        var requestInstructionsContentDiv = $("#request-agency-instructions-content");
        var hideHtml = "<button type=\"button\" id=\"request-agency-instructions-btn\" class=\"btn btn-block btn-info\"><span class=\"glyphicon glyphicon-chevron-up\"></span>&nbsp;&nbsp;Hide Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-up\"></span></button>";
        var showHtml = "<button type=\"button\" id=\"request-agency-instructions-btn\" class=\"btn btn-block btn-info\"><span class=\"glyphicon glyphicon-chevron-down\"></span>&nbsp;&nbsp;Show Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-down\"></span></button>";
        if (el.html() === showHtml) {
            el.html(hideHtml);
            requestInstructionsContentDiv.show();
        } else {
            el.html(showHtml);
            requestInstructionsContentDiv.hide();
        }
    });

    // javascript to add tooltip popovers when selecting the title and description
    $("#request-title").attr({
        'data-placement': "top",
        'data-trigger': "hover focus",
        'data-toggle': "popover",
        'data-content': "Public Advocate Emails from 2015",
        title: "Example Title"
    });
    $("#request-title").popover();
    // $("#request-title").click(function(){
    //     $("#request-title").popover("show");
    // });

    $("#request-description").attr({
        'data-placement': "top",
        'data-trigger': "hover focus",
        'data-toggle': "popover",
        'data-content': "Topic: Public Advocate Emails from 2015. Emails that mention bike lanes or bicycle lanes from the Public Advocate's Office between July 27, 2015 and September 10, 2015.",
        title: "Example Request"
    });
    $("#request-description").click(function () {
        $("#request-description").popover("show");
    });
    $("#request-description").popover();
    // $("#request-description").click(function(){
    //     $("#request-description").popover("show");
    // });

    // jQuery mask plugin to format fields
    $("#phone").mask("(999) 999-9999");
    $("#fax").mask("(999) 999-9999");
    $("#zipcode").mask("99999");

    // Datepicker for date request was received when creating a new request
    $(".dtpick").datepicker({
        dateFormat: "mm/dd/yy",
        maxDate: 0
    }).keydown(function (e) {
        // prevent keyboard input except for tab
        if (e.keyCode !== 9)
            e.preventDefault();
    });

    // Loop through required fields and apply a data-parsley-required attribute to them
    var requiredFields = ['request-title", "request-description", "first-name", "last-name", "email',
        'phone", "fax", "address-line-1", "method-received", "request-date", "city", "zipcode'];
    for (var i = 0; i < requiredFields.length; i++) {
        $("#" + requiredFields[i]).attr("data-parsley-required", "");
    }

    // Apply parsley validation styles to the input forms for a new request.
    $("#request-title").attr("data-parsley-maxlength", 90);
    $("#request-description").attr("data-parsley-maxlength", 5000);
    $("#first-name").attr("data-parsely-maxlength", 32);
    $("#last-name").attr("data-parsely-maxlength", 64);
    $("#email").attr("data-parsley-maxlength", 254);
    $("#user-title").attr("data-parsley-maxlength", 64);
    $("#user-organization").attr("data-parsley-maxlength", 128);
    $("#phone").attr("data-parsley-length", "[14,14]");
    $("#fax").attr("data-parsley-length", "[14,14]");
    $("#zipcode").attr("data-parsley-length", "[5,5]");

    // Custom Validation Messages
    $("#fax").attr("data-parsley-length-message", "The fax number must be 10 digits.");
    $("#phone").attr("data-parsley-length-message", "The phone number must be 10 digits.");
    $("#zipcode").attr("data-parsley-length-message", "The Zipcode must be 5 digits.");

    // Disable default error messages for email,phone,fax,address so custom one can be used instead.
    $("#phone").attr("data-parsley-required-message", "");
    $("#fax").attr("data-parsley-required-message", "");<commit_msg>Fixed mismatched quotes<commit_after>/**
 * Created by atan on 9/14/16.
 */

"use strict";

$(document).ready(function () {

    $("input[name='tz-name']").val(jstz.determine().name());


    // Prevent user from entering a non numeric value into phone and fax field
    $("#phone").keypress(function (key) {
        if (key.charCode != 0) {
            if (key.charCode < 48 || key.charCode > 57) {
                key.preventDefault();
            }
        }
    });
    $("#fax").keypress(function (key) {
        if (key.charCode != 0) {
            if (key.charCode < 48 || key.charCode > 57) {
                key.preventDefault();
            }
        }
    });

    // ajax call to get additional information for the specified agency
    var selectedAgency = $("#request-agency").val();
    var requestInstructionsDiv = $("#request-agency-instructions");
    var requestInstructionsContentDiv = $("#request-agency-instructions-content");
    $.ajax({
        url: "/agency/feature/" + selectedAgency + "/" + "specific_request_instructions",
        type: "GET",
        success: function (data) {
            if (data["specific_request_instructions"]["text"] !== "") {
                requestInstructionsContentDiv.html("<p>" + data["specific_request_instructions"]["text"] + "</p>");
                requestInstructionsDiv.show();
            }
            else {
                requestInstructionsDiv.hide();
            }
        },
        error: function () {
            requestInstructionsDiv.hide();
        }

    });

    $("#request-agency-instructions-toggle").click(function () {
        var el = $("#request-agency-instructions-toggle");
        var requestInstructionsContentDiv = $("#request-agency-instructions-content");
        var hideHtml = "<button type=\"button\" id=\"request-agency-instructions-btn\" class=\"btn btn-block btn-info\"><span class=\"glyphicon glyphicon-chevron-up\"></span>&nbsp;&nbsp;Hide Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-up\"></span></button>";
        var showHtml = "<button type=\"button\" id=\"request-agency-instructions-btn\" class=\"btn btn-block btn-info\"><span class=\"glyphicon glyphicon-chevron-down\"></span>&nbsp;&nbsp;Show Agency Instructions&nbsp;&nbsp;<span class=\"glyphicon glyphicon-chevron-down\"></span></button>";
        if (el.html() === showHtml) {
            el.html(hideHtml);
            requestInstructionsContentDiv.show();
        } else {
            el.html(showHtml);
            requestInstructionsContentDiv.hide();
        }
    });

    // javascript to add tooltip popovers when selecting the title and description
    $("#request-title").attr({
        'data-placement': "top",
        'data-trigger': "hover focus",
        'data-toggle': "popover",
        'data-content': "Public Advocate Emails from 2015",
        title: "Example Title"
    });
    $("#request-title").popover();
    // $("#request-title").click(function(){
    //     $("#request-title").popover("show");
    // });

    $("#request-description").attr({
        'data-placement': "top",
        'data-trigger': "hover focus",
        'data-toggle': "popover",
        'data-content': "Topic: Public Advocate Emails from 2015. Emails that mention bike lanes or bicycle lanes from the Public Advocate's Office between July 27, 2015 and September 10, 2015.",
        title: "Example Request"
    });
    $("#request-description").click(function () {
        $("#request-description").popover("show");
    });
    $("#request-description").popover();
    // $("#request-description").click(function(){
    //     $("#request-description").popover("show");
    // });

    // jQuery mask plugin to format fields
    $("#phone").mask("(999) 999-9999");
    $("#fax").mask("(999) 999-9999");
    $("#zipcode").mask("99999");

    // Datepicker for date request was received when creating a new request
    $(".dtpick").datepicker({
        dateFormat: "mm/dd/yy",
        maxDate: 0
    }).keydown(function (e) {
        // prevent keyboard input except for tab
        if (e.keyCode !== 9)
            e.preventDefault();
    });

    // Loop through required fields and apply a data-parsley-required attribute to them
    var requiredFields = ["request-title", "request-description", "first-name", "last-name", "email",
        "phone", "fax", "address-line-1", "method-received", "request-date", "city", "zipcode"];
    for (var i = 0; i < requiredFields.length; i++) {
        $("#" + requiredFields[i]).attr("data-parsley-required", "");
    }

    // Apply parsley validation styles to the input forms for a new request.
    $("#request-title").attr("data-parsley-maxlength", 90);
    $("#request-description").attr("data-parsley-maxlength", 5000);
    $("#first-name").attr("data-parsely-maxlength", 32);
    $("#last-name").attr("data-parsely-maxlength", 64);
    $("#email").attr("data-parsley-maxlength", 254);
    $("#user-title").attr("data-parsley-maxlength", 64);
    $("#user-organization").attr("data-parsley-maxlength", 128);
    $("#phone").attr("data-parsley-length", "[14,14]");
    $("#fax").attr("data-parsley-length", "[14,14]");
    $("#zipcode").attr("data-parsley-length", "[5,5]");

    // Custom Validation Messages
    $("#fax").attr("data-parsley-length-message", "The fax number must be 10 digits.");
    $("#phone").attr("data-parsley-length-message", "The phone number must be 10 digits.");
    $("#zipcode").attr("data-parsley-length-message", "The Zipcode must be 5 digits.");

    // Disable default error messages for email,phone,fax,address so custom one can be used instead.
    $("#phone").attr("data-parsley-required-message", "");
    $("#fax").attr("data-parsley-required-message", "");
{'fraction_non_alphanumeric': 0.1896943231441048, 'fraction_numerical': 0.016943231441048034, 'mean_word_length': 2.898876404494382, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 35, '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': '966368', 'n_tokens_mistral': 3452, 'n_tokens_neox': 3223, 'n_words': 698}