$(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 = {"214":{"id":"214","country":"England","countryCode":"EN","countryTr":"England"},"217":{"id":"217","country":"Northern Ireland","countryCode":"NIE","countryTr":"Northern Ireland"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"United States"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Germany"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Australia"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"South Africa"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"South Korea"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Sweden"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"Denmark"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"Italy"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"Scotland"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Spain"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japan"},"158":{"id":"158","country":"Fiji","countryCode":"FJ","countryTr":"Fiji"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"Slovakia"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgium"},"29":{"id":"29","country":"Colombia","countryCode":"CO","countryTr":"Colombia"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Ireland"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Wales"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"France"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Netherlands"},"42":{"id":"42","country":"Venezuela","countryCode":"VE","countryTr":"Venezuela"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"Argentina"},"69":{"id":"69","country":"Zimbabwe","countryCode":"ZW","countryTr":"Zimbabwe"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Thailand"},"7":{"id":"7","country":"Bangladesh","countryCode":"BD","countryTr":"Bangladesh"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"New Zealand"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"India"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Austria"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Chile"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"China"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"Canada"},"116":{"id":"116","country":"Singapore","countryCode":"SG","countryTr":"Singapore"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugal"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"Paraguay"},"49":{"id":"49","country":"Taiwan","countryCode":"TW","countryTr":"Taiwan"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"Finland"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Brazil"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"Philippines"},"11":{"id":"11","country":"Mexico","countryCode":"MX","countryTr":"Mexico"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norway"},"43":{"id":"43","country":"Malaysia","countryCode":"MY","countryTr":"Malaysia"},"119":{"id":"119","country":"Costa Rica","countryCode":"CR","countryTr":"Costa Rica"},"126":{"id":"126","country":"Puerto Rico","countryCode":"PR","countryTr":"Puerto Rico"},"122":{"id":"122","country":"United Arab Emirates","countryCode":"AE","countryTr":"United Arab Emirates"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"Iceland"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Turkey"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Switzerland"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Poland"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"Morocco"},"105":{"id":"105","country":"Jordan","countryCode":"JO","countryTr":"Jordan"},"46":{"id":"46","country":"Saudi Arabia","countryCode":"SA","countryTr":"Saudi Arabia"},"40":{"id":"40","country":"Peru","countryCode":"PE","countryTr":"Peru"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Czech Republic"},"203":{"id":"203","country":"Bermuda","countryCode":"BM","countryTr":"Bermuda"},"220":{"id":"220","country":"Cayman Islands","countryCode":"KY","countryTr":"Cayman Islands"},"68":{"id":"68","country":"Guatemala","countryCode":"GT","countryTr":"Guatemala"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"Hong Kong"},"66":{"id":"66","country":"Ecuador","countryCode":"EC","countryTr":"Ecuador"}}; var teams = [{"id":0,"name":""}]; var sportsmen = [{"id":"5644","tem":"0","ctr":"3","nam":"Spieth, Jordan ","namorig":"Spieth, Jordan ","cat":"","pri":"20 mln.","rat":0,"mw":"M","link":"Spieth, Jordan <\/a>","confirmed_b":1},{"id":"4415","tem":"0","ctr":"3","nam":"Johnson, Dustin ","namorig":"Johnson, Dustin ","cat":"","pri":"18.1 mln.","rat":0,"mw":"M","link":"Johnson, Dustin <\/a>","confirmed_b":1},{"id":"15875","tem":"0","ctr":"28","nam":"Rahm, Jon ","namorig":"Rahm, Jon ","cat":"","pri":"15.8 mln.","rat":0,"mw":"M","link":"Rahm, Jon <\/a>","confirmed_b":1},{"id":"4446","tem":"0","ctr":"3","nam":"Fowler, Rickie ","namorig":"Fowler, Rickie ","cat":"","pri":"15.6 mln.","rat":0,"mw":"M","link":"Fowler, Rickie <\/a>","confirmed_b":1},{"id":"10511","tem":"0","ctr":"3","nam":"Thomas, Justin ","namorig":"Thomas, Justin ","cat":"","pri":"15.5 mln.","rat":0,"mw":"M","link":"Thomas, Justin <\/a>","confirmed_b":1},{"id":"5502","tem":"0","ctr":"10","nam":"Matsuyama, Hideki ","namorig":"Matsuyama, Hideki ","cat":"","pri":"14.7 mln.","rat":0,"mw":"M","link":"Matsuyama, Hideki <\/a>","confirmed_b":1},{"id":"4417","tem":"0","ctr":"51","nam":"Day, Jason ","namorig":"Day, Jason ","cat":"","pri":"12.4 mln.","rat":0,"mw":"M","link":"Day, Jason <\/a>","confirmed_b":1},{"id":"4419","tem":"0","ctr":"3","nam":"Kuchar, Matt ","namorig":"Kuchar, Matt ","cat":"","pri":"12.3 mln.","rat":0,"mw":"M","link":"Kuchar, Matt <\/a>","confirmed_b":1},{"id":"4548","tem":"0","ctr":"51","nam":"Leishman, Marc ","namorig":"Leishman, Marc ","cat":"","pri":"12.2 mln.","rat":0,"mw":"M","link":"Leishman, Marc <\/a>","confirmed_b":1},{"id":"4427","tem":"0","ctr":"214","nam":"Rose, Justin ","namorig":"Rose, Justin ","cat":"","pri":"11.9 mln.","rat":0,"mw":"M","link":"Rose, Justin <\/a>","confirmed_b":1},{"id":"5617","tem":"0","ctr":"3","nam":"Koepka, Brooks ","namorig":"Koepka, Brooks ","cat":"","pri":"11.5 mln.","rat":0,"mw":"M","link":"Koepka, Brooks <\/a>","confirmed_b":1},{"id":"4457","tem":"0","ctr":"28","nam":"Garcia, Sergio ","namorig":"Garcia, Sergio ","cat":"","pri":"11.1 mln.","rat":0,"mw":"M","link":"Garcia, Sergio <\/a>","confirmed_b":1},{"id":"4430","tem":"0","ctr":"214","nam":"Casey, Paul ","namorig":"Casey, Paul ","cat":"","pri":"10 mln.","rat":0,"mw":"M","link":"Casey, Paul <\/a>","confirmed_b":1},{"id":"7509","tem":"0","ctr":"3","nam":"Reed, Patrick ","namorig":"Reed, Patrick ","cat":"","pri":"8.8 mln.","rat":0,"mw":"M","link":"Reed, Patrick <\/a>","confirmed_b":1},{"id":"4476","tem":"0","ctr":"3","nam":"Hoffman, Charley ","namorig":"Hoffman, Charley ","cat":"","pri":"8.5 mln.","rat":0,"mw":"M","link":"Hoffman, Charley <\/a>","confirmed_b":1},{"id":"4562","tem":"0","ctr":"3","nam":"Chappell, Kevin ","namorig":"Chappell, Kevin ","cat":"","pri":"8.4 mln.","rat":0,"mw":"M","link":"Chappell, Kevin <\/a>","confirmed_b":1},{"id":"10480","tem":"0","ctr":"3","nam":"Berger, Daniel ","namorig":"Berger, Daniel ","cat":"","pri":"8.1 mln.","rat":0,"mw":"M","link":"Berger, Daniel <\/a>","confirmed_b":1},{"id":"4423","tem":"0","ctr":"3","nam":"Simpson, Webb ","namorig":"Simpson, Webb ","cat":"","pri":"6.7 mln.","rat":0,"mw":"M","link":"Simpson, Webb <\/a>","confirmed_b":1},{"id":"10433","tem":"0","ctr":"3","nam":"Kisner, Kevin ","namorig":"Kisner, Kevin ","cat":"","pri":"6.6 mln.","rat":0,"mw":"M","link":"Kisner, Kevin <\/a>","confirmed_b":1},{"id":"5610","tem":"0","ctr":"3","nam":"Harman, Brian ","namorig":"Harman, Brian ","cat":"","pri":"6.3 mln.","rat":0,"mw":"M","link":"Harman, Brian <\/a>","confirmed_b":1},{"id":"4553","tem":"0","ctr":"3","nam":"Perez, Pat ","namorig":"Perez, Pat ","cat":"","pri":"5.9 mln.","rat":0,"mw":"M","link":"Perez, Pat <\/a>","confirmed_b":1},{"id":"11889","tem":"0","ctr":"3","nam":"Finau, Tony ","namorig":"Finau, Tony ","cat":"","pri":"5.5 mln.","rat":0,"mw":"M","link":"Finau, Tony <\/a>","confirmed_b":1},{"id":"5503","tem":"0","ctr":"3","nam":"Cantlay, Patrick ","namorig":"Cantlay, Patrick ","cat":"","pri":"5.2 mln.","rat":0,"mw":"M","link":"Cantlay, Patrick <\/a>","confirmed_b":1},{"id":"4516","tem":"0","ctr":"42","nam":"Vegas, Jhonattan ","namorig":"Vegas, Jhonattan ","cat":"","pri":"5 mln.","rat":0,"mw":"M","link":"Vegas, Jhonattan <\/a>","confirmed_b":1},{"id":"4441","tem":"0","ctr":"3","nam":"Dufner, Jason ","namorig":"Dufner, Jason ","cat":"","pri":"4.7 mln.","rat":0,"mw":"M","link":"Dufner, Jason <\/a>","confirmed_b":1},{"id":"4452","tem":"0","ctr":"3","nam":"Woodland, Gary ","namorig":"Woodland, Gary ","cat":"","pri":"4.5 mln.","rat":0,"mw":"M","link":"Woodland, Gary <\/a>","confirmed_b":1},{"id":"4640","tem":"0","ctr":"36","nam":"Hadwin, Adam ","namorig":"Hadwin, Adam ","cat":"","pri":"4.3 mln.","rat":0,"mw":"M","link":"Hadwin, Adam <\/a>","confirmed_b":1},{"id":"17703","tem":"0","ctr":"3","nam":"Schauffele, Xander ","namorig":"Schauffele, Xander ","cat":"","pri":"4.2 mln.","rat":0,"mw":"M","link":"Schauffele, Xander <\/a>","confirmed_b":1},{"id":"7242","tem":"0","ctr":"3","nam":"Henley, Russell ","namorig":"Henley, Russell ","cat":"","pri":"3.7 mln.","rat":0,"mw":"M","link":"Henley, Russell <\/a>","confirmed_b":1},{"id":"4551","tem":"0","ctr":"3","nam":"Stanley, Kyle ","namorig":"Stanley, Kyle ","cat":"","pri":"3.5 mln.","rat":0,"mw":"M","link":"Stanley, Kyle <\/a>","confirmed_b":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Nr.' }, { 'sTitle': 'Group' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Country', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Golf player'}, { 'sTitle': 'Value', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Team' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'M/F' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'Nr.'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Country' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Value', '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 ""; }