$(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(' mil.', '');
} );
};
$.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":"Anglie"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"Skotsko"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Austr\u00e1lie"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Wales"},"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Nizozemsko"},"217":{"id":"217","country":"Northern Ireland","countryCode":"NIE","countryTr":"Severn\u00ed Irsko"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"Kanada"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Rakousko"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"N\u011bmecko"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"\u0160pan\u011blsko"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Irsko"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"USA"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgie"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"\u0160v\u00e9dsko"},"218":{"id":"218","country":"Gibraltar","countryCode":"GI","countryTr":"Gibraltar"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"\u0158ecko"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polsko"},"2":{"id":"2","country":"India","countryCode":"IN","countryTr":"Indie"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"Jihoafrick\u00e1 republika"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"D\u00e1nsko"},"112":{"id":"112","country":"Finland","countryCode":"FI","countryTr":"Finsko"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Ma\u010farsko"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Chorvatsko"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"\u0160v\u00fdcarsko"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norsko"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"It\u00e1lie"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"Slovinsko"},"116":{"id":"116","country":"Singapore","countryCode":"SG","countryTr":"Singapur"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"\u010c\u00edna"},"98":{"id":"98","country":"Hong Kong","countryCode":"HK","countryTr":"Hongkong"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japonsko"},"12":{"id":"12","country":"Philippines","countryCode":"PH","countryTr":"Filip\u00edny"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"Nov\u00fd Z\u00e9land"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"\u010cesk\u00e1 republika"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Loty\u0161sko"},"43":{"id":"43","country":"Malaysia","countryCode":"MY","countryTr":"Malajsie"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Francie"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Rusko"},"20":{"id":"20","country":"Thailand","countryCode":"TH","countryTr":"Thajsko"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Litva"},"17":{"id":"17","country":"Turkey","countryCode":"TR","countryTr":"Turecko"},"173":{"id":"173","country":"Brunei","countryCode":"BN","countryTr":"Brunej"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Braz\u00edlie"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugalsko"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Srbsko"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Rumunsko"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"Island"},"22":{"id":"22","country":"United Kingdom","countryCode":"GB","countryTr":"Velk\u00e1 Brit\u00e1nie"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Ukrajina"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"Bahrajn"},"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 mil.","rat":0,"mw":"M","link":"Gerwen, Michael van<\/a>","confirmed_b":1},{"id":"4898","tem":"153","ctr":"215","nam":"Anderson, Gary ","namorig":"Anderson, Gary ","cat":"","pri":"7,9 mil.","rat":0,"mw":"M","link":"Anderson, Gary <\/a>","confirmed_b":1},{"id":"4925","tem":"153","ctr":"215","nam":"Wright, Peter ","namorig":"Wright, Peter ","cat":"","pri":"7,5 mil.","rat":0,"mw":"M","link":"Wright, Peter <\/a>","confirmed_b":1},{"id":"4895","tem":"153","ctr":"214","nam":"Taylor, Phil ","namorig":"Taylor, Phil ","cat":"","pri":"6,8 mil.","rat":0,"mw":"M","link":"Taylor, Phil <\/a>","confirmed_b":1},{"id":"4902","tem":"153","ctr":"61","nam":"Barneveld, Raymond van","namorig":"Barneveld, Raymond van","cat":"","pri":"6,2 mil.","rat":0,"mw":"M","link":"Barneveld, Raymond van<\/a>","confirmed_b":1},{"id":"4933","tem":"153","ctr":"214","nam":"Chisnall, Dave ","namorig":"Chisnall, Dave ","cat":"","pri":"5,3 mil.","rat":0,"mw":"M","link":"Chisnall, Dave <\/a>","confirmed_b":1},{"id":"4896","tem":"153","ctr":"214","nam":"Lewis, Adrian ","namorig":"Lewis, Adrian ","cat":"","pri":"5,1 mil.","rat":0,"mw":"M","link":"Lewis, Adrian <\/a>","confirmed_b":1},{"id":"4897","tem":"153","ctr":"214","nam":"Wade, James ","namorig":"Wade, James ","cat":"","pri":"4,8 mil.","rat":0,"mw":"M","link":"Wade, James <\/a>","confirmed_b":1},{"id":"4927","tem":"153","ctr":"61","nam":"Klaasen, Jelle ","namorig":"Klaasen, Jelle ","cat":"","pri":"4,2 mil.","rat":0,"mw":"M","link":"Klaasen, Jelle <\/a>","confirmed_b":1},{"id":"4964","tem":"153","ctr":"76","nam":"Huybrechts, Kim ","namorig":"Huybrechts, Kim ","cat":"","pri":"3,9 mil.","rat":0,"mw":"M","link":"Huybrechts, Kim <\/a>","confirmed_b":1}];
var sportsmenTeams = [];
var showTeams = 0;
//***********************
//SPORTSMEN TABLE HEADERS
//***********************
var headersTableSportsmen = [
{ 'sTitle': 'Č.' },
{ 'sTitle': 'Skupina' , 'bSearchable': false, 'bVisible': false },
{ 'sTitle': 'Země', 'sSortDataType': 'sortCountryFlag', sType : "text" },
{ 'sTitle': 'Hráč šipek'},
{ 'sTitle': 'Hodnota', 'sSortDataType': 'sortMln', 'sType': 'numeric' },
{ 'sTitle': 'Tým' , 'bSearchable': false, 'bVisible': false },
{ 'sTitle': 'M/Ž' , 'bSearchable': false, 'bVisible': false }
];
//***********************
//TEAMS TABLE HEADERS
//***********************
var headersTableTeams = [
{'sTitle': 'Č.'},
{'sTitle': '' , 'bSearchable': false, 'bVisible': false },
{'sTitle': 'Země' , 'sSortDataType': 'sortCountryFlag', sType : 'text' },
{ 'sTitle': ''},
{ 'sTitle': 'Hodnota', '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(' mil.', '').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 "";
}