$(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 = {"61":{"id":"61","country":"Netherlands","countryCode":"NL","countryTr":"les Pays-Bas"},"14":{"id":"14","country":"Germany","countryCode":"DE","countryTr":"l\u2019Allemagne"},"81":{"id":"81","country":"Serbia","countryCode":"RS","countryTr":"la Servie"},"25":{"id":"25","country":"South Korea","countryCode":"KR","countryTr":"la Cor\u00e9e du Sud"},"1":{"id":"1","country":"China","countryCode":"CN","countryTr":"la Chine"},"58":{"id":"58","country":"Cameroon","countryCode":"CM","countryTr":"le Cameroun"},"79":{"id":"79","country":"Tunisia","countryCode":"TN","countryTr":"la Tunisie"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"le Japon"},"164":{"id":"164","country":"Montenegro","countryCode":"ME","countryTr":"le Mont\u00e9n\u00e9gro"},"5":{"id":"5","country":"Brasil","countryCode":"BR","countryTr":"le Br\u00e9sil"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"la Russie"},"109":{"id":"109","country":"Denmark","countryCode":"DK","countryTr":"le Danemark"},"33":{"id":"33","country":"Poland","countryCode":"PL","countryTr":"la Pologne"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"l\u2019Argentine"},"80":{"id":"80","country":"Hungary","countryCode":"HU","countryTr":"l\u2019Hongrie"},"78":{"id":"78","country":"Czech Republic","countryCode":"CZ","countryTr":"la R\u00e9publique Tch\u00e8que"},"88":{"id":"88","country":"Sweden","countryCode":"SE","countryTr":"la Su\u00e8de"},"117":{"id":"117","country":"Norway","countryCode":"NO","countryTr":"la Norv\u00e8ge"},"104":{"id":"104","country":"Paraguay","countryCode":"PY","countryTr":"le Paraguay"},"59":{"id":"59","country":"Angola","countryCode":"AO","countryTr":"l\u2019Angola"},"145":{"id":"145","country":"Slovenia","countryCode":"SI","countryTr":"la Slov\u00e9nie"},"28":{"id":"28","country":"Spain","countryCode":"ES","countryTr":"l\u2019Espagne"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"la Roumanie"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"la France"},"84":{"id":"84","country":"Belarus","countryCode":"BY","countryTr":"Belarus"},"120":{"id":"120","country":"Croatia","countryCode":"HR","countryTr":"la Croatie"},"93":{"id":"93","country":"Austria","countryCode":"AT","countryTr":"l\u2019Autriche"},"144":{"id":"144","country":"North Macedonia","countryCode":"MK","countryTr":"Mac\u00e9doine du Nord"},"175":{"id":"175","country":"Iceland","countryCode":"IS","countryTr":"l\u2019Islande"},"156":{"id":"156","country":"Qatar","countryCode":"QA","countryTr":"le Qatar"},"16":{"id":"16","country":"Egypt","countryCode":"EG","countryTr":"l\u2019Egypte"},"160":{"id":"160","country":"Bahrain","countryCode":"BH","countryTr":"le Bahre\u00efn"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"la Chile"},"46":{"id":"46","country":"Saudi Arabia","countryCode":"SA","countryTr":"l\u2019Arabie du Sud"},"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"l\u2019Australie"},"73":{"id":"73","country":"Cuba","countryCode":"CU","countryTr":"le Cuba"},"70":{"id":"70","country":"Senegal","countryCode":"SN","countryTr":"le S\u00e9n\u00e9gal"},"62":{"id":"62","country":"Kazakhstan","countryCode":"KZ","countryTr":"le Kazakhstan"},"21":{"id":"21","country":"Kongo (Kinshasa)","countryCode":"CD","countryTr":"le Congo (Kinshasa)"},"27":{"id":"27","country":"Ukraine","countryCode":"UA","countryTr":"l\u2019Ukraine"},"142":{"id":"142","country":"Latvia","countryCode":"LV","countryTr":"la Lettonie"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"le Portugal"},"127":{"id":"127","country":"Bosnia and Herzegovina","countryCode":"BA","countryTr":"la Bosnie et Herzegovina"},"94":{"id":"94","country":"Swiss","countryCode":"CH","countryTr":"la Suisse"},"35":{"id":"35","country":"Algeria","countryCode":"DZ","countryTr":"l\u2019Alg\u00e9rie"},"166":{"id":"166","country":"Cape Verde","countryCode":"CV","countryTr":"les \u00eeles du Cap-Vert"},"37":{"id":"37","country":"Morocco","countryCode":"MA","countryTr":"le Maroc"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"l\u2019Uruguay"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"les Etats-Unis"},"128":{"id":"128","country":"Kongo (Brazzaville)","countryCode":"CG","countryTr":"le Congo (Brazzaville)"},"110":{"id":"110","country":"Slovakia","countryCode":"SK","countryTr":"la Slovaquie"},"18":{"id":"18","country":"Iran","countryCode":"IR","countryTr":"l\u2019Iran"},"126":{"id":"126","country":"Puerto Rico","countryCode":"PR","countryTr":"Porto Rico"},"44":{"id":"44","country":"Uzbekistan","countryCode":"UZ","countryTr":"l\u2019Oezb\u00e9kistan"},"132":{"id":"132","country":"Lithuania","countryCode":"LT","countryTr":"la Lituanie"},"76":{"id":"76","country":"Belgium","countryCode":"BE","countryTr":"la Belgique"},"206":{"id":"206","country":"Greenland","countryCode":"GL","countryTr":"le Groenland"},"74":{"id":"74","country":"Greece","countryCode":"GR","countryTr":"la Gr\u00e8ce"},"222":{"id":"222","country":"Faroe Islands","countryCode":"FO","countryTr":"Iles F\u00e9ro\u00e9"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"la G\u00e9orgie"}}; var teams = [{"id":0,"name":""}]; var sportsmen = []; var sportsmenTeams = [{"id":"19138","ctr":"9","nam":"la Russie","namorig":"Russia","cat":"","pri":"20 mln.","rat":0,"link":"la Russie<\/a>","confirmed_b":1},{"id":"19145","ctr":"117","nam":"la Norv\u00e8ge","namorig":"Norway","cat":"","pri":"18,5 mln.","rat":0,"link":"la Norv\u00e8ge<\/a>","confirmed_b":1},{"id":"19151","ctr":"19","nam":"la France","namorig":"France","cat":"","pri":"17,6 mln.","rat":0,"link":"la France<\/a>","confirmed_b":1},{"id":"19128","ctr":"61","nam":"les Pays-Bas","namorig":"Netherlands","cat":"","pri":"13,8 mln.","rat":0,"link":"les Pays-Bas<\/a>","confirmed_b":1},{"id":"19150","ctr":"52","nam":"la Roumanie","namorig":"Romania","cat":"","pri":"12,5 mln.","rat":0,"link":"la Roumanie<\/a>","confirmed_b":1},{"id":"19144","ctr":"88","nam":"la Su\u00e8de","namorig":"Sweden","cat":"","pri":"10,6 mln.","rat":0,"link":"la Su\u00e8de<\/a>","confirmed_b":1},{"id":"19142","ctr":"80","nam":"l\u2019Hongrie","namorig":"Hungary","cat":"","pri":"9,3 mln.","rat":0,"link":"l\u2019Hongrie<\/a>","confirmed_b":1},{"id":"19136","ctr":"164","nam":"le Mont\u00e9n\u00e9gro","namorig":"Montenegro","cat":"","pri":"9,1 mln.","rat":0,"link":"le Mont\u00e9n\u00e9gro<\/a>","confirmed_b":1},{"id":"19139","ctr":"109","nam":"le Danemark","namorig":"Denmark","cat":"","pri":"9 mln.","rat":0,"link":"le Danemark<\/a>","confirmed_b":1},{"id":"19130","ctr":"81","nam":"la Servie","namorig":"Serbia","cat":"","pri":"8,2 mln.","rat":0,"link":"la Servie<\/a>","confirmed_b":1},{"id":"19135","ctr":"10","nam":"le Japon","namorig":"Japan","cat":"","pri":"7,5 mln.","rat":0,"link":"le Japon<\/a>","confirmed_b":1},{"id":"19149","ctr":"28","nam":"l\u2019Espagne","namorig":"Spain","cat":"","pri":"6,9 mln.","rat":0,"link":"l\u2019Espagne<\/a>","confirmed_b":1},{"id":"19131","ctr":"25","nam":"la Cor\u00e9e du Sud","namorig":"South Korea","cat":"","pri":"6,4 mln.","rat":0,"link":"la Cor\u00e9e du Sud<\/a>","confirmed_b":1},{"id":"19129","ctr":"14","nam":"l\u2019Allemagne","namorig":"Germany","cat":"","pri":"5,7 mln.","rat":0,"link":"l\u2019Allemagne<\/a>","confirmed_b":1},{"id":"19137","ctr":"5","nam":"le Br\u00e9sil","namorig":"Brasil","cat":"","pri":"5,3 mln.","rat":0,"link":"le Br\u00e9sil<\/a>","confirmed_b":1},{"id":"19148","ctr":"145","nam":"la Slov\u00e9nie","namorig":"Slovenia","cat":"","pri":"5 mln.","rat":0,"link":"la Slov\u00e9nie<\/a>","confirmed_b":1},{"id":"19141","ctr":"31","nam":"l\u2019Argentine","namorig":"Argentina","cat":"","pri":"4,5 mln.","rat":0,"link":"l\u2019Argentine<\/a>","confirmed_b":1},{"id":"19147","ctr":"59","nam":"l\u2019Angola","namorig":"Angola","cat":"","pri":"3,1 mln.","rat":0,"link":"l\u2019Angola<\/a>","confirmed_b":1},{"id":"25306","ctr":"21","nam":"DR Congo","namorig":"DR Congo","cat":"","pri":"2,9 mln.","rat":0,"link":"DR Congo<\/a>","confirmed_b":1},{"id":"19132","ctr":"1","nam":"la Chine","namorig":"China","cat":"","pri":"2,9 mln.","rat":0,"link":"la Chine<\/a>","confirmed_b":1},{"id":"25304","ctr":"70","nam":"le S\u00e9n\u00e9gal","namorig":"Senegal","cat":"","pri":"2,4 mln.","rat":0,"link":"le S\u00e9n\u00e9gal<\/a>","confirmed_b":1},{"id":"25305","ctr":"62","nam":"le Kazakhstan","namorig":"Kazakhstan","cat":"","pri":"2,2 mln.","rat":0,"link":"le Kazakhstan<\/a>","confirmed_b":1},{"id":"25303","ctr":"73","nam":"le Cuba","namorig":"Cuba","cat":"","pri":"1,8 mln.","rat":0,"link":"le Cuba<\/a>","confirmed_b":1},{"id":"25302","ctr":"51","nam":"l\u2019Australie","namorig":"Australia","cat":"","pri":"1,5 mln.","rat":0,"link":"l\u2019Australie<\/a>","confirmed_b":1}]; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'N°' }, { 'sTitle': 'Groupe' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Pays', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Pays'}, { 'sTitle': 'Valeur', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Équipe' }, { 'sTitle': 'H/F' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'N°'}, {'sTitle': '' , 'bSearchable': false, 'bVisible': false }, {'sTitle': 'Pays' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Valeur', '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 ""; }