$(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":"Denemarken"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Rusland"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgi\u00eb"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"Verenigde Staten"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Australi\u00eb"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"Itali\u00eb"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Servi\u00eb"},"84":{"id":"84","country":"Belarus","countryCode":"BY","countryTr":"Wit-Rusland"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"China"},"96":{"id":"96","country":"Israel","countryCode":"IL","countryTr":"Isra\u00ebl"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polen"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Frankrijk"},"150":{"id":"150","country":"Estonia","countryCode":"EE","countryTr":"Estland"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Spanje"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Roemeni\u00eb"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"Slowakije"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Duitsland"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Tsjechi\u00eb"},"95":{"id":"95","country":"Bulgaria","countryCode":"BG","countryTr":"Bulgarije"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Oekra\u00efne"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Hongarije"},"62":{"id":"62","country":"Kazakhstan","countryCode":"KZ","countryTr":"Kazachstan"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Zwitserland"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Letland"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"Sloveni\u00eb"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"Argentini\u00eb"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japan"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Zweden"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"Verenigd Koninkrijk"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Thailand"},"44":{"id":"44","country":"Uzbekistan","countryCode":"UZ","countryTr":"Oezbekistan"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Oostenrijk"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Kroati\u00eb"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"Zuid-Afrika"},"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":"Luxemburg"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Nederland"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"Zuid-Korea"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"India"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"Griekenland"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"Paraguay"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Turkije"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"Georgi\u00eb"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugal"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"Hong Kong"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Brazili\u00eb"},"40":{"id":"40","country":"Peru","countryCode":"PE","countryTr":"Peru"},"113":{"id":"113","country":"Kyrgyzstan","countryCode":"KG","countryTr":"Kirgizi\u00eb"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"Finland"},"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":"Nieuw-Zeeland"},"4":{"id":"4","country":"Indonesia","countryCode":"ID","countryTr":"Indonesi\u00eb"},"141":{"id":"141","country":"Oman","countryCode":"OM","countryTr":"Oman"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Litouwen"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Chili"},"79":{"id":"79","country":"Tunisia","countryCode":"TN","countryTr":"Tunesi\u00eb"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"Marokko"},"127":{"id":"127","country":"Bosnia and Herzegovina","countryCode":"BA","countryTr":"Bosni\u00eb-Herzegovina"},"42":{"id":"42","country":"Venezuela","countryCode":"VE","countryTr":"Venezuela"},"159":{"id":"159","country":"Cyprus","countryCode":"CY","countryTr":"Cyprus"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"Uruguay"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Ierland"},"66":{"id":"66","country":"Ecuador","countryCode":"EC","countryTr":"Ecuador"},"82":{"id":"82","country":"Dominican Republic","countryCode":"DO","countryTr":"Dominicaanse Republiek"},"11":{"id":"11","country":"Mexico","countryCode":"MX","countryTr":"Mexico"},"131":{"id":"131","country":"Moldova","countryCode":"MD","countryTr":"Moldavi\u00eb"},"16":{"id":"16","country":"Egypt","countryCode":"EG","countryTr":"Egypte"},"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":"Puerto Rico"},"122":{"id":"122","country":"United Arab Emirates","countryCode":"AE","countryTr":"Verenigde Arabische Emiraten"},"164":{"id":"164","country":"Montenegro","countryCode":"ME","countryTr":"Montenegro"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Noorwegen"},"177":{"id":"177","country":"Barbados","countryCode":"BB","countryTr":"Barbados"},"144":{"id":"144","country":"North Macedonia","countryCode":"MK","countryTr":"Noord Macedoni\u00eb"},"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":"Libanon"},"102":{"id":"102","country":"Papua New Guinea","countryCode":"PG","countryTr":"Papoea-Nieuw-Guinea"},"199":{"id":"199","country":"Andorra","countryCode":"AD","countryTr":"Andorra"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"Filipijnen"},"92":{"id":"92","country":"Burundi","countryCode":"BI","countryTr":"Boeroendi"},"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":"Jordani\u00eb"}}; var teams = [{"id":0,"name":""}]; var sportsmen = [{"id":"5397","tem":"0","ctr":"27","nam":"Svitolina, Elina ","namorig":"Svitolina, Elina ","cat":"","pri":"15 mln.","rat":0,"mw":"V","link":"Svitolina, Elina <\/a>","confirmed_b":1},{"id":"2990","tem":"0","ctr":"3","nam":"Williams, Venus ","namorig":"Williams, Venus ","cat":"","pri":"12,7 mln.","rat":0,"mw":"V","link":"Williams, Venus <\/a>","confirmed_b":1},{"id":"2986","tem":"0","ctr":"109","nam":"Wozniacki, Caroline ","namorig":"Wozniacki, Caroline ","cat":"","pri":"12,5 mln.","rat":0,"mw":"V","link":"Wozniacki, Caroline <\/a>","confirmed_b":1},{"id":"3076","tem":"0","ctr":"1","nam":"Zhang, Shuai ","namorig":"Zhang, Shuai ","cat":"","pri":"6,8 mln.","rat":0,"mw":"V","link":"Zhang, Shuai <\/a>","confirmed_b":1},{"id":"3006","tem":"0","ctr":"9","nam":"Pavlyuchenkova, Anastasia ","namorig":"Pavlyuchenkova, Anastasia ","cat":"","pri":"6,2 mln.","rat":0,"mw":"V","link":"Pavlyuchenkova, Anastasia <\/a>","confirmed_b":1},{"id":"7176","tem":"45","ctr":"51","nam":"Saville, Daria ","namorig":"Saville, Daria ","cat":"","pri":"5,6 mln.","rat":0,"mw":"V","link":"Saville, Daria <\/a>","confirmed_b":1},{"id":"10747","tem":"45","ctr":"10","nam":"Osaka, Naomi ","namorig":"Osaka, Naomi ","cat":"","pri":"4,5 mln.","rat":0,"mw":"V","link":"Osaka, Naomi <\/a>","confirmed_b":1},{"id":"3268","tem":"0","ctr":"1","nam":"Wang, Qiang ","namorig":"Wang, Qiang ","cat":"","pri":"4,1 mln.","rat":0,"mw":"V","link":"Wang, Qiang <\/a>","confirmed_b":1},{"id":"3423","tem":"0","ctr":"3","nam":"Rogers, Shelby ","namorig":"Rogers, Shelby ","cat":"","pri":"3,8 mln.","rat":0,"mw":"V","link":"Rogers, Shelby <\/a>","confirmed_b":1},{"id":"3253","tem":"0","ctr":"80","nam":"Babos, Timea ","namorig":"Babos, Timea ","cat":"","pri":"3,5 mln.","rat":0,"mw":"V","link":"Babos, Timea <\/a>","confirmed_b":1},{"id":"6183","tem":"0","ctr":"36","nam":"Bouchard, Eugenie ","namorig":"Bouchard, Eugenie ","cat":"","pri":"3,1 mln.","rat":0,"mw":"V","link":"Bouchard, Eugenie <\/a>","confirmed_b":1},{"id":"3156","tem":"0","ctr":"62","nam":"Diyas, Zarina ","namorig":"Diyas, Zarina ","cat":"","pri":"3 mln.","rat":0,"mw":"V","link":"Diyas, Zarina <\/a>","confirmed_b":1},{"id":"11232","tem":"45","ctr":"3","nam":"Brady, Jennifer ","namorig":"Brady, Jennifer ","cat":"","pri":"2,9 mln.","rat":0,"mw":"V","link":"Brady, Jennifer <\/a>","confirmed_b":1},{"id":"14276","tem":"45","ctr":"10","nam":"Kato, Miyu ","namorig":"Kato, Miyu ","cat":"","pri":"2,3 mln.","rat":0,"mw":"V","link":"Kato, Miyu <\/a>","confirmed_b":1},{"id":"15048","tem":"45","ctr":"51","nam":"Hon, Priscilla ","namorig":"Hon, Priscilla ","cat":"","pri":"2,2 mln.","rat":0,"mw":"V","link":"Hon, Priscilla <\/a>","confirmed_b":1},{"id":"16965","tem":"45","ctr":"51","nam":"Cabrera, Lizette ","namorig":"Cabrera, Lizette ","cat":"","pri":"2,1 mln.","rat":0,"mw":"V","link":"Cabrera, Lizette <\/a>","confirmed_b":1},{"id":"3102","tem":"0","ctr":"49","nam":"Chang, Kai-Chen ","namorig":"Chang, Kai-Chen ","cat":"","pri":"2 mln.","rat":0,"mw":"V","link":"Chang, Kai-Chen <\/a>","confirmed_b":1},{"id":"7761","tem":"45","ctr":"25","nam":"Jang, Su Jeong ","namorig":"Jang, Su Jeong ","cat":"","pri":"1,9 mln.","rat":0,"mw":"V","link":"Jang, Su Jeong <\/a>","confirmed_b":1},{"id":"7175","tem":"45","ctr":"20","nam":"Kumkhum, Luksika ","namorig":"Kumkhum, Luksika ","cat":"","pri":"1,8 mln.","rat":0,"mw":"V","link":"Kumkhum, Luksika <\/a>","confirmed_b":1},{"id":"3514","tem":"0","ctr":"3","nam":"Cako, Jacqueline ","namorig":"Cako, Jacqueline ","cat":"","pri":"1,5 mln.","rat":0,"mw":"V","link":"Cako, Jacqueline <\/a>","confirmed_b":1},{"id":"16966","tem":"45","ctr":"74","nam":"Grammatikopoulou, Valentini ","namorig":"Grammatikopoulou, Valentini ","cat":"","pri":"1,4 mln.","rat":0,"mw":"V","link":"Grammatikopoulou, Valentini <\/a>","confirmed_b":1},{"id":"5404","tem":"0","ctr":"10","nam":"Eguchi, Misa ","namorig":"Eguchi, Misa ","cat":"","pri":"1,3 mln.","rat":0,"mw":"V","link":"Eguchi, Misa <\/a>","confirmed_b":1},{"id":"3417","tem":"0","ctr":"10","nam":"Aoyama, Shuko ","namorig":"Aoyama, Shuko ","cat":"","pri":"1,2 mln.","rat":0,"mw":"V","link":"Aoyama, Shuko <\/a>","confirmed_b":1},{"id":"14283","tem":"45","ctr":"49","nam":"Lee, Ya-Hsuan ","namorig":"Lee, Ya-Hsuan ","cat":"","pri":"1,2 mln.","rat":0,"mw":"V","link":"Lee, Ya-Hsuan <\/a>","confirmed_b":1},{"id":"3215","tem":"0","ctr":"98","nam":"Zhang, Ling ","namorig":"Zhang, Ling ","cat":"","pri":"1,1 mln.","rat":0,"mw":"V","link":"Zhang, Ling <\/a>","confirmed_b":1},{"id":"18825","tem":"45","ctr":"60","nam":"Guarachi, Alexa ","namorig":"Guarachi, Alexa ","cat":"","pri":"1 mln.","rat":0,"mw":"V","link":"Guarachi, Alexa <\/a>","confirmed_b":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Nr.' }, { 'sTitle': 'Groep' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Land', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Tennisser'}, { 'sTitle': 'Waarde', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Team' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'M/V' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'Nr.'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Land' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Waarde', '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 ""; }