$(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 = {"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"Nizozemsko"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"N\u011bmecko"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Srbsko"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"Ji\u017en\u00ed Korea"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"\u010c\u00edna"},"58":{"id":"58","country":"Cameroon","countryCode":"CM","countryTr":"Kamerun"},"79":{"id":"79","country":"Tunisia","countryCode":"TN","countryTr":"Tunisko"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japonsko"},"164":{"id":"164","country":"Montenegro","countryCode":"ME","countryTr":"\u010cern\u00e1 hora"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Braz\u00edlie"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Rusko"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"D\u00e1nsko"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polsko"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"Argentina"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"Ma\u010farsko"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"\u010cesk\u00e1 republika"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"\u0160v\u00e9dsko"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norsko"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"Paraguay"},"59":{"id":"59","country":"Angola","countryCode":"AO","countryTr":"Angola"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"Slovinsko"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"\u0160pan\u011blsko"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Rumunsko"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Francie"},"84":{"id":"84","country":"Belarus","countryCode":"BY","countryTr":"B\u011blorusko"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Chorvatsko"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Rakousko"},"144":{"id":"144","country":"North Macedonia","countryCode":"MK","countryTr":"Severn\u00ed Makedonie"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"Island"},"156":{"id":"156","country":"Qatar","countryCode":"QA","countryTr":"Katar"},"16":{"id":"16","country":"Egypt","countryCode":"EG","countryTr":"Egypt"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"Bahrajn"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Chile"},"46":{"id":"46","country":"Saudi Arabia","countryCode":"SA","countryTr":"Saudsk\u00e1 Ar\u00e1bie"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Austr\u00e1lie"},"73":{"id":"73","country":"Cuba","countryCode":"CU","countryTr":"Kuba"},"70":{"id":"70","country":"Senegal","countryCode":"SN","countryTr":"Senegal"},"62":{"id":"62","country":"Kazakhstan","countryCode":"KZ","countryTr":"Kazachst\u00e1n"},"21":{"id":"21","country":"Kongo (Kinshasa)","countryCode":"CD","countryTr":"Kongo (Kinshasa)"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Ukrajina"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"Loty\u0161sko"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugalsko"},"127":{"id":"127","country":"Bosnia and Herzegovina","countryCode":"BA","countryTr":"Bosna a Hercegovina"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"\u0160v\u00fdcarsko"},"35":{"id":"35","country":"Algeria","countryCode":"DZ","countryTr":"Al\u017e\u00edrsko"},"166":{"id":"166","country":"Cape Verde","countryCode":"CV","countryTr":"Kapverdy"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"Maroko"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"Uruguay"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"USA"},"128":{"id":"128","country":"Kongo (Brazzaville)","countryCode":"CG","countryTr":"Kongo (Brazzaville)"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"Slovensko"},"18":{"id":"18","country":"Iran","countryCode":"IR","countryTr":"\u00cdr\u00e1n"},"126":{"id":"126","country":"Puerto Rico","countryCode":"PR","countryTr":"Portoriko"},"44":{"id":"44","country":"Uzbekistan","countryCode":"UZ","countryTr":"Uzbekist\u00e1n"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Litva"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgie"},"206":{"id":"206","country":"Greenland","countryCode":"GL","countryTr":"Gr\u00f3nsko"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"\u0158ecko"},"222":{"id":"222","country":"Faroe Islands","countryCode":"FO","countryTr":"Faersk\u00e9 ostrovy"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"Gruzie"}}; var teams = [{"id":0,"name":""}]; var sportsmen = []; var sportsmenTeams = [{"id":"19151","ctr":"19","nam":"Francie","namorig":"France","cat":"","pri":"15 mil.","rat":0,"link":"Francie<\/a>","confirmed_b":1},{"id":"19139","ctr":"109","nam":"D\u00e1nsko","namorig":"Denmark","cat":"","pri":"12,6 mil.","rat":0,"link":"D\u00e1nsko<\/a>","confirmed_b":1},{"id":"19399","ctr":"120","nam":"Chorvatsko","namorig":"Croatia","cat":"","pri":"12,1 mil.","rat":0,"link":"Chorvatsko<\/a>","confirmed_b":1},{"id":"19149","ctr":"28","nam":"\u0160pan\u011blsko","namorig":"Spain","cat":"","pri":"8,8 mil.","rat":0,"link":"\u0160pan\u011blsko<\/a>","confirmed_b":1},{"id":"19129","ctr":"14","nam":"N\u011bmecko","namorig":"Germany","cat":"","pri":"8,7 mil.","rat":0,"link":"N\u011bmecko<\/a>","confirmed_b":1},{"id":"19145","ctr":"117","nam":"Norsko","namorig":"Norway","cat":"","pri":"6,9 mil.","rat":0,"link":"Norsko<\/a>","confirmed_b":1},{"id":"19144","ctr":"88","nam":"\u0160v\u00e9dsko","namorig":"Sweden","cat":"","pri":"5,2 mil.","rat":0,"link":"\u0160v\u00e9dsko<\/a>","confirmed_b":1},{"id":"19142","ctr":"80","nam":"Ma\u010farsko","namorig":"Hungary","cat":"","pri":"4,3 mil.","rat":0,"link":"Ma\u010farsko<\/a>","confirmed_b":1},{"id":"19148","ctr":"145","nam":"Slovinsko","namorig":"Slovenia","cat":"","pri":"3,8 mil.","rat":0,"link":"Slovinsko<\/a>","confirmed_b":1},{"id":"19130","ctr":"81","nam":"Srbsko","namorig":"Serbia","cat":"","pri":"3,4 mil.","rat":0,"link":"Srbsko<\/a>","confirmed_b":1},{"id":"19401","ctr":"144","nam":"Severn\u00ed Makedonie","namorig":"North Macedonia","cat":"","pri":"2,7 mil.","rat":0,"link":"Severn\u00ed Makedonie<\/a>","confirmed_b":1},{"id":"19400","ctr":"93","nam":"Rakousko","namorig":"Austria","cat":"","pri":"2,3 mil.","rat":0,"link":"Rakousko<\/a>","confirmed_b":1},{"id":"19136","ctr":"164","nam":"\u010cern\u00e1 hora","namorig":"Montenegro","cat":"","pri":"2 mil.","rat":0,"link":"\u010cern\u00e1 hora<\/a>","confirmed_b":1},{"id":"19402","ctr":"175","nam":"Island","namorig":"Iceland","cat":"","pri":"1,5 mil.","rat":0,"link":"Island<\/a>","confirmed_b":1},{"id":"19398","ctr":"84","nam":"B\u011blorusko","namorig":"Belarus","cat":"","pri":"1,4 mil.","rat":0,"link":"B\u011blorusko<\/a>","confirmed_b":1},{"id":"19143","ctr":"78","nam":"\u010cesk\u00e1 republika","namorig":"Czech Republic","cat":"","pri":"1,2 mil.","rat":0,"link":"\u010cesk\u00e1 republika<\/a>","confirmed_b":1}]; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Č.' }, { 'sTitle': 'Skupina' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Země', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Země'}, { 'sTitle': 'Hodnota', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Tým' }, { '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 ""; }