// Call the dataTables jQuery plugin
$(window).on("load", function() {
	// Normal Datatable begins
	$('#dataTable').DataTable({
		"processing": true,
		"serverSide": false,
		"ajax": 'datatable-data-arrays.txt',
		"language": {
			"loadingRecords": '&nbsp;',
			"processing": '<i class="fa fa-spinner fa-spin" style="font-size:18px; color:rgb(75, 183, 245);"></i>&nbsp;&nbsp;Please wait...'
		}
	});
	// Normal Datatable ends

	// Datatable with filter colomns begins
	$('#filterDataTable thead tr').clone(true).appendTo('#filterDataTable thead');
    $('#filterDataTable thead tr:eq(1) th').each( function (i) {
        var title = $(this).text();
        $(this).html( '<input type="text" class="form-control" placeholder="Search '+title+'" />' );
 
        $( 'input', this ).on( 'keyup change', function () {
            if ( table.column(i).search() !== this.value ) {
                table
                    .column(i)
                    .search( this.value )
                    .draw();
            }
        } );
    } );
 
    var table = $('#filterDataTable').DataTable({
		"processing": true,
		"serverSide": false,
        "orderCellsTop": true,
        "fixedHeader": true,
		"ajax": 'datatable-data-arrays.txt',
		"language": {
			"loadingRecords": '&nbsp;',
			"processing": '<i class="fa fa-spinner fa-spin" style="font-size:18px; color:rgb(75, 183, 245);"></i>&nbsp;&nbsp;Please wait...'
		}
    });
	// Datatable with filter colomns ends
});


// Datatable error displaying method begins
$.fn.dataTableExt.sErrMode = "console";

$.fn.dataTableExt.oApi._fnLog = function (oSettings, iLevel, sMesg, tn) {
	var sAlert = (oSettings === null) ?
		"DataTables warning: " + sMesg :
		"DataTables warning (table id = '" + oSettings.sTableId + "'): " + sMesg;

	if (tn) {
		sAlert += ". For more information about this error, please see " +
			"http://datatables.net/tn/" + tn;
	}

	if (iLevel === 0) {
		if ($.fn.dataTableExt.sErrMode == "alert") {
			alert(sAlert);
		} else if ($.fn.dataTableExt.sErrMode == "thow") {
			throw sAlert;
		} else if ($.fn.dataTableExt.sErrMode == "console") {
			console.log(sAlert);
		} else if ($.fn.dataTableExt.sErrMode == "mute") {}

		return;
	} else if (console !== undefined && console.log) {
		console.log(sAlert);
	}
}
// Datatable error displaying method ends