Loading…
`;
if(firstActiveTab.innerHTML==’लाइव’ || firstActiveTab.innerHTML==’LIVE’){
setTimeout(function() {
$(‘#live__fixtures .carousel__container’).html(loaderElement);
},100);
}else if (firstActiveTab.innerHTML==’आगामी’ || firstActiveTab.innerHTML==’UPCOMING’) {
setTimeout(function() {
$(‘#upcoming__fixtures .carousel__container’).html(loaderElement);
}, 100);
}
else{
setTimeout(function() {
$(‘#completed__fixtures .carousel__container’).html(loaderElement);
},100);
}
$.ajax({
url: ‘https://www.indiatoday.in/live-score/series_team_venue_filter’,
method: ‘POST’,
type: ‘POST’,
data: {
series_id: 15436,
teams: selectedTeams,
venues: selectedVenues,
activeTab:firstActiveTab.innerHTML
},
success: function(response) {
console.log(“AjaxCall”,response);
var resObject = JSON.parse(response);
var resMatchesArray = resObject;
var htmlData=”;
var noMatchFound=’No Match Found’;
if(Array.isArray(resMatchesArray) && resMatchesArray.length > 0)
{
resMatchesArray.forEach(function(match) {
let scoreCardText=”Full Scorecard”;
let baseURL=”https://www.indiatoday.in/live-score/”;
let matchdateISTTop=”+formatDate(match.matchdate_ist)+’
‘;
let scordCardLink=”+scoreCardText+”;
if(firstActiveTab.innerHTML==’आगामी’ || firstActiveTab.innerHTML==’UPCOMING’){
scordCardLink=match.venue;
}
/*
* The API pairs innings by fixed slot (teama=1&3, teamb=2&4), which breaks
* under follow-on (e.g. teamb bats both 2 & 3). Look up each team’s own
* latest innings directly by team id instead.
*/
const scoreTeamB = getLatestTeamInningsScore(match, match.teamb_id);
const scoreTeamA = getLatestTeamInningsScore(match, match.teama_id);
let inning1Score = ”;
if (scoreTeamB) {
const scoreArray = scoreTeamB.split(‘ ‘);
inning1Score = `
${scoreArray[1]} ${scoreArray[2]}
`;
}
else{
if((firstActiveTab.innerHTML!=’आगामी’) && (firstActiveTab.innerHTML!=’UPCOMING’)){
inning1Score = ‘
‘;
matchdateISTTop=”;
}
}
let inning2Score = ”;
if (scoreTeamA) {
const scoreArray = scoreTeamA.split(‘ ‘);
inning2Score = `
`;
}
else{
if(firstActiveTab.innerHTML!=’आगामी’ && firstActiveTab.innerHTML!=’UPCOMING’){
inning2Score = ‘
‘;
matchdateISTTop=”;
}
}
htmlData += `
${matchdateISTTop}
`;
});
}
else{
htmlData=`
`;
}
if(firstActiveTab.innerHTML==’लाइव’ || firstActiveTab.innerHTML==’LIVE’)
{
setTimeout(function() {
$(‘#live__fixtures .carousel__container’).html(htmlData);
},1000);
}
else if (firstActiveTab.innerHTML==’आगामी’ || firstActiveTab.innerHTML==’UPCOMING’) {
setTimeout(function() {
$(‘#upcoming__fixtures .carousel__container’).html(htmlData);
}, 1000);
}
else{
setTimeout(function() {
$(‘#completed__fixtures .carousel__container’).html(htmlData);
}, 1000);
}
},
error: function(xhr, status, error) {
setTimeout(function() {
$(‘#completed__fixtures .carousel__container’).html(‘
Server Error!!!
‘);
}, 2000);
console.error(error);
}
});
}
$(‘#checkbox-container’).on(‘change‘, ‘input[type=”checkbox”]’, function() {
var checkedCountTeam = $(‘input[name=”teams[]”]:checked’).length;
var checkedCountVenues = $(‘input[name=”venues[]”]:checked’).length;
if(checkedCountTeam){
$(‘#selectTeamCount’).html(”+checkedCountTeam+”);
}
else{
$(‘#selectTeamCount’).html(”);
}
if(checkedCountVenues)
{
$(‘#selectVenuesCount’).html(”+checkedCountVenues+”);
}
else{
$(‘#selectVenuesCount’).html(”);
}
makeAjaxCall();
});
});
});
