$(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(' min.', ''); } ); }; $.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":"Holandia"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"Niemcy"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"Serbia"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"Korea Po\u0142udniowa"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"Chiny"},"58":{"id":"58","country":"Cameroon","countryCode":"CM","countryTr":"Kamerun"},"79":{"id":"79","country":"Tunisia","countryCode":"TN","countryTr":"Tunezja"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japonia"},"164":{"id":"164","country":"Montenegro","countryCode":"ME","countryTr":"Czarnog\u00f3ra"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"Brazil"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Rosja"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"Dania"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"Polska"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"Argentyna"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"W\u0119gry"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"Republika Czeska"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"Szwecja"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"Norwegia"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"Paragwaj"},"59":{"id":"59","country":"Angola","countryCode":"AO","countryTr":"Angola"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"S\u0142owenia"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"Hiszpania"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Rumunia"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Francja"},"84":{"id":"84","country":"Belarus","countryCode":"BY","countryTr":"Bia\u0142oru\u015b"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"Chorwacja"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"Austria"},"144":{"id":"144","country":"North Macedonia","countryCode":"MK","countryTr":"Macedonia P\u00f3\u0142nocna"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"Islandia"},"156":{"id":"156","country":"Qatar","countryCode":"QA","countryTr":"Katar"},"16":{"id":"16","country":"Egypt","countryCode":"EG","countryTr":"Egipt"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"Bahrain"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Chile"},"46":{"id":"46","country":"Saudi Arabia","countryCode":"SA","countryTr":"Arabia Saudyjska"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"Australia"},"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":"Kazachstan"},"21":{"id":"21","country":"Kongo (Kinshasa)","countryCode":"CD","countryTr":"Kongo"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"Ukraina"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"\u0141otwa"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugalia"},"127":{"id":"127","country":"Bosnia and Herzegovina","countryCode":"BA","countryTr":"Bosnia-Herzegovina"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"Switzerland"},"35":{"id":"35","country":"Algeria","countryCode":"DZ","countryTr":"Algieria"},"166":{"id":"166","country":"Cape Verde","countryCode":"CV","countryTr":"Zielony Przyl\u0105dek"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"Maroko"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"Urugwaj"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"Stany Zjednoczone"},"128":{"id":"128","country":"Kongo (Brazzaville)","countryCode":"CG","countryTr":"Kongo (Brazzaville)"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"S\u0142owacja"},"18":{"id":"18","country":"Iran","countryCode":"IR","countryTr":"Iran"},"126":{"id":"126","country":"Puerto Rico","countryCode":"PR","countryTr":"Puerto Rico"},"44":{"id":"44","country":"Uzbekistan","countryCode":"UZ","countryTr":"Uzbekistan"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"Litwa"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"Belgia"},"206":{"id":"206","country":"Greenland","countryCode":"GL","countryTr":"Grenlandia"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"Grecja"},"222":{"id":"222","country":"Faroe Islands","countryCode":"FO","countryTr":"Wyspy Faroe"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"Gruzja"}}; var teams = [{"id":0,"name":""}]; var sportsmen = []; var sportsmenTeams = [{"id":"19151","ctr":"19","nam":"Francja","namorig":"France","cat":"","pri":"15 min.","rat":0,"link":"Francja<\/a>","confirmed_b":1},{"id":"19139","ctr":"109","nam":"Dania","namorig":"Denmark","cat":"","pri":"12,6 min.","rat":0,"link":"Dania<\/a>","confirmed_b":1},{"id":"19399","ctr":"120","nam":"Chorwacja","namorig":"Croatia","cat":"","pri":"12,1 min.","rat":0,"link":"Chorwacja<\/a>","confirmed_b":1},{"id":"19149","ctr":"28","nam":"Hiszpania","namorig":"Spain","cat":"","pri":"8,8 min.","rat":0,"link":"Hiszpania<\/a>","confirmed_b":1},{"id":"19129","ctr":"14","nam":"Niemcy","namorig":"Germany","cat":"","pri":"8,7 min.","rat":0,"link":"Niemcy<\/a>","confirmed_b":1},{"id":"19145","ctr":"117","nam":"Norwegia","namorig":"Norway","cat":"","pri":"6,9 min.","rat":0,"link":"Norwegia<\/a>","confirmed_b":1},{"id":"19144","ctr":"88","nam":"Szwecja","namorig":"Sweden","cat":"","pri":"5,2 min.","rat":0,"link":"Szwecja<\/a>","confirmed_b":1},{"id":"19142","ctr":"80","nam":"W\u0119gry","namorig":"Hungary","cat":"","pri":"4,3 min.","rat":0,"link":"W\u0119gry<\/a>","confirmed_b":1},{"id":"19148","ctr":"145","nam":"S\u0142owenia","namorig":"Slovenia","cat":"","pri":"3,8 min.","rat":0,"link":"S\u0142owenia<\/a>","confirmed_b":1},{"id":"19130","ctr":"81","nam":"Serbia","namorig":"Serbia","cat":"","pri":"3,4 min.","rat":0,"link":"Serbia<\/a>","confirmed_b":1},{"id":"19401","ctr":"144","nam":"Macedonia P\u00f3\u0142nocna","namorig":"North Macedonia","cat":"","pri":"2,7 min.","rat":0,"link":"Macedonia P\u00f3\u0142nocna<\/a>","confirmed_b":1},{"id":"19400","ctr":"93","nam":"Austria","namorig":"Austria","cat":"","pri":"2,3 min.","rat":0,"link":"Austria<\/a>","confirmed_b":1},{"id":"19136","ctr":"164","nam":"Czarnog\u00f3ra","namorig":"Montenegro","cat":"","pri":"2 min.","rat":0,"link":"Czarnog\u00f3ra<\/a>","confirmed_b":1},{"id":"19402","ctr":"175","nam":"Islandia","namorig":"Iceland","cat":"","pri":"1,5 min.","rat":0,"link":"Islandia<\/a>","confirmed_b":1},{"id":"19398","ctr":"84","nam":"Bia\u0142oru\u015b","namorig":"Belarus","cat":"","pri":"1,4 min.","rat":0,"link":"Bia\u0142oru\u015b<\/a>","confirmed_b":1},{"id":"19143","ctr":"78","nam":"Republika Czeska","namorig":"Czech Republic","cat":"","pri":"1,2 min.","rat":0,"link":"Republika Czeska<\/a>","confirmed_b":1}]; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Nr' }, { 'sTitle': 'Grupa' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Kraj', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Kraj'}, { 'sTitle': 'Wartość', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Drużyna' }, { 'sTitle': 'M/K' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'Nr'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Kraj' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Wartość', '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(' min.', '').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 ""; }