window.initMatchDetails = function() { $(".match_details").unbind(); $(".match_details").click(function(event) { event.preventDefault(); var id = $(this).data("match_id"); if( $("#match_progress_" + id).length > 0 ) { $("#match_progress_" + id).slideUp("slow").remove(); $("#match_details_switch_" + id).addClass("fe-icon-chevron-down"); $("#match_details_switch_" + id).removeClass("fe-icon-chevron-up"); } else { $.post("https://www.epbf.com/extern/matchProgress.php", { matchProgress: true, match_id: id, layout: '', link_to_match: 'european-championships/id/1240' }, function( data ) { if(data == "error") { console.log("Getting match progress failed."); } else { $("#match_details_switch_" + id).removeClass("fe-icon-chevron-down"); $("#match_details_switch_" + id).addClass("fe-icon-chevron-up"); $(".row_" + id).after(data); $("#match_progress_" + id + " .date_tooltip").tooltip('update'); $("#match_progress_" + id).slideDown("slow"); } }); } }); } result = initMatchDetails();