jQuery(document).ready(function() { var finUrl = window.location.href.split('='); var admin_url = '../wp-admin/admin-ajax.php'; var urlParam = 1; if (typeof finUrl[1] != 'undefined'){ urlParam = finUrl[1]; } var topUrl = '../top-finance-datatable/'; console.log('jmd'); console.log(topUrl); if(urlParam=='2'){ jQuery(".show_traffic").html('Show Traffic Score'); }else{ jQuery(".show_traffic").html('Show Traffic Data'); } if(urlParam==3){ jQuery(".show_social").html('Show Social Media Score'); }else{ jQuery(".show_social").html('Show Social Media Data'); } if(urlParam==4){ jQuery(".show_seo").html('Show SEO Score'); }else{ jQuery(".show_seo").html('Show SEO Data'); } jQuery('.show_traffic').click(function(){ if(urlParam=='2'){ jQuery(this).attr('href',topUrl); }else{ jQuery(this).attr('href',topUrl+'@select_part=2'); } }); jQuery('.show_social').click(function(){ if(urlParam=='3'){ jQuery(this).attr('href',topUrl); }else{ jQuery(this).attr('href',topUrl+'@select_part=3'); } }); jQuery('.show_seo').click(function(){ if(urlParam=='4'){ jQuery(this).attr('href',topUrl); }else{ jQuery(this).attr('href',topUrl+'@select_part=4'); } }); if(jQuery('#test-top-finance').length>0){ var oTable = jQuery('#test-top-finance').DataTable( { "bProcessing": true, "bServerSide": true, "aLengthMenu": [[50, 100, 200, 500, -1], [50, 100, 200, 500, "All"]], "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,1 ] }, ], "sAjaxSource": admin_url, "fnServerParams": function ( aoData ) { aoData.push( { "name": "action", "value": "get_data" } ); aoData.push( { "name": "select_part", "value": urlParam } ); }, "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { }, "fnDrawCallback":function(){ //this.fnSetColumnVis(6, false);//hide country column } }); /*jQuery('#test-top-finance').on('page.dt', function() { console.log('jhdjsakjfhda'); var info = oTable.page.info(); var page = info.page+1; ga('send', 'pageview', location.pathname + '#' + page); });*/ } });