mailer.dnbindiasnms.in Open in urlscan Pro
103.15.80.5  Public Scan

URL: https://mailer.dnbindiasnms.in/js/misc.js
Submission: On November 09 via api from US — Scanned from US

Form analysis 0 forms found in the DOM

Text Content

$(function() {

        $('#unsubscribe_all').on('click', function() {
                if ($('#unsubscribe_all').is(':checked')) {
                        var mailing_list_count = eval($("#mailing_list_count").val());
                        var public_list_count = eval($("#public_list_count").val());
                        var all_id_exists = eval($("#all_id_exists").val());
                        var check_count = (mailing_list_count + public_list_count) - all_id_exists;
                        for (i = 0; i < check_count; i++) {
                                $("#list" + '_' + i).prop('checked', false);
                        }
                }

        });
        $("input[name='list_id[]']").on('click', function() {
                $("#unsubscribe_all").prop('checked', false);
        });

        $('#friend_forward').on('click', function() {
                var from_name = $.trim($("#from_name").val());
                if (from_name == "") {
                        alert("Please Enter Your Name.");
                        $("#from_name").focus();
                        return false;
                }

                var email = $('input[name="Email[]"]');
                var email_len = email.length;
                var email_count = 0;
                var invalid_email = -1;
                for (i = 0; i < email_len; i++) {
                        var to_email = email[i].value;
                        if ($.trim(to_email) != '') {
                                email_count++;
                                if (!(/^\w+([\.\&-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(to_email))) {
                                        invalid_email = i;
                                        break;
                                }
                        }

                }
                if (invalid_email > -1) {
                        var row = invalid_email + 1;
                        alert("Please enter a valid email ID (Email Format: abc@xyx.co.in) at row - " + row + ".");
                        $('#Email' + invalid_email).focus();
                        return false;
                }
                else {
                        if (email_count == 0) {
                                $('#Email' + email_count).focus();
                                alert('Atleast one email id should be filled.');
                                return false;
                        }
                }
        });


        $('#show_response').click(function() {

                var search_text = '';
                var question_id = 0;
                var error_message = '';

                $('#survey_show_response_error').html('');

                survey_id = $('#survey_id').val();
                search_text = $('#frmSearch').val();
                question_id = $('#response_field').val();
                client_code_db_id = $('#client_code_db_id').val();

                if (search_text == '') {
                        error_message += 'Enter search Text.<br />';
                }
                else if (question_id == 0) {
                        error_message += 'Select Question.<br />';
                }


                if (error_message) {
                        $('#survey_show_response_error').attr('class', 'text-danger');
                        $('#survey_show_response_error').html(error_message);
                        return false;
                }
                else {
                        $('#survey_edit_question_error').html('');
                        searchResponse(survey_id, question_id, search_text, client_code_db_id);

                }
        });



        $('#survey_stat_form').submit(function() {
                var val = $('#option').val();
                if (val == 0) {
                        alert('Please select a Campaign.');
                        return false;
                }
        });



});

function survey_misc_stats_ajax_request(request_data) {
        var res_data;
        var url;
        url = "/misc/pages/ajax_action";
        $.ajax
                ({
                        type: "POST",
                        url: url,
                        data: request_data,
                        async: false,
                        cache: false,
                        success: function(response) {
                                res_data = jQuery.parseJSON(response);
                        }

                });
        return res_data;
}

function searchResponse(survey_id, question_id, search_text, client_code_db_id) {
        var data_string = {
                'case': 'SEARCH_RESPONSE',
                'id': survey_id,
                'question_id': question_id,
                'search_text': search_text,
                'client_code_db_id': client_code_db_id
        };
        var result = survey_misc_stats_ajax_request(data_string);

        if (result.status == 1) {
		var display_string = '<table width="100%" class="table table-bordered table-fixed-header"><tr><th width="5%">Sr.</th><th>'+result.data['question_text']+'</th><th width="5%">View</th></tr>';
                var id = 0;
                $.each(result.data['response_display'], function(key, val) {
                        id++;
			display_string += '<tr><td>'+id+'</td><td>'+val+'</td><td><a id ="response_detail_link" rel="'+key+'" title="View" style="cursor:pointer"><i class="fa  fa-eye fa-fw fa-lg"></i></a></td></tr>';
                });
		display_string += '</table>';
                $('#response').attr('class', '');
                $("#response").html(display_string);
                $("#response").show();
        }
        else {
                $('#response').attr('class', 'text-danger');
                $("#response").html('<br />No response found<br />');
                $("#response").show();
        }
}
$(document).on('click', '#add_fwd_friend_row', function(){
        var max_fwd_friend_count = new Number($('#maximum_fwd_friend_count').val());
        var initial_fwd_friend_count = new Number($('#initial_fwd_friend_count').val());
        if(initial_fwd_friend_count < max_fwd_friend_count) {
                addFwdFriendRow(initial_fwd_friend_count);
        }
        else {
                alert('The maximum number of Forward Friend allowed is '+max_fwd_friend_count+'.');
        }
});
function addFwdFriendRow(initial_fwd_friend_count){
        var new_fwd_friend_row = '<div class="row" style="margin-top:10px;"><div class="col-md-6 col-sm-6"><div class="col-md-4 col-sm-4 hidden-xs"><label class="control-label hidden-xs" for="Email'+initial_fwd_friend_count+'">Forward To:</label></div><div class="col-md-8 col-sm-8"><div class="input text"><input name="Email[]" id="Email'+initial_fwd_friend_count+'" class="form-control" placeholder="Forward To Email" type="textbox"></div></div></div><div class="col-md-6 col-sm-6"><div class="col-md-4 col-sm-4 hidden-xs"><label class="control-label hidden-xs" for="FirstName'+initial_fwd_friend_count+'">Name:</label></div><div class="col-md-8 col-sm-8"><div class="input text"><input name="FirstName[]" id="FirstName'+initial_fwd_friend_count+'" class="form-control" placeholder="Forward To Name" type="textbox"></div></div></div></div>';
        $('#forward_friend_rows').append(new_fwd_friend_row);
        var new_fwd_friend_row_number = initial_fwd_friend_count + 1;
        $('#initial_fwd_friend_count').val(new_fwd_friend_row_number);
}