$(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(' млн.', ''); } ); }; $.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":"\u0410\u043d\u0433\u043b\u0438\u044f"},"217":{"id":"217","country":"Northern Ireland","countryCode":"NIE","countryTr":"\u0421\u0435\u0432\u0435\u0440\u043d\u0430\u044f \u0418\u0440\u043b\u0430\u043d\u0434\u0438\u044f"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0428\u0442\u0430\u0442\u044b"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"\u0413\u0435\u0440\u043c\u0430\u043d\u0438\u044f"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"\u0410\u0432\u0441\u0442\u0440\u0430\u043b\u0438\u044f"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"\u042e\u0436\u043d\u0430\u044f \u0410\u0444\u0440\u0438\u043a\u0430"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"\u042e\u0436\u043d\u0430\u044f \u041a\u043e\u0440\u0435\u044f"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"\u0428\u0432\u0435\u0446\u0438\u044f"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"\u0414\u0430\u043d\u0438\u044f"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"\u0418\u0442\u0430\u043b\u0438\u044f"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"\u0428\u043e\u0442\u043b\u0430\u043d\u0434\u0438\u044f"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"\u0418\u0441\u043f\u0430\u043d\u0438\u044f"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"\u042f\u043f\u043e\u043d\u0438\u044f"},"158":{"id":"158","country":"Fiji","countryCode":"FJ","countryTr":"\u0424\u0438\u0434\u0436\u0438"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"\u0421\u043b\u043e\u0432\u0430\u043a\u0438\u044f"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"\u0411\u0435\u043b\u044c\u0433\u0438\u044f"},"29":{"id":"29","country":"Colombia","countryCode":"CO","countryTr":"\u041a\u043e\u043b\u0443\u043c\u0431\u0438\u044f"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"\u0418\u0440\u043b\u0430\u043d\u0434\u0438\u044f"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"\u0423\u044d\u043b\u044c\u0441"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"\u0424\u0440\u0430\u043d\u0446\u0438\u044f"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"\u041d\u0438\u0434\u0435\u0440\u043b\u0430\u043d\u0434\u044b"},"42":{"id":"42","country":"Venezuela","countryCode":"VE","countryTr":"\u0412\u0435\u043d\u0435\u0441\u0443\u044d\u043b\u0430"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"\u0410\u0440\u0433\u0435\u043d\u0442\u0438\u043d\u0430"},"69":{"id":"69","country":"Zimbabwe","countryCode":"ZW","countryTr":"\u0417\u0438\u043c\u0431\u0430\u0431\u0432\u0435"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"\u0422\u0430\u0439\u043b\u0430\u043d\u0434"},"7":{"id":"7","country":"Bangladesh","countryCode":"BD","countryTr":"\u0411\u0430\u043d\u0433\u043b\u0430\u0434\u0435\u0448"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"\u041d\u043e\u0432\u0430\u044f \u0417\u0435\u043b\u0430\u043d\u0434\u0438\u044f"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"\u0418\u043d\u0434\u0438\u044f"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"\u0410\u0432\u0441\u0442\u0440\u0438\u044f"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"\u0427\u0438\u043b\u0438"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"\u041a\u0438\u0442\u0430\u0439"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"\u041a\u0430\u043d\u0430\u0434\u0430"},"116":{"id":"116","country":"Singapore","countryCode":"SG","countryTr":"\u0421\u0438\u043d\u0433\u0430\u043f\u0443\u0440"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"\u041f\u043e\u0440\u0442\u0443\u0433\u0430\u043b\u0438\u044f"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"\u041f\u0430\u0440\u0430\u0433\u0432\u0430\u0439"},"49":{"id":"49","country":"Taiwan","countryCode":"TW","countryTr":"\u0422\u0430\u0439\u0432\u0430\u043d\u044c"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"\u0424\u0438\u043d\u043b\u044f\u043d\u0434\u0438\u044f"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"\u0411\u0440\u0430\u0437\u0438\u043b\u0438\u044f"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"\u0424\u0438\u043b\u0438\u043f\u0438\u043d\u044b"},"11":{"id":"11","country":"Mexico","countryCode":"MX","countryTr":"\u041c\u0435\u043a\u0441\u0438\u043a\u0430"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"\u041d\u043e\u0440\u0432\u0435\u0433\u0438\u044f"},"43":{"id":"43","country":"Malaysia","countryCode":"MY","countryTr":"\u041c\u0430\u043b\u0430\u0439\u0437\u0438\u044f"},"119":{"id":"119","country":"Costa Rica","countryCode":"CR","countryTr":"\u041a\u043e\u0441\u0442\u0430-\u0420\u0438\u043a\u0430"},"126":{"id":"126","country":"Puerto Rico","countryCode":"PR","countryTr":"\u041f\u0443\u044d\u0440\u0442\u043e-\u0420\u0438\u043a\u043e"},"122":{"id":"122","country":"United Arab Emirates","countryCode":"AE","countryTr":"\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0435 \u0410\u0440\u0430\u0431\u0441\u043a\u0438\u0435 \u042d\u043c\u0438\u0440\u0430\u0442\u044b"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"\u0418\u0441\u043b\u0430\u043d\u0434\u0438\u044f"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"\u0422\u0443\u0440\u0446\u0438\u044f"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"\u0428\u0432\u0435\u0439\u0446\u0430\u0440\u0438\u044f"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"\u041f\u043e\u043b\u044c\u0448\u0430"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"\u041c\u0430\u0440\u043e\u043a\u043a\u043e"},"105":{"id":"105","country":"Jordan","countryCode":"JO","countryTr":"\u0418\u043e\u0440\u0434\u0430\u043d\u0438\u044f"},"46":{"id":"46","country":"Saudi Arabia","countryCode":"SA","countryTr":"\u0421\u0430\u0443\u0434\u043e\u0432\u0441\u043a\u0430\u044f \u0410\u0440\u0430\u0432\u0438\u044f"},"40":{"id":"40","country":"Peru","countryCode":"PE","countryTr":"\u041f\u0435\u0440\u0443"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"\u0427\u0435\u0445\u0438\u044f"},"203":{"id":"203","country":"Bermuda","countryCode":"BM","countryTr":"\u0411\u0435\u0440\u043c\u0443\u0434\u0441\u043a\u0438\u0435 \u043e\u0441\u0442\u0440\u043e\u0432\u0430"},"220":{"id":"220","country":"Cayman Islands","countryCode":"KY","countryTr":"Cayman Islands"},"68":{"id":"68","country":"Guatemala","countryCode":"GT","countryTr":"\u0413\u0432\u0430\u0442\u0435\u043c\u0430\u043b\u0430"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"\u0413\u043e\u043d\u043a\u043e\u043d\u0433"},"66":{"id":"66","country":"Ecuador","countryCode":"EC","countryTr":"\u042d\u043a\u0432\u0430\u0434\u043e\u0440"}}; var teams = [{"id":0,"name":""}]; var sportsmen = [{"id":"5644","tem":"0","ctr":"3","nam":"Spieth, Jordan ","namorig":"Spieth, Jordan ","cat":"","pri":"20 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Spieth, Jordan <\/a>","confirmed_b":1},{"id":"4415","tem":"0","ctr":"3","nam":"Johnson, Dustin ","namorig":"Johnson, Dustin ","cat":"","pri":"18,1 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Johnson, Dustin <\/a>","confirmed_b":1},{"id":"15875","tem":"0","ctr":"28","nam":"Rahm, Jon ","namorig":"Rahm, Jon ","cat":"","pri":"15,8 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Rahm, Jon <\/a>","confirmed_b":1},{"id":"4446","tem":"0","ctr":"3","nam":"Fowler, Rickie ","namorig":"Fowler, Rickie ","cat":"","pri":"15,6 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Fowler, Rickie <\/a>","confirmed_b":1},{"id":"10511","tem":"0","ctr":"3","nam":"Thomas, Justin ","namorig":"Thomas, Justin ","cat":"","pri":"15,5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Thomas, Justin <\/a>","confirmed_b":1},{"id":"5502","tem":"0","ctr":"10","nam":"Matsuyama, Hideki ","namorig":"Matsuyama, Hideki ","cat":"","pri":"14,7 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Matsuyama, Hideki <\/a>","confirmed_b":1},{"id":"4417","tem":"0","ctr":"51","nam":"Day, Jason ","namorig":"Day, Jason ","cat":"","pri":"12,4 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Day, Jason <\/a>","confirmed_b":1},{"id":"4419","tem":"0","ctr":"3","nam":"Kuchar, Matt ","namorig":"Kuchar, Matt ","cat":"","pri":"12,3 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Kuchar, Matt <\/a>","confirmed_b":1},{"id":"4548","tem":"0","ctr":"51","nam":"Leishman, Marc ","namorig":"Leishman, Marc ","cat":"","pri":"12,2 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Leishman, Marc <\/a>","confirmed_b":1},{"id":"4427","tem":"0","ctr":"214","nam":"Rose, Justin ","namorig":"Rose, Justin ","cat":"","pri":"11,9 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Rose, Justin <\/a>","confirmed_b":1},{"id":"5617","tem":"0","ctr":"3","nam":"Koepka, Brooks ","namorig":"Koepka, Brooks ","cat":"","pri":"11,5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Koepka, Brooks <\/a>","confirmed_b":1},{"id":"4457","tem":"0","ctr":"28","nam":"Garcia, Sergio ","namorig":"Garcia, Sergio ","cat":"","pri":"11,1 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Garcia, Sergio <\/a>","confirmed_b":1},{"id":"4430","tem":"0","ctr":"214","nam":"Casey, Paul ","namorig":"Casey, Paul ","cat":"","pri":"10 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Casey, Paul <\/a>","confirmed_b":1},{"id":"7509","tem":"0","ctr":"3","nam":"Reed, Patrick ","namorig":"Reed, Patrick ","cat":"","pri":"8,8 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Reed, Patrick <\/a>","confirmed_b":1},{"id":"4476","tem":"0","ctr":"3","nam":"Hoffman, Charley ","namorig":"Hoffman, Charley ","cat":"","pri":"8,5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Hoffman, Charley <\/a>","confirmed_b":1},{"id":"4562","tem":"0","ctr":"3","nam":"Chappell, Kevin ","namorig":"Chappell, Kevin ","cat":"","pri":"8,4 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Chappell, Kevin <\/a>","confirmed_b":1},{"id":"10480","tem":"0","ctr":"3","nam":"Berger, Daniel ","namorig":"Berger, Daniel ","cat":"","pri":"8,1 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Berger, Daniel <\/a>","confirmed_b":1},{"id":"4423","tem":"0","ctr":"3","nam":"Simpson, Webb ","namorig":"Simpson, Webb ","cat":"","pri":"6,7 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Simpson, Webb <\/a>","confirmed_b":1},{"id":"10433","tem":"0","ctr":"3","nam":"Kisner, Kevin ","namorig":"Kisner, Kevin ","cat":"","pri":"6,6 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Kisner, Kevin <\/a>","confirmed_b":1},{"id":"5610","tem":"0","ctr":"3","nam":"Harman, Brian ","namorig":"Harman, Brian ","cat":"","pri":"6,3 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Harman, Brian <\/a>","confirmed_b":1},{"id":"4553","tem":"0","ctr":"3","nam":"Perez, Pat ","namorig":"Perez, Pat ","cat":"","pri":"5,9 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Perez, Pat <\/a>","confirmed_b":1},{"id":"11889","tem":"0","ctr":"3","nam":"Finau, Tony ","namorig":"Finau, Tony ","cat":"","pri":"5,5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Finau, Tony <\/a>","confirmed_b":1},{"id":"5503","tem":"0","ctr":"3","nam":"Cantlay, Patrick ","namorig":"Cantlay, Patrick ","cat":"","pri":"5,2 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Cantlay, Patrick <\/a>","confirmed_b":1},{"id":"4516","tem":"0","ctr":"42","nam":"Vegas, Jhonattan ","namorig":"Vegas, Jhonattan ","cat":"","pri":"5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Vegas, Jhonattan <\/a>","confirmed_b":1},{"id":"4441","tem":"0","ctr":"3","nam":"Dufner, Jason ","namorig":"Dufner, Jason ","cat":"","pri":"4,7 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Dufner, Jason <\/a>","confirmed_b":1},{"id":"4452","tem":"0","ctr":"3","nam":"Woodland, Gary ","namorig":"Woodland, Gary ","cat":"","pri":"4,5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Woodland, Gary <\/a>","confirmed_b":1},{"id":"4640","tem":"0","ctr":"36","nam":"Hadwin, Adam ","namorig":"Hadwin, Adam ","cat":"","pri":"4,3 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Hadwin, Adam <\/a>","confirmed_b":1},{"id":"17703","tem":"0","ctr":"3","nam":"Schauffele, Xander ","namorig":"Schauffele, Xander ","cat":"","pri":"4,2 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Schauffele, Xander <\/a>","confirmed_b":1},{"id":"7242","tem":"0","ctr":"3","nam":"Henley, Russell ","namorig":"Henley, Russell ","cat":"","pri":"3,7 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Henley, Russell <\/a>","confirmed_b":1},{"id":"4551","tem":"0","ctr":"3","nam":"Stanley, Kyle ","namorig":"Stanley, Kyle ","cat":"","pri":"3,5 \u043c\u043b\u043d.","rat":0,"mw":"\u041c","link":"Stanley, Kyle <\/a>","confirmed_b":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': '№.' }, { 'sTitle': 'Группа' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Страна', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'игрок в гольф'}, { 'sTitle': 'Стоимость', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Команда' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'М/Ж' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': '№.'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Страна' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Стоимость', '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(' млн.', '').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 ""; }