$(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":"Angleterre"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"\u00c9cosse"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"l\u2019Australie"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Pays de Galles"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"les Pays-Bas"},"217":{"id":"217","country":"Northern Ireland","countryCode":"NIE","countryTr":"Irlande du Nord"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"le Canada"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"l\u2019Autriche"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"l\u2019Allemagne"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"l\u2019Espagne"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"l\u2019Irlande"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"les Etats-Unis"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"la Belgique"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"la Su\u00e8de"},"218":{"id":"218","country":"Gibraltar","countryCode":"GI","countryTr":"Gibraltar"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"la Gr\u00e8ce"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"la Pologne"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"l\u2019Inde"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"l\u2019Afrique du Sud"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"le Danemark"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"la Finlande"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"l\u2019Hongrie"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"la Croatie"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"la Suisse"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"la Norv\u00e8ge"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"l\u2019Italie"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"la Slov\u00e9nie"},"116":{"id":"116","country":"Singapore","countryCode":"SG","countryTr":"le Singapour"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"la Chine"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"Hong Kong"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"le Japon"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"les Philippines"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"la Nouvelle Z\u00e9lande"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"la R\u00e9publique Tch\u00e8que"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"la Lettonie"},"43":{"id":"43","country":"Malaysia","countryCode":"MY","countryTr":"la Malaisie"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"la France"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"la Russie"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"la Thailande"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"la Lituanie"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"la Turquie"},"173":{"id":"173","country":"Brunei","countryCode":"BN","countryTr":"le Brunei"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"le Br\u00e9sil"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"le Portugal"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"la Servie"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"la Roumanie"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"l\u2019Islande"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"le Royaume-Uni"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"l\u2019Ukraine"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"le Bahre\u00efn"},"161":{"id":"161","country":"Guyana","countryCode":"GY","countryTr":"Guyana"}}; var teams = {"0":{"id":0,"name":""},"152":{"id":"152","name":"BDO","nameTranslated":"BDO"},"153":{"id":"153","name":"PDC","nameTranslated":"PDC"}}; var sportsmen = [{"id":"4932","tem":"153","ctr":"61","nam":"Gerwen, Michael van","namorig":"Gerwen, Michael van","cat":"","pri":"10 mln.","rat":0,"mw":"H","link":"Gerwen, Michael van<\/a>","confirmed_b":1},{"id":"4955","tem":"153","ctr":"214","nam":"Smith, Michael ","namorig":"Smith, Michael ","cat":"","pri":"7,4 mln.","rat":0,"mw":"H","link":"Smith, Michael <\/a>","confirmed_b":1},{"id":"15735","tem":"153","ctr":"214","nam":"Cross, Rob ","namorig":"Cross, Rob ","cat":"","pri":"5,6 mln.","rat":0,"mw":"H","link":"Cross, Rob <\/a>","confirmed_b":1},{"id":"4897","tem":"153","ctr":"214","nam":"Wade, James ","namorig":"Wade, James ","cat":"","pri":"4,9 mln.","rat":0,"mw":"H","link":"Wade, James <\/a>","confirmed_b":1},{"id":"10058","tem":"153","ctr":"216","nam":"Price, Gerwyn ","namorig":"Price, Gerwyn ","cat":"","pri":"4,8 mln.","rat":0,"mw":"H","link":"Price, Gerwyn <\/a>","confirmed_b":1},{"id":"4925","tem":"153","ctr":"215","nam":"Wright, Peter ","namorig":"Wright, Peter ","cat":"","pri":"4,5 mln.","rat":0,"mw":"H","link":"Wright, Peter <\/a>","confirmed_b":1},{"id":"6803","tem":"153","ctr":"217","nam":"Gurney, Daryl ","namorig":"Gurney, Daryl ","cat":"","pri":"4 mln.","rat":0,"mw":"H","link":"Gurney, Daryl <\/a>","confirmed_b":1},{"id":"4933","tem":"153","ctr":"214","nam":"Chisnall, Dave ","namorig":"Chisnall, Dave ","cat":"","pri":"3,7 mln.","rat":0,"mw":"H","link":"Chisnall, Dave <\/a>","confirmed_b":1},{"id":"4896","tem":"153","ctr":"214","nam":"Lewis, Adrian ","namorig":"Lewis, Adrian ","cat":"","pri":"3,4 mln.","rat":0,"mw":"H","link":"Lewis, Adrian <\/a>","confirmed_b":1},{"id":"4943","tem":"153","ctr":"93","nam":"Suljovic, Mensur ","namorig":"Suljovic, Mensur ","cat":"","pri":"3,2 mln.","rat":0,"mw":"H","link":"Suljovic, Mensur <\/a>","confirmed_b":1},{"id":"4899","tem":"153","ctr":"51","nam":"Whitlock, Simon ","namorig":"Whitlock, Simon ","cat":"","pri":"3,1 mln.","rat":0,"mw":"H","link":"Whitlock, Simon <\/a>","confirmed_b":1},{"id":"5164","tem":"153","ctr":"214","nam":"Bunting, Stephen ","namorig":"Bunting, Stephen ","cat":"","pri":"3 mln.","rat":0,"mw":"H","link":"Bunting, Stephen <\/a>","confirmed_b":1},{"id":"4946","tem":"153","ctr":"214","nam":"Cullen, Joe ","namorig":"Cullen, Joe ","cat":"","pri":"2,3 mln.","rat":0,"mw":"H","link":"Cullen, Joe <\/a>","confirmed_b":1},{"id":"4960","tem":"153","ctr":"214","nam":"White, Ian ","namorig":"White, Ian ","cat":"","pri":"2,1 mln.","rat":0,"mw":"H","link":"White, Ian <\/a>","confirmed_b":1},{"id":"6648","tem":"153","ctr":"214","nam":"Webster, Darren ","namorig":"Webster, Darren ","cat":"","pri":"1,8 mln.","rat":0,"mw":"H","link":"Webster, Darren <\/a>","confirmed_b":1},{"id":"11873","tem":"153","ctr":"216","nam":"Clayton, Jonny ","namorig":"Clayton, Jonny ","cat":"","pri":"1,5 mln.","rat":0,"mw":"H","link":"Clayton, Jonny <\/a>","confirmed_b":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'N°' }, { 'sTitle': 'Groupe' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Pays', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Joueur de fléchettes'}, { 'sTitle': 'Valeur', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Équipe' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'H/F' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'N°'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Pays' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Valeur', '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 ""; }