$(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":"Engeland"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"Schotland"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Australi\u00eb"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Wales"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Nederland"},"217":{"id":"217","country":"Northern Ireland","countryCode":"NIE","countryTr":"Noord-Ierland"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"Canada"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Oostenrijk"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Duitsland"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Spanje"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Ierland"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"Verenigde Staten"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgi\u00eb"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Zweden"},"218":{"id":"218","country":"Gibraltar","countryCode":"GI","countryTr":"Gibraltar"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"Griekenland"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polen"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"India"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"Zuid-Afrika"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"Denemarken"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"Finland"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Hongarije"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Kroati\u00eb"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Zwitserland"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Noorwegen"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"Itali\u00eb"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"Sloveni\u00eb"},"116":{"id":"116","country":"Singapore","countryCode":"SG","countryTr":"Singapore"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"China"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"Hong Kong"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japan"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"Filipijnen"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"Nieuw-Zeeland"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Tsjechi\u00eb"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Letland"},"43":{"id":"43","country":"Malaysia","countryCode":"MY","countryTr":"Maleisi\u00eb"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Frankrijk"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Rusland"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Thailand"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Litouwen"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Turkije"},"173":{"id":"173","country":"Brunei","countryCode":"BN","countryTr":"Brunei"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Brazili\u00eb"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugal"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Servi\u00eb"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Roemeni\u00eb"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"IJsland"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"Verenigd Koninkrijk"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Oekra\u00efne"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"Bahrein"},"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":"15735","tem":"153","ctr":"214","nam":"Cross, Rob ","namorig":"Cross, Rob ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Cross, Rob <\/a>","confirmed_c":1},{"id":"6803","tem":"153","ctr":"217","nam":"Gurney, Daryl ","namorig":"Gurney, Daryl ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Gurney, Daryl <\/a>","confirmed_c":1},{"id":"4896","tem":"153","ctr":"214","nam":"Lewis, Adrian ","namorig":"Lewis, Adrian ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Lewis, Adrian <\/a>","confirmed_c":1},{"id":"10058","tem":"153","ctr":"216","nam":"Price, Gerwyn ","namorig":"Price, Gerwyn ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Price, Gerwyn <\/a>","confirmed_c":1},{"id":"4943","tem":"153","ctr":"93","nam":"Suljovic, Mensur ","namorig":"Suljovic, Mensur ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Suljovic, Mensur <\/a>","confirmed_c":1},{"id":"4897","tem":"153","ctr":"214","nam":"Wade, James ","namorig":"Wade, James ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Wade, James <\/a>","confirmed_c":1},{"id":"4960","tem":"153","ctr":"214","nam":"White, Ian ","namorig":"White, Ian ","cat":"A","pri":"0","rat":0,"mw":"M","link":"White, Ian <\/a>","confirmed_c":1},{"id":"4925","tem":"153","ctr":"215","nam":"Wright, Peter ","namorig":"Wright, Peter ","cat":"A","pri":"0","rat":0,"mw":"M","link":"Wright, Peter <\/a>","confirmed_c":1},{"id":"11874","tem":"153","ctr":"214","nam":"Aspinall, Nathan ","namorig":"Aspinall, Nathan ","cat":"B","pri":"0","rat":0,"mw":"M","link":"Aspinall, Nathan <\/a>","confirmed_c":1},{"id":"4933","tem":"153","ctr":"214","nam":"Chisnall, Dave ","namorig":"Chisnall, Dave ","cat":"B","pri":"0","rat":0,"mw":"M","link":"Chisnall, Dave <\/a>","confirmed_c":1},{"id":"4946","tem":"153","ctr":"214","nam":"Cullen, Joe ","namorig":"Cullen, Joe ","cat":"B","pri":"0","rat":0,"mw":"M","link":"Cullen, Joe <\/a>","confirmed_c":1},{"id":"8297","tem":"153","ctr":"214","nam":"Durrant, Glen ","namorig":"Durrant, Glen ","cat":"B","pri":"0","rat":0,"mw":"M","link":"Durrant, Glen <\/a>","confirmed_c":1},{"id":"4955","tem":"153","ctr":"214","nam":"Smith, Michael ","namorig":"Smith, Michael ","cat":"B","pri":"0","rat":0,"mw":"M","link":"Smith, Michael <\/a>","confirmed_c":1},{"id":"4899","tem":"153","ctr":"51","nam":"Whitlock, Simon ","namorig":"Whitlock, Simon ","cat":"B","pri":"0","rat":0,"mw":"M","link":"Whitlock, Simon <\/a>","confirmed_c":1},{"id":"4923","tem":"153","ctr":"214","nam":"Beaton, Steve ","namorig":"Beaton, Steve ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Beaton, Steve <\/a>","confirmed_c":1},{"id":"5164","tem":"153","ctr":"214","nam":"Bunting, Stephen ","namorig":"Bunting, Stephen ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Bunting, Stephen <\/a>","confirmed_c":1},{"id":"11873","tem":"153","ctr":"216","nam":"Clayton, Jonny ","namorig":"Clayton, Jonny ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Clayton, Jonny <\/a>","confirmed_c":1},{"id":"10310","tem":"153","ctr":"214","nam":"Dobey, Chris ","namorig":"Dobey, Chris ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Dobey, Chris <\/a>","confirmed_c":1},{"id":"7406","tem":"153","ctr":"214","nam":"Evans, Ricky ","namorig":"Evans, Ricky ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Evans, Ricky <\/a>","confirmed_c":1},{"id":"13607","tem":"153","ctr":"33","nam":"Ratajski, Krzysztof ","namorig":"Ratajski, Krzysztof ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Ratajski, Krzysztof <\/a>","confirmed_c":1},{"id":"11539","tem":"153","ctr":"61","nam":"Wattimena, Jermaine ","namorig":"Wattimena, Jermaine ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Wattimena, Jermaine <\/a>","confirmed_c":1},{"id":"6648","tem":"153","ctr":"214","nam":"Webster, Darren ","namorig":"Webster, Darren ","cat":"C","pri":"0","rat":0,"mw":"M","link":"Webster, Darren <\/a>","confirmed_c":1},{"id":"6646","tem":"153","ctr":"51","nam":"Anderson, Kyle ","namorig":"Anderson, Kyle ","cat":"D","pri":"0","rat":0,"mw":"M","link":"Anderson, Kyle <\/a>","confirmed_c":1},{"id":"16507","tem":"153","ctr":"14","nam":"Clemens, Gabriel ","namorig":"Clemens, Gabriel ","cat":"D","pri":"0","rat":0,"mw":"M","link":"Clemens, Gabriel <\/a>","confirmed_c":1},{"id":"10848","tem":"153","ctr":"76","nam":"Decker, Mike De","namorig":"Decker, Mike De","cat":"D","pri":"0","rat":0,"mw":"M","link":"Decker, Mike De<\/a>","confirmed_c":1},{"id":"15858","tem":"153","ctr":"214","nam":"Joyce, Ryan ","namorig":"Joyce, Ryan ","cat":"D","pri":"0","rat":0,"mw":"M","link":"Joyce, Ryan <\/a>","confirmed_c":1},{"id":"4905","tem":"153","ctr":"214","nam":"King, Mervyn ","namorig":"King, Mervyn ","cat":"D","pri":"0","rat":0,"mw":"M","link":"King, Mervyn <\/a>","confirmed_c":1},{"id":"17506","tem":"153","ctr":"118","nam":"Lennon, Steve ","namorig":"Lennon, Steve ","cat":"D","pri":"0","rat":0,"mw":"M","link":"Lennon, Steve <\/a>","confirmed_c":1},{"id":"4952","tem":"153","ctr":"118","nam":"O'Connor, William ","namorig":"O'Connor, William ","cat":"D","pri":"0","rat":0,"mw":"M","link":"O'Connor, William <\/a>","confirmed_c":1},{"id":"10694","tem":"153","ctr":"14","nam":"Schindler, Martin ","namorig":"Schindler, Martin ","cat":"D","pri":"0","rat":0,"mw":"M","link":"Schindler, Martin <\/a>","confirmed_c":1},{"id":"4910","tem":"153","ctr":"61","nam":"Voort, Vincent van der","namorig":"Voort, Vincent van der","cat":"D","pri":"0","rat":0,"mw":"M","link":"Voort, Vincent van der<\/a>","confirmed_c":1},{"id":"5157","tem":"153","ctr":"214","nam":"West, Steve ","namorig":"West, Steve ","cat":"D","pri":"0","rat":0,"mw":"M","link":"West, Steve <\/a>","confirmed_c":1},{"id":"19877","tem":"153","ctr":"217","nam":"Burness, Kevin ","namorig":"Burness, Kevin ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Burness, Kevin <\/a>","confirmed_c":1},{"id":"22670","tem":"153","ctr":"77","nam":"De Sousa, Jose ","namorig":"De Sousa, Jose ","cat":"E","pri":"0","rat":0,"mw":"M","link":"De Sousa, Jose <\/a>","confirmed_c":1},{"id":"23198","tem":"153","ctr":"109","nam":"Hansen, Niels-J\u00f8rgen ","namorig":"Hansen, Niels-J\u00f8rgen ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Hansen, Niels-J\u00f8rgen <\/a>","confirmed_c":1},{"id":"5053","tem":"153","ctr":"214","nam":"Harrington, Ryan ","namorig":"Harrington, Ryan ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Harrington, Ryan <\/a>","confirmed_c":1},{"id":"19169","tem":"153","ctr":"124","nam":"Harris, Cody ","namorig":"Harris, Cody ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Harris, Cody <\/a>","confirmed_c":1},{"id":"23934","tem":"153","ctr":"112","nam":"Haverinen, Teuvo ","namorig":"Haverinen, Teuvo ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Haverinen, Teuvo <\/a>","confirmed_c":1},{"id":"19874","tem":"153","ctr":"28","nam":"Justicia, Jose ","namorig":"Justicia, Jose ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Justicia, Jose <\/a>","confirmed_c":1},{"id":"22951","tem":"153","ctr":"33","nam":"Kciuk, Krzysztof ","namorig":"Kciuk, Krzysztof ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Kciuk, Krzysztof <\/a>","confirmed_c":1},{"id":"5014","tem":"153","ctr":"109","nam":"Laursen, Per ","namorig":"Laursen, Per ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Laursen, Per <\/a>","confirmed_c":1},{"id":"17282","tem":"153","ctr":"88","nam":"Nilsson, Dennis ","namorig":"Nilsson, Dennis ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Nilsson, Dennis <\/a>","confirmed_c":1},{"id":"4998","tem":"153","ctr":"214","nam":"Robinson, Reece ","namorig":"Robinson, Reece ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Robinson, Reece <\/a>","confirmed_c":1},{"id":"4937","tem":"153","ctr":"214","nam":"Shepherd, Kirk ","namorig":"Shepherd, Kirk ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Shepherd, Kirk <\/a>","confirmed_c":1},{"id":"16496","tem":"153","ctr":"214","nam":"Taylor, Scott ","namorig":"Taylor, Scott ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Taylor, Scott <\/a>","confirmed_c":1},{"id":"5003","tem":"153","ctr":"214","nam":"Todd, Mick ","namorig":"Todd, Mick ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Todd, Mick <\/a>","confirmed_c":1},{"id":"11535","tem":"153","ctr":"112","nam":"Viljanen, Kim ","namorig":"Viljanen, Kim ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Viljanen, Kim <\/a>","confirmed_c":1},{"id":"5160","tem":"153","ctr":"214","nam":"Woodhouse, Luke ","namorig":"Woodhouse, Luke ","cat":"E","pri":"0","rat":0,"mw":"M","link":"Woodhouse, Luke <\/a>","confirmed_c":1}]; var sportsmenTeams = []; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Nr.' }, { 'sTitle': 'Groep' }, { 'sTitle': 'Land', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Darter'}, { 'sTitle': 'Waarde', 'sSortDataType': 'sortMln', 'sType': 'numeric' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Team' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'M/V' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'Nr.'}, { 'sTitle': 'Groep' }, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Land' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Waarde', 'sSortDataType': 'sortMln', 'sType': 'numeric' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //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, v['cat'], "", 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 ""; }