$(document).ready(function() { $.fn.dataTable.ext.order['sortMln'] = function ( settings, col ) { return this.api().column( col, {order:'index'} ).nodes().map( function ( td ) { return 1*$(td).text().replace(' mln.', ''); } ); }; $.fn.dataTable.ext.order['sortCountryFlag'] = function ( settings, col ) { return this.api().column( col, {order:'index'} ).nodes().map( function ( td ) { return $('i', td).attr('title'); } ); }; $.fn.dataTable.ext.order['sortMostPopular'] = function ( settings, col ) { return this.api().column( col, {order:'index'} ).nodes().map( function ( td ) { return 1*$(td).text().substr(0,$(td).text().indexOf("x")-1); } ); }; }); var countries = {"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"Danimarca"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Russia"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgio"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"Stati Uniti"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Australia"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"Italia"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Serbia"},"84":{"id":"84","country":"Belarus","countryCode":"BY","countryTr":"Bielorussia"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"Cina"},"96":{"id":"96","country":"Israel","countryCode":"IL","countryTr":"Israele"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polonia"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Francia"},"150":{"id":"150","country":"Estonia","countryCode":"EE","countryTr":"Estonia"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Spagna"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Romania"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"Slovacchia"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Germania"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Repubblica Ceca"},"95":{"id":"95","country":"Bulgaria","countryCode":"BG","countryTr":"Bulgaria"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Ucraina"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Ungheria"},"62":{"id":"62","country":"Kazakhstan","countryCode":"KZ","countryTr":"Kazakistan"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Svizzera"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Lettonia"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"Slovenia"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"Argentina"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Giappone"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Svezia"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"Regno Unito"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Tailandia"},"44":{"id":"44","country":"Uzbekistan","countryCode":"UZ","countryTr":"Usbechistan"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Austria"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Croazia"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"Sud Africa"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"Canada"},"49":{"id":"49","country":"Taiwan","countryCode":"TW","countryTr":"Taiwan"},"29":{"id":"29","country":"Colombia","countryCode":"CO","countryTr":"Colombia"},"169":{"id":"169","country":"Luxembourg","countryCode":"LU","countryTr":"Lussemburgo"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Olanda"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"Corea del Sud"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"India"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"Grecia"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"Paraguay"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Turchia"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"Georgia"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portogallo"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"Hong Kong"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Brasile"},"40":{"id":"40","country":"Peru","countryCode":"PE","countryTr":"Per\u00f9"},"113":{"id":"113","country":"Kyrgyzstan","countryCode":"KG","countryTr":"Kirghizistan"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"Finlandia"},"208":{"id":"208","country":"Liechtenstein","countryCode":"LI","countryTr":"Liechtenstein"},"86":{"id":"86","country":"Bolivia","countryCode":"BO","countryTr":"Bolivia"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"Nuova Zelanda"},"4":{"id":"4","country":"Indonesia","countryCode":"ID","countryTr":"Indonesia"},"141":{"id":"141","country":"Oman","countryCode":"OM","countryTr":"Oman"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Lituania"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Cile"},"79":{"id":"79","country":"Tunisia","countryCode":"TN","countryTr":"Tunisia"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"Marocco"},"127":{"id":"127","country":"Bosnia and Herzegovina","countryCode":"BA","countryTr":"Bosnia-Erzegovina"},"42":{"id":"42","country":"Venezuela","countryCode":"VE","countryTr":"Venezuela"},"159":{"id":"159","country":"Cyprus","countryCode":"CY","countryTr":"Cipro"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"Uruguay"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Irlanda"},"66":{"id":"66","country":"Ecuador","countryCode":"EC","countryTr":"Ecuador"},"82":{"id":"82","country":"Dominican Republic","countryCode":"DO","countryTr":"Repubblica Dominicana"},"11":{"id":"11","country":"Mexico","countryCode":"MX","countryTr":"Messico"},"131":{"id":"131","country":"Moldova","countryCode":"MD","countryTr":"Moldavia"},"16":{"id":"16","country":"Egypt","countryCode":"EG","countryTr":"Egitto"},"85":{"id":"85","country":"Haiti","countryCode":"HT","countryTr":"Haiti"},"209":{"id":"209","country":"Monaco","countryCode":"MC","countryTr":"Monaco"},"126":{"id":"126","country":"Puerto Rico","countryCode":"PR","countryTr":"Porto Rico"},"122":{"id":"122","country":"United Arab Emirates","countryCode":"AE","countryTr":"Emirati Arabi Uniti"},"164":{"id":"164","country":"Montenegro","countryCode":"ME","countryTr":"Montenegro"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norvegia"},"177":{"id":"177","country":"Barbados","countryCode":"BB","countryTr":"Barbados"},"144":{"id":"144","country":"North Macedonia","countryCode":"MK","countryTr":"Macedonia del Nord"},"99":{"id":"99","country":"El Salvador","countryCode":"SV","countryTr":"El Salvador"},"156":{"id":"156","country":"Qatar","countryCode":"QA","countryTr":"Qatar"},"69":{"id":"69","country":"Zimbabwe","countryCode":"ZW","countryTr":"Zimbabwe"},"125":{"id":"125","country":"Lebanon","countryCode":"LB","countryTr":"Libano"},"102":{"id":"102","country":"Papua New Guinea","countryCode":"PG","countryTr":"Papua Nuova Guinea"},"199":{"id":"199","country":"Andorra","countryCode":"AD","countryTr":"Andorra"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"Filippine"},"92":{"id":"92","country":"Burundi","countryCode":"BI","countryTr":"Burundi"},"172":{"id":"172","country":"Malta","countryCode":"MT","countryTr":"Malta"},"13":{"id":"13","country":"Vietnam","countryCode":"VN","countryTr":"Vietnam"},"105":{"id":"105","country":"Jordan","countryCode":"JO","countryTr":"Giordania"}}; var teams = [{"id":0,"name":""}]; var sportsmen = [{"id":"3586","tem":"0","ctr":"28","nam":"Nadal, Rafael ","namorig":"Nadal, Rafael ","cat":"","pri":"20 mln.","rat":0,"mw":"M","link":"Nadal, Rafael <\/a>","confirmed_b":1},{"id":"3683","tem":"0","ctr":"10","nam":"Nishikori, Kei ","namorig":"Nishikori, Kei ","cat":"","pri":"15,6 mln.","rat":0,"mw":"M","link":"Nishikori, Kei <\/a>","confirmed_b":1},{"id":"3592","tem":"0","ctr":"28","nam":"Ferrer, David ","namorig":"Ferrer, David ","cat":"","pri":"12,1 mln.","rat":0,"mw":"M","link":"Ferrer, David <\/a>","confirmed_b":1},{"id":"3615","tem":"0","ctr":"19","nam":"Gasquet, Richard ","namorig":"Gasquet, Richard ","cat":"","pri":"9,7 mln.","rat":0,"mw":"M","link":"Gasquet, Richard <\/a>","confirmed_b":1},{"id":"3755","tem":"0","ctr":"28","nam":"Bautista Agut, Roberto ","namorig":"Bautista Agut, Roberto ","cat":"","pri":"9,2 mln.","rat":0,"mw":"M","link":"Bautista Agut, Roberto <\/a>","confirmed_b":1},{"id":"3737","tem":"0","ctr":"19","nam":"Paire, Benoit ","namorig":"Paire, Benoit ","cat":"","pri":"7,4 mln.","rat":0,"mw":"M","link":"Paire, Benoit <\/a>","confirmed_b":1},{"id":"7522","tem":"45","ctr":"14","nam":"Zverev, Alexander ","namorig":"Zverev, Alexander ","cat":"","pri":"6,6 mln.","rat":0,"mw":"M","link":"Zverev, Alexander <\/a>","confirmed_b":1},{"id":"3640","tem":"0","ctr":"23","nam":"Fognini, Fabio ","namorig":"Fognini, Fabio ","cat":"","pri":"5,9 mln.","rat":0,"mw":"M","link":"Fognini, Fabio <\/a>","confirmed_b":1},{"id":"3648","tem":"0","ctr":"134","nam":"Cuevas, Pablo ","namorig":"Cuevas, Pablo ","cat":"","pri":"5,5 mln.","rat":0,"mw":"M","link":"Cuevas, Pablo <\/a>","confirmed_b":1},{"id":"3829","tem":"0","ctr":"77","nam":"Sousa, Joao ","namorig":"Sousa, Joao ","cat":"","pri":"4,5 mln.","rat":0,"mw":"M","link":"Sousa, Joao <\/a>","confirmed_b":1},{"id":"3816","tem":"0","ctr":"9","nam":"Kuznetsov, Andrey ","namorig":"Kuznetsov, Andrey ","cat":"","pri":"3,8 mln.","rat":0,"mw":"M","link":"Kuznetsov, Andrey <\/a>","confirmed_b":1},{"id":"3708","tem":"0","ctr":"28","nam":"Ramos-Vinolas, Albert ","namorig":"Ramos-Vinolas, Albert ","cat":"","pri":"3,7 mln.","rat":0,"mw":"M","link":"Ramos-Vinolas, Albert <\/a>","confirmed_b":1},{"id":"3927","tem":"0","ctr":"28","nam":"Carreno Busta, Pablo ","namorig":"Carreno Busta, Pablo ","cat":"","pri":"3,5 mln.","rat":0,"mw":"M","link":"Carreno Busta, Pablo <\/a>","confirmed_b":1},{"id":"3627","tem":"0","ctr":"28","nam":"Granollers, Marcel ","namorig":"Granollers, Marcel ","cat":"","pri":"3,4 mln.","rat":0,"mw":"M","link":"Granollers, Marcel <\/a>","confirmed_b":1},{"id":"8018","tem":"45","ctr":"25","nam":"Chung, Hyeon ","namorig":"Chung, Hyeon ","cat":"","pri":"3,3 mln.","rat":0,"mw":"M","link":"Chung, Hyeon <\/a>","confirmed_b":1},{"id":"3944","tem":"0","ctr":"28","nam":"Cervantes, Inigo ","namorig":"Cervantes, Inigo ","cat":"","pri":"3,1 mln.","rat":0,"mw":"M","link":"Cervantes, Inigo <\/a>","confirmed_b":1},{"id":"3609","tem":"0","ctr":"142","nam":"Gulbis, Ernests ","namorig":"Gulbis, Ernests ","cat":"","pri":"2,9 mln.","rat":0,"mw":"M","link":"Gulbis, Ernests <\/a>","confirmed_b":1},{"id":"3665","tem":"0","ctr":"9","nam":"Gabashvili, Teymuraz ","namorig":"Gabashvili, Teymuraz ","cat":"","pri":"2,8 mln.","rat":0,"mw":"M","link":"Gabashvili, Teymuraz <\/a>","confirmed_b":1},{"id":"3769","tem":"0","ctr":"3","nam":"Ram, Rajeev ","namorig":"Ram, Rajeev ","cat":"","pri":"2,6 mln.","rat":0,"mw":"M","link":"Ram, Rajeev <\/a>","confirmed_b":1},{"id":"3625","tem":"0","ctr":"44","nam":"Istomin, Denis ","namorig":"Istomin, Denis ","cat":"","pri":"2,4 mln.","rat":0,"mw":"M","link":"Istomin, Denis <\/a>","confirmed_b":1},{"id":"11490","tem":"45","ctr":"88","nam":"Ymer, Elias ","namorig":"Ymer, Elias ","cat":"","pri":"2,3 mln.","rat":0,"mw":"M","link":"Ymer, Elias <\/a>","confirmed_b":1},{"id":"3673","tem":"0","ctr":"120","nam":"Dodig, Ivan ","namorig":"Dodig, Ivan ","cat":"","pri":"2,2 mln.","rat":0,"mw":"M","link":"Dodig, Ivan <\/a>","confirmed_b":1},{"id":"3844","tem":"0","ctr":"9","nam":"Donskoy, Evgeny ","namorig":"Donskoy, Evgeny ","cat":"","pri":"2,2 mln.","rat":0,"mw":"M","link":"Donskoy, Evgeny <\/a>","confirmed_b":1},{"id":"3644","tem":"0","ctr":"62","nam":"Kukushkin, Mikhail ","namorig":"Kukushkin, Mikhail ","cat":"","pri":"2,1 mln.","rat":0,"mw":"M","link":"Kukushkin, Mikhail <\/a>","confirmed_b":1},{"id":"7314","tem":"45","ctr":"28","nam":"Carballes Baena, Roberto ","namorig":"Carballes Baena, Roberto ","cat":"","pri":"2 mln.","rat":0,"mw":"M","link":"Carballes Baena, Roberto <\/a>","confirmed_b":1},{"id":"3827","tem":"0","ctr":"31","nam":"Bagnis, Facundo ","namorig":"Bagnis, Facundo ","cat":"","pri":"1,9 mln.","rat":0,"mw":"M","link":"Bagnis, Facundo <\/a>","confirmed_b":1},{"id":"3628","tem":"0","ctr":"61","nam":"Bakker, Thiemo de","namorig":"Bakker, Thiemo de","cat":"","pri":"1,8 mln.","rat":0,"mw":"M","link":"Bakker, Thiemo de<\/a>","confirmed_b":1},{"id":"3943","tem":"0","ctr":"14","nam":"Struff, Jan-Lennard ","namorig":"Struff, Jan-Lennard ","cat":"","pri":"1,7 mln.","rat":0,"mw":"M","link":"Struff, Jan-Lennard <\/a>","confirmed_b":1},{"id":"12337","tem":"45","ctr":"28","nam":"Munar, Jaume ","namorig":"Munar, Jaume ","cat":"","pri":"1,5 mln.","rat":0,"mw":"M","link":"Munar, Jaume <\/a>","confirmed_b":1},{"id":"10369","tem":"45","ctr":"9","nam":"Khachanov, Karen ","namorig":"Khachanov, Karen ","cat":"","pri":"1,4 mln.","rat":0,"mw":"M","link":"Khachanov, Karen <\/a>","confirmed_b":1},{"id":"3767","tem":"0","ctr":"120","nam":"Skugor, Franko ","namorig":"Skugor, Franko ","cat":"","pri":"1,3 mln.","rat":0,"mw":"M","link":"Skugor, Franko <\/a>","confirmed_b":1},{"id":"11493","tem":"45","ctr":"31","nam":"Cachin, Pedro ","namorig":"Cachin, Pedro ","cat":"","pri":"1,1 mln.","rat":0,"mw":"M","link":"Cachin, Pedro <\/a>","confirmed_b":1},{"id":"11472","tem":"45","ctr":"80","nam":"Fucsovics, Marton ","namorig":"Fucsovics, Marton ","cat":"","pri":"1 mln.","rat":0,"mw":"M","link":"Fucsovics, Marton <\/a>","confirmed_b":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'No.' }, { 'sTitle': 'Gruppo' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Nazione', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Tennista'}, { 'sTitle': 'Valore', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Squadra' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'M/F' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'No.'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Nazione' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Valore', 'sSortDataType': 'sortMln', 'sType': 'numeric' } ]; //*********************** //SPORTSMEN TABLE CONTENT //*********************** var contentTableSportsmen = []; $.each(sportsmen, function(k, v) { contentTableSportsmen.push([ k + 1, v['cat'], getFlag(v['ctr']), v['link'], v['pri'], isset(teams[v['tem']])? teams[v['tem']]['name']:'', v['mw'] ]); }); //*********************** //TEAMS TABLE CONTENT //*********************** var contentTableTeams = []; $.each(sportsmenTeams, function(k, v) { contentTableTeams.push([ k + 1, "", getFlag(v['ctr']), v['nam'], v['pri'] ]); }); function isset (va) { return typeof va != 'undefined'; } $(document).ready(function() { $.fn.dataTable.ext.order['sortMln'] = function (settings, col) { return this.api().column(col, {order: 'index'}).nodes().map(function (td) { return parseFloat($(td).text().replace(' mln.', '').replace(',', '.')); } ); }; if (sportsmen.length) { var sportsmenTable = $('#tblSportsmen').dataTable( { "bPaginate": false, "bFilter": true, "bInfo": false, "bAutoWidth": true, "aoColumns" : headersTableSportsmen, "aaData": contentTableSportsmen, "bAutoWidth": false } ); } if (sportsmenTeams.length) { var sportsmenTeamsTable = $('#tblTeams').dataTable( { "bPaginate": false, "bFilter": true, "bInfo": false, "bAutoWidth": true, "aoColumns" : headersTableTeams, "aaData": contentTableTeams, "bAutoWidth": false } ); $('#teamsOverview').show(); } } ); function getFlag(id, margin) { if (!id || typeof countries[id] === "undefined" ) return ""; if (typeof margin == 'undefined') margin = true; return ""; }