$(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"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"Scotland"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Australia"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Wales"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Netherlands"},"217":{"id":"217","country":"Northern Ireland","countryCode":"NIE","countryTr":"Northern Ireland"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"Canada"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Austria"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Germany"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Spain"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Ireland"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"United States"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgium"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Sweden"},"218":{"id":"218","country":"Gibraltar","countryCode":"GI","countryTr":"Gibraltar"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"Greece"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Poland"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"India"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"South Africa"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"Denmark"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"Finland"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Hungary"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Croatia"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Switzerland"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norway"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"Italy"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"Slovenia"},"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":"Philippines"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"New Zealand"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Czech Republic"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Latvia"},"43":{"id":"43","country":"Malaysia","countryCode":"MY","countryTr":"Malaysia"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"France"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Russia"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Thailand"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Lithuania"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Turkey"},"173":{"id":"173","country":"Brunei","countryCode":"BN","countryTr":"Brunei"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Brazil"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugal"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Serbia"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Romania"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"Iceland"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"United Kingdom"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Ukraine"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"Bahrain"},"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":"8297","tem":"153","ctr":"214","nam":"Durrant, Glen ","namorig":"Durrant, Glen ","cat":"","pri":"20 mln.","rat":0,"mw":"M","link":"Durrant, Glen <\/a>","confirmed_b":1},{"id":"8576","tem":"153","ctr":"61","nam":"Noppert, Danny ","namorig":"Noppert, Danny ","cat":"","pri":"13.4 mln.","rat":0,"mw":"M","link":"Noppert, Danny <\/a>","confirmed_b":1},{"id":"11041","tem":"153","ctr":"214","nam":"Hughes, Jamie ","namorig":"Hughes, Jamie ","cat":"","pri":"12.5 mln.","rat":0,"mw":"M","link":"Hughes, Jamie <\/a>","confirmed_b":1},{"id":"5155","tem":"153","ctr":"214","nam":"Mitchell, Scott ","namorig":"Mitchell, Scott ","cat":"","pri":"11.3 mln.","rat":0,"mw":"M","link":"Mitchell, Scott <\/a>","confirmed_b":1},{"id":"12050","tem":"153","ctr":"214","nam":"McGeeney, Mark ","namorig":"McGeeney, Mark ","cat":"","pri":"8.6 mln.","rat":0,"mw":"M","link":"McGeeney, Mark <\/a>","confirmed_b":1},{"id":"5144","tem":"153","ctr":"214","nam":"Waites, Scott ","namorig":"Waites, Scott ","cat":"","pri":"7.9 mln.","rat":0,"mw":"M","link":"Waites, Scott <\/a>","confirmed_b":1},{"id":"5142","tem":"153","ctr":"76","nam":"Vos, Geert De","namorig":"Vos, Geert De","cat":"","pri":"7.2 mln.","rat":0,"mw":"M","link":"Vos, Geert De<\/a>","confirmed_b":1},{"id":"5171","tem":"153","ctr":"61","nam":"Harms, Wesley ","namorig":"Harms, Wesley ","cat":"","pri":"6.8 mln.","rat":0,"mw":"M","link":"Harms, Wesley <\/a>","confirmed_b":1},{"id":"8286","tem":"153","ctr":"216","nam":"Williams, Jim ","namorig":"Williams, Jim ","cat":"","pri":"6.1 mln.","rat":0,"mw":"M","link":"Williams, Jim <\/a>","confirmed_b":1},{"id":"5180","tem":"153","ctr":"215","nam":"Montgomery, Ross ","namorig":"Montgomery, Ross ","cat":"","pri":"5.7 mln.","rat":0,"mw":"M","link":"Montgomery, Ross <\/a>","confirmed_b":1},{"id":"5143","tem":"153","ctr":"214","nam":"Adams, Martin ","namorig":"Adams, Martin ","cat":"","pri":"5 mln.","rat":0,"mw":"M","link":"Adams, Martin <\/a>","confirmed_b":1},{"id":"18940","tem":"153","ctr":"215","nam":"Menzies, Cameron ","namorig":"Menzies, Cameron ","cat":"","pri":"4.8 mln.","rat":0,"mw":"M","link":"Menzies, Cameron <\/a>","confirmed_b":1},{"id":"11038","tem":"152","ctr":"61","nam":"Mandigers, Willem ","namorig":"Mandigers, Willem ","cat":"","pri":"4.4 mln.","rat":0,"mw":"M","link":"Mandigers, Willem <\/a>","confirmed_b":1},{"id":"11181","tem":"153","ctr":"61","nam":"Veenstra, Richard ","namorig":"Veenstra, Richard ","cat":"","pri":"4.1 mln.","rat":0,"mw":"M","link":"Veenstra, Richard <\/a>","confirmed_b":1},{"id":"10317","tem":"152","ctr":"216","nam":"Reynolds, Dean ","namorig":"Reynolds, Dean ","cat":"","pri":"3.6 mln.","rat":0,"mw":"M","link":"Reynolds, Dean <\/a>","confirmed_b":1},{"id":"5184","tem":"152","ctr":"216","nam":"Phillips, Martin ","namorig":"Phillips, Martin ","cat":"","pri":"3.3 mln.","rat":0,"mw":"M","link":"Phillips, Martin <\/a>","confirmed_b":1},{"id":"16823","tem":"153","ctr":"76","nam":"Baetens, Andy ","namorig":"Baetens, Andy ","cat":"","pri":"3.2 mln.","rat":0,"mw":"M","link":"Baetens, Andy <\/a>","confirmed_b":1},{"id":"11040","tem":"153","ctr":"132","nam":"Labanauskas, Darius ","namorig":"Labanauskas, Darius ","cat":"","pri":"3.1 mln.","rat":0,"mw":"M","link":"Labanauskas, Darius <\/a>","confirmed_b":1},{"id":"5154","tem":"152","ctr":"214","nam":"Fitton, Darryl ","namorig":"Fitton, Darryl ","cat":"","pri":"3 mln.","rat":0,"mw":"M","link":"Fitton, Darryl <\/a>","confirmed_b":1},{"id":"19277","tem":"153","ctr":"217","nam":"McKinstry, Kyle ","namorig":"McKinstry, Kyle ","cat":"","pri":"2.9 mln.","rat":0,"mw":"M","link":"McKinstry, Kyle <\/a>","confirmed_b":1},{"id":"15856","tem":"153","ctr":"216","nam":"Kenny, Nick ","namorig":"Kenny, Nick ","cat":"","pri":"2.8 mln.","rat":0,"mw":"M","link":"Kenny, Nick <\/a>","confirmed_b":1},{"id":"7441","tem":"153","ctr":"214","nam":"Whitehead, Conan ","namorig":"Whitehead, Conan ","cat":"","pri":"2.7 mln.","rat":0,"mw":"M","link":"Whitehead, Conan <\/a>","confirmed_b":1},{"id":"19276","tem":"153","ctr":"214","nam":"Baker, Scott ","namorig":"Baker, Scott ","cat":"","pri":"2.6 mln.","rat":0,"mw":"M","link":"Baker, Scott <\/a>","confirmed_b":1},{"id":"19528","tem":"152","ctr":"216","nam":"Edwards, Richie ","namorig":"Edwards, Richie ","cat":"","pri":"2.5 mln.","rat":0,"mw":"M","link":"Edwards, Richie <\/a>","confirmed_b":1},{"id":"6452","tem":"153","ctr":"216","nam":"Warren, Wayne ","namorig":"Warren, Wayne ","cat":"","pri":"2.5 mln.","rat":0,"mw":"M","link":"Warren, Wayne <\/a>","confirmed_b":1},{"id":"19272","tem":"153","ctr":"214","nam":"Day, Daniel ","namorig":"Day, Daniel ","cat":"","pri":"2.4 mln.","rat":0,"mw":"M","link":"Day, Daniel <\/a>","confirmed_b":1},{"id":"19267","tem":"153","ctr":"51","nam":"Thompson, Justin ","namorig":"Thompson, Justin ","cat":"","pri":"2.3 mln.","rat":0,"mw":"M","link":"Thompson, Justin <\/a>","confirmed_b":1},{"id":"16824","tem":"153","ctr":"61","nam":"Sparidaans, Jeffrey ","namorig":"Sparidaans, Jeffrey ","cat":"","pri":"2.2 mln.","rat":0,"mw":"M","link":"Sparidaans, Jeffrey <\/a>","confirmed_b":1},{"id":"19275","tem":"153","ctr":"61","nam":"Telnekes, Derk ","namorig":"Telnekes, Derk ","cat":"","pri":"2.1 mln.","rat":0,"mw":"M","link":"Telnekes, Derk <\/a>","confirmed_b":1},{"id":"5147","tem":"152","ctr":"214","nam":"Robson, Gary ","namorig":"Robson, Gary ","cat":"","pri":"2 mln.","rat":0,"mw":"M","link":"Robson, Gary <\/a>","confirmed_b":1},{"id":"19274","tem":"153","ctr":"61","nam":"Landman, Chris ","namorig":"Landman, Chris ","cat":"","pri":"1.9 mln.","rat":0,"mw":"M","link":"Landman, Chris <\/a>","confirmed_b":1},{"id":"19270","tem":"152","ctr":"17","nam":"Uyguns\u00f6zl\u00fc, \u00dcmit ","namorig":"Uyguns\u00f6zl\u00fc, \u00dcmit ","cat":"","pri":"1.8 mln.","rat":0,"mw":"M","link":"Uyguns\u00f6zl\u00fc, \u00dcmit <\/a>","confirmed_b":1},{"id":"19268","tem":"153","ctr":"217","nam":"Gilliland, Christopher ","namorig":"Gilliland, Christopher ","cat":"","pri":"1.7 mln.","rat":0,"mw":"M","link":"Gilliland, Christopher <\/a>","confirmed_b":1},{"id":"5048","tem":"153","ctr":"36","nam":"Cameron, David ","namorig":"Cameron, David ","cat":"","pri":"1.6 mln.","rat":0,"mw":"M","link":"Cameron, David <\/a>","confirmed_b":1},{"id":"19271","tem":"152","ctr":"216","nam":"Harris, Chris ","namorig":"Harris, Chris ","cat":"","pri":"1.5 mln.","rat":0,"mw":"M","link":"Harris, Chris <\/a>","confirmed_b":1},{"id":"17282","tem":"153","ctr":"88","nam":"Nilsson, Dennis ","namorig":"Nilsson, Dennis ","cat":"","pri":"1.4 mln.","rat":0,"mw":"M","link":"Nilsson, Dennis <\/a>","confirmed_b":1},{"id":"14927","tem":"153","ctr":"124","nam":"Caldwell, Craig ","namorig":"Caldwell, Craig ","cat":"","pri":"1.3 mln.","rat":0,"mw":"M","link":"Caldwell, Craig <\/a>","confirmed_b":1},{"id":"19269","tem":"153","ctr":"14","nam":"Unterbuchner, Michael ","namorig":"Unterbuchner, Michael ","cat":"","pri":"1.2 mln.","rat":0,"mw":"M","link":"Unterbuchner, Michael <\/a>","confirmed_b":1},{"id":"19273","tem":"152","ctr":"3","nam":"Chaney, Joe ","namorig":"Chaney, Joe ","cat":"","pri":"1.1 mln.","rat":0,"mw":"M","link":"Chaney, Joe <\/a>","confirmed_b":1},{"id":"19266","tem":"152","ctr":"173","nam":"Mohamed, Pengiran ","namorig":"Mohamed, Pengiran ","cat":"","pri":"1 mln.","rat":0,"mw":"M","link":"Mohamed, Pengiran <\/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': 'Darts 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 ""; }