$(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 = {"51":{"id":"51","country":"Australia","countryCode":"AU","countryTr":"l\u2019Australie"},"214":{"id":"214","country":"England","countryCode":"EN","countryTr":"Angleterre"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Pays de Galles"},"158":{"id":"158","country":"Fiji","countryCode":"FJ","countryTr":"les Fidji"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"l\u2019Uruguay"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"l\u2019Afrique du Sud"},"183":{"id":"183","country":"Samoa","countryCode":"WS","countryTr":"la Samoa"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"le Japon"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"\u00c9cosse"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"les Etats-Unis"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"la Nouvelle Z\u00e9lande"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"l\u2019Argentine"},"193":{"id":"193","country":"Tonga","countryCode":"TO","countryTr":"les Tonga"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"la G\u00e9orgie"},"143":{"id":"143","country":"Namibia","countryCode":"NA","countryTr":"la Namibie"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"la France"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"l\u2019Irlande"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"l\u2019Italie"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"le Canada"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"la Roumanie"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"la Russie"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"le Portugal"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"la Chile"}};
var teams = [{"id":0,"name":""}];
var sportsmen = [];
var sportsmenTeams = [{"id":"12310","ctr":"124","nam":"la Nouvelle Z\u00e9lande","namorig":"New Zealand","cat":"","pri":"20 mln.","rat":0,"link":"la Nouvelle Z\u00e9lande<\/a>","confirmed_b":1},{"id":"12305","ctr":"26","nam":"l\u2019Afrique du Sud","namorig":"South Africa","cat":"","pri":"16,4 mln.","rat":0,"link":"l\u2019Afrique du Sud<\/a>","confirmed_b":1},{"id":"12301","ctr":"214","nam":"Angleterre","namorig":"England","cat":"","pri":"15,8 mln.","rat":0,"link":"Angleterre<\/a>","confirmed_b":1},{"id":"12302","ctr":"216","nam":"Pays de Galles","namorig":"Wales","cat":"","pri":"13,7 mln.","rat":0,"link":"Pays de Galles<\/a>","confirmed_b":1},{"id":"12300","ctr":"51","nam":"l\u2019Australie","namorig":"Australia","cat":"","pri":"12,9 mln.","rat":0,"link":"l\u2019Australie<\/a>","confirmed_b":1},{"id":"12316","ctr":"118","nam":"l\u2019Irlande","namorig":"Ireland","cat":"","pri":"11,6 mln.","rat":0,"link":"l\u2019Irlande<\/a>","confirmed_b":1},{"id":"12308","ctr":"215","nam":"\u00c9cosse","namorig":"Scotland","cat":"","pri":"10 mln.","rat":0,"link":"\u00c9cosse<\/a>","confirmed_b":1},{"id":"12315","ctr":"19","nam":"la France","namorig":"France","cat":"","pri":"9,9 mln.","rat":0,"link":"la France<\/a>","confirmed_b":1},{"id":"12311","ctr":"31","nam":"l\u2019Argentine","namorig":"Argentina","cat":"","pri":"7,5 mln.","rat":0,"link":"l\u2019Argentine<\/a>","confirmed_b":1},{"id":"12303","ctr":"158","nam":"les Fidji","namorig":"Fiji","cat":"","pri":"5,3 mln.","rat":0,"link":"les Fidji<\/a>","confirmed_b":1},{"id":"12307","ctr":"10","nam":"le Japon","namorig":"Japan","cat":"","pri":"5 mln.","rat":0,"link":"le Japon<\/a>","confirmed_b":1},{"id":"12317","ctr":"23","nam":"l\u2019Italie","namorig":"Italy","cat":"","pri":"4,8 mln.","rat":0,"link":"l\u2019Italie<\/a>","confirmed_b":1},{"id":"12318","ctr":"36","nam":"le Canada","namorig":"Canada","cat":"","pri":"3,2 mln.","rat":0,"link":"le Canada<\/a>","confirmed_b":1},{"id":"12309","ctr":"3","nam":"les Etats-Unis","namorig":"United States","cat":"","pri":"3,1 mln.","rat":0,"link":"les Etats-Unis<\/a>","confirmed_b":1},{"id":"12306","ctr":"183","nam":"la Samoa","namorig":"Samoa","cat":"","pri":"3 mln.","rat":0,"link":"la Samoa<\/a>","confirmed_b":1},{"id":"12313","ctr":"121","nam":"la G\u00e9orgie","namorig":"Georgia","cat":"","pri":"2,7 mln.","rat":0,"link":"la G\u00e9orgie<\/a>","confirmed_b":1},{"id":"24219","ctr":"9","nam":"la Russie","namorig":"Russia","cat":"","pri":"2,6 mln.","rat":0,"link":"la Russie<\/a>","confirmed_b":1},{"id":"12304","ctr":"134","nam":"l\u2019Uruguay","namorig":"Uruguay","cat":"","pri":"2,6 mln.","rat":0,"link":"l\u2019Uruguay<\/a>","confirmed_b":1},{"id":"12314","ctr":"143","nam":"la Namibie","namorig":"Namibia","cat":"","pri":"2,4 mln.","rat":0,"link":"la Namibie<\/a>","confirmed_b":1},{"id":"12312","ctr":"193","nam":"les Tonga","namorig":"Tonga","cat":"","pri":"2 mln.","rat":0,"link":"les Tonga<\/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': 'Rugby team'},
{ 'sTitle': 'Valeur', 'sSortDataType': 'sortMln', 'sType': 'numeric' },
{ 'sTitle': 'Équipe' },
{ 'sTitle': 'H/F' , 'bSearchable': false, 'bVisible': false }
];
//***********************
//TEAMS TABLE HEADERS
//***********************
var headersTableTeams = [
{'sTitle': 'N°'},
{'sTitle': '' , '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,
'', 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 "";
return ''; if (typeof margin == 'undefined') margin = true;
return "";
}