$(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(' min.', ''); } ); }; $.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":"Danmark"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Russland"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgia"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"Amerika"},"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":"Belarus"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"Kina"},"96":{"id":"96","country":"Israel","countryCode":"IL","countryTr":"Israel"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polen"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Frankrike"},"150":{"id":"150","country":"Estonia","countryCode":"EE","countryTr":"Estland"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Spania"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Romania"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"Slovakia"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Tyskland"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Tsjekkisk Republikk"},"95":{"id":"95","country":"Bulgaria","countryCode":"BG","countryTr":"Bulgaria"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Ukraina"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Ungarn"},"62":{"id":"62","country":"Kazakhstan","countryCode":"KZ","countryTr":"Kazakhstan"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Sveits"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Latvia"},"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":"Japan"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Sverige"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"England"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Thailand"},"44":{"id":"44","country":"Uzbekistan","countryCode":"UZ","countryTr":"Uzbekistan"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"\u00d8sterrike"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Kroatia"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"S\u00f8r-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":"Luxembourg"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Nederland"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"S\u00f8r-Korea"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"India"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"Hellas"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"Paraguay"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Tyrkia"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"Georgia"},"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":"Brasil"},"40":{"id":"40","country":"Peru","countryCode":"PE","countryTr":"Peru"},"113":{"id":"113","country":"Kyrgyzstan","countryCode":"KG","countryTr":"Kyrgyzstan"},"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":"New Zealand"},"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":"Litauen"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Chile"},"79":{"id":"79","country":"Tunisia","countryCode":"TN","countryTr":"Tunisia"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"Marokko"},"127":{"id":"127","country":"Bosnia and Herzegovina","countryCode":"BA","countryTr":"Bosnia og Herzegovina"},"42":{"id":"42","country":"Venezuela","countryCode":"VE","countryTr":"Venezuela"},"159":{"id":"159","country":"Cyprus","countryCode":"CY","countryTr":"Kypros"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"Uruguay"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Irland"},"66":{"id":"66","country":"Ecuador","countryCode":"EC","countryTr":"Ekvador"},"82":{"id":"82","country":"Dominican Republic","countryCode":"DO","countryTr":"Dominikansk Republikk"},"11":{"id":"11","country":"Mexico","countryCode":"MX","countryTr":"Mexico"},"131":{"id":"131","country":"Moldova","countryCode":"MD","countryTr":"Moldova"},"16":{"id":"16","country":"Egypt","countryCode":"EG","countryTr":"Egypt"},"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":"Forente Arabiske Stater"},"164":{"id":"164","country":"Montenegro","countryCode":"ME","countryTr":"Montenegro"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norge"},"177":{"id":"177","country":"Barbados","countryCode":"BB","countryTr":"Barbados"},"144":{"id":"144","country":"North Macedonia","countryCode":"MK","countryTr":"Nord-Makedonia"},"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":"Papua New Guinea"},"199":{"id":"199","country":"Andorra","countryCode":"AD","countryTr":"Andorra"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"Filippinene"},"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":"Jordan"}}; var teams = [{"id":0,"name":""}]; var sportsmen = [{"id":"3589","tem":"0","ctr":"22","nam":"Murray, Andy ","namorig":"Murray, Andy ","cat":"","pri":"22,3 min.","rat":0,"mw":"M","link":"Murray, Andy <\/a>","confirmed_b":1},{"id":"3615","tem":"0","ctr":"19","nam":"Gasquet, Richard ","namorig":"Gasquet, Richard ","cat":"","pri":"13,8 min.","rat":0,"mw":"M","link":"Gasquet, Richard <\/a>","confirmed_b":1},{"id":"3597","tem":"0","ctr":"19","nam":"Monfils, Gael ","namorig":"Monfils, Gael ","cat":"","pri":"8,3 min.","rat":0,"mw":"M","link":"Monfils, Gael <\/a>","confirmed_b":1},{"id":"3746","tem":"0","ctr":"33","nam":"Janowicz, Jerzy ","namorig":"Janowicz, Jerzy ","cat":"","pri":"7,2 min.","rat":0,"mw":"M","link":"Janowicz, Jerzy <\/a>","confirmed_b":1},{"id":"3691","tem":"0","ctr":"95","nam":"Dimitrov, Grigor ","namorig":"Dimitrov, Grigor ","cat":"","pri":"6,5 min.","rat":0,"mw":"M","link":"Dimitrov, Grigor <\/a>","confirmed_b":1},{"id":"3599","tem":"0","ctr":"120","nam":"Cilic, Marin ","namorig":"Cilic, Marin ","cat":"","pri":"5,8 min.","rat":0,"mw":"M","link":"Cilic, Marin <\/a>","confirmed_b":1},{"id":"3609","tem":"0","ctr":"142","nam":"Gulbis, Ernests ","namorig":"Gulbis, Ernests ","cat":"","pri":"5,1 min.","rat":0,"mw":"M","link":"Gulbis, Ernests <\/a>","confirmed_b":1},{"id":"3782","tem":"0","ctr":"9","nam":"Tursunov, Dmitry ","namorig":"Tursunov, Dmitry ","cat":"","pri":"4,7 min.","rat":0,"mw":"M","link":"Tursunov, Dmitry <\/a>","confirmed_b":1},{"id":"3594","tem":"0","ctr":"28","nam":"Verdasco, Fernando ","namorig":"Verdasco, Fernando ","cat":"","pri":"3,8 min.","rat":0,"mw":"M","link":"Verdasco, Fernando <\/a>","confirmed_b":1},{"id":"3709","tem":"0","ctr":"19","nam":"Roger-Vasselin, Edouard ","namorig":"Roger-Vasselin, Edouard ","cat":"","pri":"3,7 min.","rat":0,"mw":"M","link":"Roger-Vasselin, Edouard <\/a>","confirmed_b":1},{"id":"3673","tem":"0","ctr":"120","nam":"Dodig, Ivan ","namorig":"Dodig, Ivan ","cat":"","pri":"3,6 min.","rat":0,"mw":"M","link":"Dodig, Ivan <\/a>","confirmed_b":1},{"id":"3625","tem":"0","ctr":"44","nam":"Istomin, Denis ","namorig":"Istomin, Denis ","cat":"","pri":"3,2 min.","rat":0,"mw":"M","link":"Istomin, Denis <\/a>","confirmed_b":1},{"id":"3717","tem":"0","ctr":"19","nam":"Mahut, Nicolas ","namorig":"Mahut, Nicolas ","cat":"","pri":"2,8 min.","rat":0,"mw":"M","link":"Mahut, Nicolas <\/a>","confirmed_b":1},{"id":"3749","tem":"0","ctr":"78","nam":"Rosol, Lukas ","namorig":"Rosol, Lukas ","cat":"","pri":"2,7 min.","rat":0,"mw":"M","link":"Rosol, Lukas <\/a>","confirmed_b":1},{"id":"3711","tem":"0","ctr":"61","nam":"Sijsling, Igor ","namorig":"Sijsling, Igor ","cat":"","pri":"2,4 min.","rat":0,"mw":"M","link":"Sijsling, Igor <\/a>","confirmed_b":1},{"id":"8555","tem":"45","ctr":"93","nam":"Thiem, Dominic ","namorig":"Thiem, Dominic ","cat":"","pri":"2,1 min.","rat":0,"mw":"M","link":"Thiem, Dominic <\/a>","confirmed_b":1},{"id":"3713","tem":"0","ctr":"61","nam":"Huta Galung, Jesse ","namorig":"Huta Galung, Jesse ","cat":"","pri":"1,9 min.","rat":0,"mw":"M","link":"Huta Galung, Jesse <\/a>","confirmed_b":1},{"id":"3628","tem":"0","ctr":"61","nam":"Bakker, Thiemo de","namorig":"Bakker, Thiemo de","cat":"","pri":"1,7 min.","rat":0,"mw":"M","link":"Bakker, Thiemo de<\/a>","confirmed_b":1},{"id":"3643","tem":"0","ctr":"14","nam":"Berrer, Michael ","namorig":"Berrer, Michael ","cat":"","pri":"1,6 min.","rat":0,"mw":"M","link":"Berrer, Michael <\/a>","confirmed_b":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Nr.' }, { 'sTitle': 'Gruppe' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Land', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Tennisspiller'}, { 'sTitle': 'Verdi', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Lag' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'M/K' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'Nr.'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Land' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Verdi', '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(' min.', '').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 ""; }