$(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":"Australi\u00eb"},"214":{"id":"214","country":"England","countryCode":"EN","countryTr":"Engeland"},"216":{"id":"216","country":"Wales","countryCode":"WL","countryTr":"Wales"},"158":{"id":"158","country":"Fiji","countryCode":"FJ","countryTr":"Fiji"},"134":{"id":"134","country":"Uruguay","countryCode":"UY","countryTr":"Uruguay"},"26":{"id":"26","country":"South Africa","countryCode":"ZA","countryTr":"Zuid-Afrika"},"183":{"id":"183","country":"Samoa","countryCode":"WS","countryTr":"Samoa"},"10":{"id":"10","country":"Japan","countryCode":"JP","countryTr":"Japan"},"215":{"id":"215","country":"Scotland","countryCode":"SF","countryTr":"Schotland"},"3":{"id":"3","country":"United States","countryCode":"US","countryTr":"Verenigde Staten"},"124":{"id":"124","country":"New Zealand","countryCode":"NZ","countryTr":"Nieuw-Zeeland"},"31":{"id":"31","country":"Argentina","countryCode":"AR","countryTr":"Argentini\u00eb"},"193":{"id":"193","country":"Tonga","countryCode":"TO","countryTr":"Tonga"},"121":{"id":"121","country":"Georgia","countryCode":"GE","countryTr":"Georgi\u00eb"},"143":{"id":"143","country":"Namibia","countryCode":"NA","countryTr":"Namibi\u00eb"},"19":{"id":"19","country":"France","countryCode":"FR","countryTr":"Frankrijk"},"118":{"id":"118","country":"Ireland","countryCode":"IE","countryTr":"Ierland"},"23":{"id":"23","country":"Italy","countryCode":"IT","countryTr":"Itali\u00eb"},"36":{"id":"36","country":"Canada","countryCode":"CA","countryTr":"Canada"},"52":{"id":"52","country":"Romania","countryCode":"RO","countryTr":"Roemeni\u00eb"},"9":{"id":"9","country":"Russia","countryCode":"RU","countryTr":"Rusland"},"77":{"id":"77","country":"Portugal","countryCode":"PT","countryTr":"Portugal"},"60":{"id":"60","country":"Chile","countryCode":"CL","countryTr":"Chili"}}; var teams = [{"id":0,"name":""}]; var sportsmen = []; var sportsmenTeams = [{"id":"12310","ctr":"124","nam":"Nieuw-Zeeland","namorig":"New Zealand","cat":"","pri":"20 mln.","rat":0,"link":"Nieuw-Zeeland<\/a>","confirmed_b":1},{"id":"12305","ctr":"26","nam":"Zuid-Afrika","namorig":"South Africa","cat":"","pri":"16,4 mln.","rat":0,"link":"Zuid-Afrika<\/a>","confirmed_b":1},{"id":"12301","ctr":"214","nam":"Engeland","namorig":"England","cat":"","pri":"15,8 mln.","rat":0,"link":"Engeland<\/a>","confirmed_b":1},{"id":"12302","ctr":"216","nam":"Wales","namorig":"Wales","cat":"","pri":"13,7 mln.","rat":0,"link":"Wales<\/a>","confirmed_b":1},{"id":"12300","ctr":"51","nam":"Australi\u00eb","namorig":"Australia","cat":"","pri":"12,9 mln.","rat":0,"link":"Australi\u00eb<\/a>","confirmed_b":1},{"id":"12316","ctr":"118","nam":"Ierland","namorig":"Ireland","cat":"","pri":"11,6 mln.","rat":0,"link":"Ierland<\/a>","confirmed_b":1},{"id":"12308","ctr":"215","nam":"Schotland","namorig":"Scotland","cat":"","pri":"10 mln.","rat":0,"link":"Schotland<\/a>","confirmed_b":1},{"id":"12315","ctr":"19","nam":"Frankrijk","namorig":"France","cat":"","pri":"9,9 mln.","rat":0,"link":"Frankrijk<\/a>","confirmed_b":1},{"id":"12311","ctr":"31","nam":"Argentini\u00eb","namorig":"Argentina","cat":"","pri":"7,5 mln.","rat":0,"link":"Argentini\u00eb<\/a>","confirmed_b":1},{"id":"12303","ctr":"158","nam":"Fiji","namorig":"Fiji","cat":"","pri":"5,3 mln.","rat":0,"link":"Fiji<\/a>","confirmed_b":1},{"id":"12307","ctr":"10","nam":"Japan","namorig":"Japan","cat":"","pri":"5 mln.","rat":0,"link":"Japan<\/a>","confirmed_b":1},{"id":"12317","ctr":"23","nam":"Itali\u00eb","namorig":"Italy","cat":"","pri":"4,8 mln.","rat":0,"link":"Itali\u00eb<\/a>","confirmed_b":1},{"id":"12318","ctr":"36","nam":"Canada","namorig":"Canada","cat":"","pri":"3,2 mln.","rat":0,"link":"Canada<\/a>","confirmed_b":1},{"id":"12309","ctr":"3","nam":"Verenigde Staten","namorig":"United States","cat":"","pri":"3,1 mln.","rat":0,"link":"Verenigde Staten<\/a>","confirmed_b":1},{"id":"12306","ctr":"183","nam":"Samoa","namorig":"Samoa","cat":"","pri":"3 mln.","rat":0,"link":"Samoa<\/a>","confirmed_b":1},{"id":"12313","ctr":"121","nam":"Georgi\u00eb","namorig":"Georgia","cat":"","pri":"2,7 mln.","rat":0,"link":"Georgi\u00eb<\/a>","confirmed_b":1},{"id":"24219","ctr":"9","nam":"Rusland","namorig":"Russia","cat":"","pri":"2,6 mln.","rat":0,"link":"Rusland<\/a>","confirmed_b":1},{"id":"12304","ctr":"134","nam":"Uruguay","namorig":"Uruguay","cat":"","pri":"2,6 mln.","rat":0,"link":"Uruguay<\/a>","confirmed_b":1},{"id":"12314","ctr":"143","nam":"Namibi\u00eb","namorig":"Namibia","cat":"","pri":"2,4 mln.","rat":0,"link":"Namibi\u00eb<\/a>","confirmed_b":1},{"id":"12312","ctr":"193","nam":"Tonga","namorig":"Tonga","cat":"","pri":"2 mln.","rat":0,"link":"Tonga<\/a>","confirmed_b":1}]; var showTeams = 0; //*********************** //SPORTSMEN TABLE HEADERS //*********************** var headersTableSportsmen = [ { 'sTitle': 'Nr.' }, { 'sTitle': 'Groep' , 'bSearchable': false, 'bVisible': false }, { 'sTitle': 'Land', 'sSortDataType': 'sortCountryFlag', sType : "text" }, { 'sTitle': 'Rugby team'}, { 'sTitle': 'Waarde', 'sSortDataType': 'sortMln', 'sType': 'numeric' }, { 'sTitle': 'Team' }, { 'sTitle': 'M/V' , 'bSearchable': false, 'bVisible': false } ]; //*********************** //TEAMS TABLE HEADERS //*********************** var headersTableTeams = [ {'sTitle': 'Nr.'}, {'sTitle': '' , 'sSortDataType': 'sortCountryFlag', sType : 'text' }, { 'sTitle': ''}, { 'sTitle': 'Waarde', '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 ""; }