var excludeMobileRedirect = ["/fifaworldcup/organisation/ticketing/", "/worldcup/organisation/ticketing/"];;(function () {
'use strict';
var module = angular.module('matchDataManage', []);
var matchDataManage = (function () {
var _hasLineup = function (match) {
if (!match) { return false; }
return (match.hasLineup && !match.isLive && !match.isFinished && !match.isAbandoned);
};
return {
isLive: function (match) {
if (!match) { return false; }
return match.isLive || _hasLineup(match);
},
hasLineup: function (match) {
return _hasLineup(match);
},
/* Format Minute + Extension Time + Phase Label */
matchMinuteFormat: function (match, liveMatchData, $scope) {
if (!liveMatchData) {
liveMatchData = match;
}
switch (liveMatchData.phaseCode) {
case '1': /*FirstHalf*/
if (liveMatchData.minute > 45 || liveMatchData.minuteExtra > 0) {
match.minuteFormatted = 45;
match.showext = true;
} else {
match.minuteFormatted = liveMatchData.minute;
match.showext = false;
}
break;
case 'H': case '2': /*HalfTime*/
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.halfTimeLabelAbbr;
}
else {
match.minuteFormatted = $scope.halfTimeLabel;
}
match.showext = false;
break;
case '4': /*SecondHalf*/
if (liveMatchData.minute > 90 || liveMatchData.minuteExtra > 0) {
match.minuteFormatted = 90;
match.showext = true;
} else {
match.minuteFormatted = liveMatchData.minute;
match.showext = false;
}
break;
case '5': /*End SecondHalf*/
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.endSecondHalfLabelAbbr;
}
else {
match.minuteFormatted = $scope.endSecondHalfLabel;
}
match.showext = false;
break;
case '6': /*Fist Extra*/
if (liveMatchData.minute > 105 || liveMatchData.minuteExtra > 0) {
match.minuteFormatted = 105;
match.showext = true;
} else {
match.minuteFormatted = liveMatchData.minute;
match.showext = false;
}
break;
case '7': /*End Fist Extra*/
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.endFirstExtraLabelAbbr;
}
else {
match.minuteFormatted = $scope.endFirstExtraLabel;
}
match.showext = false;
break;
case '8': /*Second Extra*/
if (liveMatchData.minute > 120 || liveMatchData.minuteExtra > 0) {
match.minuteFormatted = 120;
match.showext = true;
} else {
match.minuteFormatted = liveMatchData.minute;
match.showext = false;
}
break;
case '9': /*End Second Extra*/
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.endSecondExtraLabelAbbr;
} else {
match.minuteFormatted = $scope.endSecondExtraLabel;
}
match.showext = false;
break;
case 'A': /* PSO*/
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.penaltyLabelAbbr;
} else {
match.minuteFormatted = $scope.penaltyLabel;
}
match.showext = false;
break;
}
},
/* Manage Reason Win Text Translate and Replace placeholder */
matchReasonWinSet: function (match, liveMatchData, $scope) {
if (!liveMatchData) {
liveMatchData = match;
}
var tag = 'fifa.winningReason_' + liveMatchData.reasonWinCode;
var text = '';
var textAbbr = '';
textAbbr = fifa.vocManager.translateAbbr(tag);
text = fifa.vocManager.translate(tag);
textAbbr = textAbbr.replace('{ScorePenH}', liveMatchData.scorePenaltyHome);
textAbbr = textAbbr.replace('{ScorePenA}', liveMatchData.scorePenaltyAway);
textAbbr = textAbbr.replace('{ScoreAggH}', liveMatchData.scoreAggregateHome);
textAbbr = textAbbr.replace('{ScoreAggA}', liveMatchData.scoreAggregateAway);
textAbbr = textAbbr.replace('{WinTeamName}', liveMatchData.winTeamName);
textAbbr = textAbbr.replace('{WinTeamCountry}', liveMatchData.winTeamShortName);
text = text.replace('{ScorePenH}', liveMatchData.scorePenaltyHome);
text = text.replace('{ScorePenA}', liveMatchData.scorePenaltyAway);
text = text.replace('{ScoreAggH}', liveMatchData.scoreAggregateHome);
text = text.replace('{ScoreAggA}', liveMatchData.scoreAggregateAway);
text = text.replace('{WinTeamName}', liveMatchData.winTeamName);
text = text.replace('{WinTeamCountry}', liveMatchData.winTeamShortName);
match.winReasonTextAbbr = textAbbr;
match.winReasonText = text;
},
matchDataCreate: function (match, $scope) {
this.dateManage(match);
if (match.isLive) {
match.status = 3;
this.matchMinuteFormat(match, null, $scope);
}
if (match.isFinished) {
match.status = 0;
match.showext = false;
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.fullTimeLabelAbbr;
} else {
match.minuteFormatted = $scope.fullTimeLabel;
}
if (match.reasonWinCode != null) {
this.matchReasonWinSet(match, null, $scope);
}
}
if (!match.isFinished && !match.isLive && match.hasLineup) {
match.status = 1;
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.lineupLabelAbbr;
} else {
match.minuteFormatted = $scope.lineupLabel;
}
}
if (match.isFinished && match.winnerTeamId != null) {
if (match.winnerTeamId == match.idHomeTeam) {
match.winTeamName = match.homeTeamName;
match.winTeamShortName = match.homeTeamName;
}
if (match.winnerTeamId == match.idAwayTeam) {
match.winTeamName = match.AwayTeamName;
match.winTeamShortName = match.AwayTeamName;
}
}
if (match.isAbandoned) {
match.status = 1;
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.abandonedLabelAbbr;
} else {
match.minuteFormatted = $scope.abandonedLabel;
}
}
if (match.isAwarded) {
match.status = 1;
if ($scope.locals && $scope.locals.isMobile) {
match.minuteFormatted = $scope.forfeitedLabelAbbr;
} else {
match.minuteFormatted = $scope.forfeitedLabel;
}
}
},
dateManage: function (match) {
var date = new Date(Date.parse(match.matchDate));
var monthNum = date.getMonth() + 1;
var dayNum = date.getDate();
var yearNum = date.getFullYear();
var monthText = fifa.vocManager.translateAbbr('fifa.month_' + monthNum);
match.dayName = fifa.vocManager.translate('fifa.dayOfWeek_' + date.getDay());
match.fullDateFormatted = dayNum + ' ' + monthText + ' ' + yearNum;
match.dayNum = dayNum;
match.monthNum = monthNum;
match.daymonth = dayNum + '' + monthNum;
var clientDt = new Date(match.matchDateUTC);
if (match.kickOffTime && !isNaN(clientDt.getTime())) {
match.kickOffTime = [clientDt.getHours().twoDigits(), clientDt.getMinutes().twoDigits()].join(':');
match.fullDateTimeFormatted = match.fullDateFormatted + ' ' + match.kickOffTime;
} else {
match.kickOffTime = '-:-';
match.fullDateTimeFormatted = match.fullDateFormatted;
}
},
getTeamImage: function (team, type, size, cupKindId, continentalIdCup) {
if (team) {
switch (type) {
case "nationalteam":
return fifa.extensions.getTeamFlag(team, size);
case "club":
return fifa.extensions.getClubLogo(team, size);
case "competition":
if (cupKindId && cupKindId == 102) {
return fifa.extensions.getContinentalLogo(team, continentalIdCup, size);
}
else {
return fifa.extensions.getCompetitionLogo(team, size);
}
}
}
},
/* Match Info Live Data Merge */
LiveMatchDataMerge: function (matchData, liveMatchData, $scope) {
if (!liveMatchData) {
liveMatchData = matchData;
}
matchData.isLive = liveMatchData.isLive;
matchData.hasLineup = liveMatchData.hasLineup;
matchData.isFinished = liveMatchData.isFinished;
matchData.isSuspended = liveMatchData.isSuspended;
matchData.isAbandoned = liveMatchData.isAbandoned;
if (_hasLineup(liveMatchData)) {
$scope.showLineupLabel = true;
}
if (liveMatchData.isLive) {
matchData.status = 3;
this.matchMinuteFormat(matchData, liveMatchData, $scope);
matchData.scoreHome = liveMatchData.scoreHome;
matchData.scoreAway = liveMatchData.scoreAway;
}
if (liveMatchData.isFinished) {
matchData.status = 0;
matchData.showext = false;
if ($scope.locals && $scope.locals.isMobile) {
matchData.minuteFormatted = $scope.fullTimeLabelAbbr;
} else {
matchData.minuteFormatted = $scope.fullTimeLabel;
}
matchData.scoreHome = liveMatchData.scoreHome;
matchData.scoreAway = liveMatchData.scoreAway;
matchData.reasonWinCode = liveMatchData.reasonWinCode;
matchData.scorePenaltyHome = liveMatchData.scorePenaltyHome;
matchData.scorePenaltyAway = liveMatchData.scorePenaltyAway;
matchData.scoreAggregateHome = liveMatchData.scoreAggregateHome;
matchData.scoreAggregateAway = liveMatchData.scoreAggregateAway;
matchData.winnerTeamId = liveMatchData.winnerTeamId;
if (liveMatchData.winnerTeamId != null) {
if (liveMatchData.winnerTeamId == liveMatchData.idHomeTeam) {
matchData.winTeamName = liveMatchData.homeTeamName;
matchData.winTeamShortName = liveMatchData.homeTeamName;
}
if (liveMatchData.winnerTeamId == liveMatchData.idAwayTeam) {
matchData.winTeamName = liveMatchData.AwayTeamName;
matchData.winTeamShortName = liveMatchData.AwayTeamName;
}
}
if (liveMatchData.reasonWinCode != null) {
this.matchReasonWinSet(matchData, liveMatchData, $scope);
}
}
},
getCompetitionImageClass: function (comp) {
var cupKindID = comp.cupKindID;
if (!comp.isFifaCompetition && cupKindID !== 111 && cupKindID !== 102 && cupKindID !== 103) {
return "flag-national-league";
}
else if (cupKindID === 111 || cupKindID === 103 || cupKindID === 102) {
return "logo-competition";
}
else if (comp.isFifaCompetition) {
return "logo-fifa-competition";
}
},
getCompetitionImagePath: function (comp, size) {
var cupKindID = comp.cupKindID,
idCup = comp.idCup;
if (!comp.isFifaCompetition && cupKindID !== 111 && cupKindID !== 102 && cupKindID !== 103) {
return fifa.extensions.getTeamFlag(comp.countryCode, size);
}
else if (cupKindID === 111 || cupKindID === 103 || cupKindID === 102) {
if (cupKindID === 102 || cupKindID === 103) {
return fifa.extensions.getContinentalLogo(idCup, comp.idCupSeason, size);
} else {
return fifa.extensions.getCompetitionLogo(idCup, size);
}
}
else if (comp.isFifaCompetition) {
if (cupKindID === 105) {
return fifa.extensions.getFriendliesLogo();
} else {
if (cupKindID === 101 && idCup !== 520) {
return '';
}
else {
return fifa.extensions.getTournamentLogo(idCup, comp.edition);
}
}
}
},
checkFifaGenericImage: function (url) {
if (url && url.split('/')[url.split('/').length - 1] == 'generic.png') {
return 'generic-image';
}
},
winReasonText: function (match) {
var tag = 'fifa.winningReason_' + match.reasonWinCode;
var text = fifa.vocManager.translate(tag);
text = text.replace('{ScorePenH}', match.scorePenaltyHome);
text = text.replace('{ScorePenA}', match.scorePenaltyAway);
text = text.replace('{ScoreAggH}', match.scoreAggregateHome);
text = text.replace('{ScoreAggA}', match.scoreAggregateAway);
text = text.replace('{WinTeamName}', match.winTeamName);
text = text.replace('{WinTeamCountry}', match.winTeamShortName);
return text;
},
winReasonTextAbbr: function (match) {
var tag = 'fifa.winningReason_' + match.reasonWinCode;
var text = fifa.vocManager.translateAbbr(tag);
text = text.replace('{ScorePenH}', match.scorePenaltyHome);
text = text.replace('{ScorePenA}', match.scorePenaltyAway);
text = text.replace('{ScoreAggH}', match.scoreAggregateHome);
text = text.replace('{ScoreAggA}', match.scoreAggregateAway);
text = text.replace('{WinTeamName}', match.winTeamName);
text = text.replace('{WinTeamCountry}', match.winTeamShortName);
return text;
},
hasDifferentDataFromLiveData: function (match, liveData, comp, compLiveData) {
if (match.isLive != liveData.isLive) { return true; }
if (match.isFinished != liveData.isFinished) { return true; }
if (match.scoreHome != liveData.scoreHome) { return true; }
if (match.idWinTeam != liveData.winnerTeamId) { return true; }
if (match.reasonWinCode != liveData.reasonWinCode) { return true; }
if (match.scorePenaltyHome != liveData.scorePenaltyHome) { return true; }
if (match.scorePenaltyAway != liveData.scorePenaltyAway) { return true; }
if (match.scoreAggregateHome != liveData.scoreAggregateHome) { return true; }
if (match.scoreAggregateAway != liveData.scoreAggregateAway) { return true; }
if (match.scoreHomeFirstLeg != liveData.scoreHomeFirstLeg) { return true; }
if (match.scoreAwayFirstLeg != liveData.scoreAwayFirstLeg) { return true; }
if (comp.hasMatchLive != compLiveData.hasMatchLive) { return true; }
return false;
},
setGoalHighlightTimeout: function (match) {
setTimeout(function () {
localStorage.removeItem("ls-hl-" + match.idMatch);
}, 60000);
},
setGoalHighlight: function (match, liveData) {
var highlightDirection = "";
var _this = this;
if ((liveData.scoreHome > 0) && (liveData.scoreHome !== match.scoreHome)) {
highlightDirection = "home";
} else if ((liveData.scoreAway > 0) && (liveData.scoreAway !== match.scoreAway)) {
highlightDirection = "away";
}
if (highlightDirection) {
match.goalHighlight = highlightDirection;
localStorage.setItem("ls-hl-" + match.idMatch, "true");
_this.setGoalHighlightTimeout(match);
}
},
mapLiveData: function (match, liveData, $scope, comp, compLiveData) {
match.isLive = liveData.isLive;
match.isFinished = liveData.isFinished;
if (liveData.competitionId !== 106) {
match.isSuspended = liveData.isSuspended;
}
match.isAbandoned = liveData.isAbandoned;
comp.hasMatchLive = compLiveData.hasMatchLive;
if (!localStorage.getItem("ls-hl-" + match.idMatch)) {
delete match.goalHighlight;
}
if (liveData.isLive) {
match.status = 3;
$scope.minute(match, liveData, $scope);
if ($scope.checkHighlight) {
this.setGoalHighlight(match, liveData);
}
match.scoreHome = liveData.scoreHome;
match.scoreAway = liveData.scoreAway;
}
if (liveData.isFinished && match.status == 3) {
match.status = 0;
match.showext = false;
match.minuteFormatted = $scope.fullTimeLabel;
match.scoreHome = liveData.scoreHome;
match.scoreAway = liveData.scoreAway;
if (!$scope.callLoadFavourites) {
$scope.callLoadFavourites = true;
}
}
match.hasLineup = liveData.hasLineup;
if (match.status == 0 && liveData.winnerTeamId != null) {
match.idWinTeam = liveData.winnerTeamId;
}
if (liveData.reasonWinCode != null && match.status == 0) {
if (match.reasonWinCode !== liveData.reasonWinCode) {
match.reasonWinCode = liveData.reasonWinCode;
match.scorePenaltyHome = liveData.scorePenaltyHome;
match.scorePenaltyAway = liveData.scorePenaltyAway;
match.scoreAggregateHome = liveData.scoreAggregateHome;
match.scoreAggregateAway = liveData.scoreAggregateAway;
match.scoreHomeFirstLeg = liveData.scoreHomeFirstLeg;
match.scoreAwayFirstLeg = liveData.scoreAwayFirstLeg;
}
if (liveData.winnerTeamId != null && liveData.winnerTeamId == match.idHomeTeam) {
match.winTeamName = match.homeTeamName;
match.winTeamShortName = match.homeTeamName;
}
if (liveData.winnerTeamId != null && liveData.winnerTeamId == match.idAwayTeam) {
match.winTeamName = match.awayTeamName;
match.winTeamShortName = match.awayTeamName;
}
}
},
updateDataLive: function ($scope) {
var _matchUpdate = false;
angular.forEach($scope.competitions.competitionslist, function (comp, key) {
if (comp != null && $scope.livematches[comp.idCupSeason]) {
var matchlist = $scope.livematches[comp.idCupSeason].matchlist;
var compLiveData = $scope.livematches[comp.idCupSeason];
angular.forEach(matchlist, function (liveData, key) {
angular.forEach(comp.matchlist, function (match, key) {
if (match.idMatch == liveData.id) {
$scope.mapLiveData(match, liveData, $scope, comp, compLiveData);
if (_matchUpdate) {
$scope.hasDifferentDataFromLiveData(match, liveData, comp, compLiveData);
}
}
});
});
if (($scope.filteredCompetitions || []).length > 0) {
angular.forEach($scope.filteredCompetitions, function (compfiltered, key) {
if (compfiltered.idCupSeason == comp.idCupSeason) {
compfiltered.hasMatchLive = comp.hasMatchLive;
}
});
}
}
});
if ($scope.callLoadFavourites) {
$scope.forceReloadFavourites();
}
if (_matchUpdate) {
fifa.dispatcher.trigger('analytics:customPageView', { dataupdates: true });
}
},
minute: function (match, liveData, $scope) {
switch (liveData.phaseCode) {
case '1': /*FirstHalf*/
if (liveData.minute > 45 || liveData.minuteExtra > 0) {
match.minuteFormatted = 45;
match.showext = true;
} else {
match.minuteFormatted = liveData.minute;
match.showext = false;
}
break;
case 'H': case '2': /*HalfTime*/
match.minuteFormatted = $scope.halfTimeLabel;
match.showext = false;
break;
case '4': /*SecondHalf*/
if (liveData.minute > 90 || liveData.minuteExtra > 0) {
match.minuteFormatted = 90;
match.showext = true;
} else {
match.minuteFormatted = liveData.minute;
match.showext = false;
}
break;
case '5': /*End SecondHalf*/
match.minuteFormatted = $scope.endSecondHalfLabel;
match.showext = false;
break;
case '6': /*Fist Extra*/
if (liveData.minute > 105 || liveData.minuteExtra > 0) {
match.minuteFormatted = 105;
match.showext = true;
} else {
match.minuteFormatted = liveData.minute;
match.showext = false;
}
break;
case '7': /*End Fist Extra*/
match.minuteFormatted = $scope.endFirstExtraLabel;
match.showext = false;
break;
case '8': /*Second Extra*/
if (liveData.minute > 120 || liveData.minuteExtra > 0) {
match.minuteFormatted = 120;
match.showext = true;
} else {
match.minuteFormatted = liveData.minute;
match.showext = false;
}
break;
case '9': /*End Second Extra*/
match.minuteFormatted = $scope.endSecondExtraLabel;
match.showext = false;
break;
case 'A': /* PSO*/
match.minuteFormatted = $scope.penaltyLabel;
match.showext = false;
break;
}
},
getFilteredScorerGoalsEvents: function (scorer, teamId) {
var _filtered_events_goals = _.filter(scorer.events, function (evt) {
if (evt.eventCode == 3 && (scorer.teamID == teamId && evt.subKindCode != 'O') || (scorer.teamID != teamId && evt.subKindCode == 'O')) {
return evt;
}
});
return _filtered_events_goals;
}
};
}());
var matchListManage = {
fillMatchList: function ($scope, data) {
$scope.matchList = data;
}
}
/* Expose the library in a factory*/
module.factory('matchDataManage', function () {
return matchDataManage;
});
module.factory('matchListManage', function () {
return matchListManage;
});
}());
;(function () {
'use strict';
var module = angular.module('middlewareCalls', []);
var mockType = "";
if (localStorage.getItem("useMock") == "true") {
mockType = "/mock";
}
var host = window.location.host,
_lang = "en",
_localDate = new Date(),
_timeshift = _localDate.getTimezoneOffset() * -1,
_localDateMidnight = new Date(Date.UTC(_localDate.getFullYear(), _localDate.getMonth(), _localDate.getDate())),
_middlewareBaseUrl = (host.indexOf('localhost') !== -1) ? 'http://localhost:1337' : '//data.fifa.com';
var middlewareMatchCalls = {
lang: "en",
localDate: new Date(),
middlewareBaseUrl: (host.indexOf('localhost') !== -1) ? 'http://localhost:1337' : '//data.fifa.com',
getClosestMatches: function (successCallback, idmatch, $http) {
window._closestMatchesCallback = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/matches/' + this.lang + '/closest/' + idmatch, null);
},
getTeamMatches: function (successCallback, idteam, count, $http) {
window._teamMatchesCallback = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/matches/' + this.lang + '/byteam/' + idteam + '/' + count, null);
},
getTeamMatchesPrevNext: function (successCallback, idteam, $http) {
window._teamMatchesPrevNextCallback = successCallback;
var middleWareUrl = this.middlewareBaseUrl + '/matches/' + this.lang + '/byteam/prevnext/' + idteam;
$http.jsonp(middleWareUrl, null);
},
getPlayingCompetitions: function (successCallback, idteam, $http) {
window._playingCompetitionsCallback = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/livescores/' + this.lang + '/competitions/playingbyteam/' + idteam, null);
},
getLiveMatches: function (successCallback, $http) {
window._liveMatchesCallback = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/livescores/live/matches' + mockType, null);
},
getAllClubMatches: function (successCallBack, idclub, $http) {
window._matchesbyclub = successCallBack;
$http.jsonp(this.middlewareBaseUrl + '/livescores/en/matches/byclub/' + idclub, null);
},
getMatchInfo: function (successCallback, matchid, $http) {
window._matchInfoCallBack = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/matches/' + this.lang + '/info/' + matchid, null);
},
getLiveMatchInfo: function (successCallback, matchid, $http) {
window._matchInfoCallBack = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/matches/' + this.lang + '/live/info/' + matchid, null);
}
};
var middlewareTeamCalls = {
lang: "en",
localDate: new Date(),
middlewareBaseUrl: (host.indexOf('localhost') !== -1) ? 'http://localhost:1337' : '//data.fifa.com',
getListYearWithMatch: function (successCallback, idteam, $http) {
window._yearsbyteam = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/livescores/' + this.lang + '/years/teams/' + idteam);
},
getCompetionsMatchList: function (successCallback, idteam, year, $http) {
window._matchesbyteam = successCallback;
$http.jsonp(this.middlewareBaseUrl + '/livescores/' + this.lang + '/matches/byteam/' + +idteam + '/years/' + year);
}
};
var middlewareCompetitionsCalls = {
getCompetitionInfo: function (successCallback, idcup, $http) {
window._competitionInfoCallback = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/competitions/info/' + idcup);
},
getCompetitionClosestMatches: function (successCallback, idcup, $http) {
window._closestMatchesByIdCupCallback = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/matches/closest/competitions/' + idcup + '/' + _localDateMidnight.getTime());
},
getMatchesByYearAndMonth: function (successCallback, idcup, year, month, $http) {
window._matchesByYearAndMonthCallback = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/matches/byyearandmonth/' + idcup + '/' + year + '/' + month);
},
getCompetitionStandings: function (successCallback, idcup, count, $http) {
window._competitionListStandingsByCupCallback = successCallback;
count = count || 50;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/standings/bycup/' + idcup + '/' + count);
},
getTopScorers: function (successCallback, idcup, count, $http) {
window._topScorersByIdCupCallback = successCallback;
count = count || 100;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/competitions/' + idcup + '/topscorers/' + count);
},
getListMonthWithMatch: function (successCallback, idCup, $http) {
window._monthbycompetition = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/months/competitions/' + idCup);
}
};
var middlewareInternationalTournamentsCalls = {
getListMonths: function (successCallback, gender, $http) {
window._monthListCallback = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/internationaltournaments/months/' + gender);
},
getMatchesByYearAndMonth: function (successCallback, year, month, gender, $http) {
window._matchesByYearAndMonthCallback = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/internationaltournaments/matches/' + gender + '/byyearandmonth/' + year + '/' + month);
},
getMatchesByDateRange: function (successCallback, dateFrom, dateTo, gender, $http) {
window._matchesByDateRangeCallback = successCallback;
$http.jsonp(_middlewareBaseUrl + '/livescores/' + _lang + '/internationaltournaments/matches/' + gender + '/bydaterange/' + dateFrom + '/' + dateTo);
}
};
module.factory('middlewareMatchCalls', function () {
return middlewareMatchCalls;
});
module.factory('middlewareTeamCalls', function () {
return middlewareTeamCalls;
});
module.factory('middlewareCompetitionsCalls', function () {
return middlewareCompetitionsCalls;
});
module.factory('middlewareInternationalTournamentsCalls', function () {
return middlewareInternationalTournamentsCalls;
});
}());
;(function () {
'use strict';
var module = angular.module('utilityModule', []);
var utilityManager = {
getCompetitionImagePath: function (comp) {
var cupKindID = comp.cupKindID,
idCup = comp.idCup;
if (!comp.isFifaCompetition && cupKindID !== 111 && cupKindID !== 102 && cupKindID !== 103) {
return fifa.extensions.getTeamFlag(comp.countryCode, '3');
}
else if (cupKindID === 111 || cupKindID === 103 || cupKindID === 102) {
if (cupKindID === 102 || cupKindID === 103) {
return fifa.extensions.getContinentalLogo(idCup, comp.idCupSeason, '3');
} else {
return fifa.extensions.getCompetitionLogo(idCup, '3');
}
}
else if (comp.isFifaCompetition) {
if (cupKindID === 105) {
return fifa.extensions.getFriendliesLogo();
} else {
if (cupKindID === 101 && idCup !== 520) {
return '';
}
else {
return fifa.extensions.getTournamentLogo(idCup, comp.edition);
}
}
}
},
registerEmit: function (emit) {
if (!window.initializerEmit) {
window.initializerEmit = [];
}
window.initializerEmit.push(emit);
},
replaceMoreUrl: function (context, queryPath, selector) {
var _basePath = document.location.pathname;
_basePath = _basePath.substring(0, _basePath.indexOf(queryPath));
var _buttonObj = document.querySelector("div[data-context='" + context + "'] .qlink-wrap" + selector + " .qlink-link .qlink-link-wrap a");
if (_buttonObj) {
var _href = _buttonObj.getAttribute("href");
_href = _href.replace("[basepath]", _basePath);
_buttonObj.setAttribute("href", _href);
}
}
};
var sliderManager = {
sliderListObject: null,
dataValue: null,
initListObject: function () {
this.sliderListObject = angular.element(document.querySelectorAll("div[data-elment-name='slider'] > ul > li"));
},
click: function ($event) {
if (!this.sliderListObject) {
this.initListObject();
}
if (this.dataValue) {
this.dataValue = null;
}
var dataType = $event.currentTarget.dataset.type;
if (dataType) {
switch (dataType) {
case 'next':
this.next();
break;
case 'prev':
this.prev();
break;
}
return this.dataValue;
}
},
next: function () {
var activeItemIndex = this.getActiveItemIndexByDataType();
this.manageNextNewActiveItemIndex(activeItemIndex);
},
prev: function () {
var activeItemIndex = this.getActiveItemIndexByDataType();
this.managePrevNewActiveItemIndex(activeItemIndex);
},
selectSpecificItem: function (value) {
if (!this.sliderListObject) {
this.initListObject();
}
if (this.dataValue) {
this.dataValue = null;
}
var activeItemIndex = this.getActiveItemIndexByDataValue(value);
this.manageSelectedActiveItemIndex(activeItemIndex);
return this.dataValue;
},
getActiveItemIndexByDataValue: function (value) {
var index = null;
for (var i = 0; i < (this.sliderListObject || this.initListObject(), this.sliderListObject).length; i++) {
var el = this.sliderListObject[i];
if (el.getAttribute('data-value') == value) {
index = i;
return index;
}
}
},
getActiveItemIndexByDataType: function () {
var index = null;
for (var i = 0; i < (this.sliderListObject || this.initListObject(), this.sliderListObject).length; i++) {
var el = this.sliderListObject[i];
if (el.getAttribute('data-type') === 'active') {
index = i;
return index
}
}
},
manageSelectedActiveItemIndex: function (activeItemIndex) {
var _newPrevIndex = activeItemIndex - 1;
var _newActiveIndex = activeItemIndex;
var _newNextIndex = activeItemIndex + 1;
this.setUpdateActiveItemPosition(_newPrevIndex, _newActiveIndex, _newNextIndex);
},
managePrevNewActiveItemIndex: function (activeItemIndex) {
var _newPrevIndex = activeItemIndex - 2;
var _newActiveIndex = activeItemIndex - 1;
var _newNextIndex = activeItemIndex;
this.setUpdateActiveItemPosition(_newPrevIndex, _newActiveIndex, _newNextIndex);
},
manageNextNewActiveItemIndex: function (activeItemIndex) {
var _newPrevIndex = activeItemIndex;
var _newActiveIndex = activeItemIndex + 1;
var _newNextIndex = activeItemIndex + 2;
this.setUpdateActiveItemPosition(_newPrevIndex, _newActiveIndex, _newNextIndex);
},
setUpdateActiveItemPosition: function (prev, active, next) {
if (!this.sliderListObject) {
this.initListObject();
}
var emptyEl = document.getElementById('empty-item');
if (emptyEl) {
emptyEl.parentNode.removeChild(emptyEl);
}
for (var i = 0; i < this.sliderListObject.length; i++) {
var el = this.sliderListObject[i];
el.setAttribute('data-type', '');
el.setAttribute('class', 'item hidden');
if (i == prev) {
el.setAttribute('data-type', 'prev');
el.setAttribute('class', 'item prev');
}
if (i == active) {
el.setAttribute('data-type', 'active');
el.setAttribute('class', 'item active');
this.dataValue = el.getAttribute('data-value');
}
if (i == next) {
el.setAttribute('data-type', 'next');
el.setAttribute('class', 'item next');
}
}
if (active === 0) {
var listLi = document.querySelector("div[data-elment-name='slider'] > ul");
var emptyli = document.createElement("li");
var emptyText = document.createTextNode("-");
emptyli.appendChild(emptyText);
emptyli.setAttribute('class', 'item item-empty');
emptyli.setAttribute('id', 'empty-item');
listLi.insertBefore(emptyli, listLi.childNodes[0]);
}
if (active == this.sliderListObject.length - 1) {
var listLi = document.querySelector("div[data-elment-name='slider'] > ul");
var emptyli = document.createElement("li");
var emptyText = document.createTextNode("-");
emptyli.appendChild(emptyText);
emptyli.setAttribute('class', 'item item-empty');
emptyli.setAttribute('id', 'empty-item');
listLi.appendChild(emptyli);
}
}
};
var standingsManager = {
ISSRankTypeList: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
32768, 65536, 131072, 262144, 1048576, 536870912, 1073741824],
ISSRankTypeListMappingFifaTag: [{ id: 1, name: "fifa.matchesBrowser" }
, { id: 2, name: "fifa.championshipPlayOff" }
, { id: 4, name: "fifa.relegationPlayOff" }
, { id: 8, name: "fifa.relegation" }
, { id: 16, name: "fifa.promotion" }
, { id: 32, name: "fifa.promotionPlayOff" }
, { id: 64, name: "fifa.championsLeagueEc" }
, { id: 128, name: "fifa.championsLeaguePreliminary" }
, { id: 256, name: "fifa.uefaCupPlayOff" }
, { id: 512, name: "fifa.uefaCupByDomestic" }
, { id: 1024, name: "fifa.nextRound" }
, { id: 2048, name: "fifa.play-offs" }
, { id: 4096, name: "fifa.finalTournament" }
, { id: 8192, name: "fifa.championsPlayOff" }
, { id: 16384, name: "fifa.uefaCupPlayOff" }
, { id: 32768, name: "fifa.intertoto" }
, { id: 65536, name: "fifa.intertotoPlayOff" }
, { id: 131072, name: "fifa.copaLibertadores" }
, { id: 262144, name: "fifa.copaSudamericana" }
, { id: 1048576, name: "fifa.uefaCup" }
, { id: 536870912, name: "fifa.uefaCupThroughDomestic" }
, { id: 1073741824, name: "fifa.periodChampions" }],
standingsMarkerManageByCompetitionList: function (competitionListStandingsData) {
var _this = this;
angular.forEach(competitionListStandingsData, function (comp, key) {
comp.tableLegend = [];
angular.forEach(comp.listStandings, function (standingRow, key) {
_this.getPositionMarker(standingRow);
var legendItem = _this.getLegendStandings(standingRow);
if (legendItem) {
var checkItemExist = _.find(comp.tableLegend, function (el) {
if (el.id == legendItem.id) {
return true;
} else {
return false;
}
});
if (!checkItemExist) {
comp.tableLegend.push(legendItem);
}
}
});
});
},
standingsMarkerManageByListStandingsRow: function (listStandingsRow) {
var _this = this;
angular.forEach(listStandingsRow, function (standingRow, key) {
_this.getPositionMarker(standingRow);
});
},
getPositionMarker: function (standingRow) {
standingRow.rankMarkerType = this.getRankTypeBW(standingRow.providerRankCode);
},
getRankTypeBW: function (rankType) {
for (var i = 0; i < this.ISSRankTypeList.length; i++) {
if ((rankType & this.ISSRankTypeList[i]) > 0) {
return rankType & this.ISSRankTypeList[i];
}
}
return 0;
},
getLegendStandings: function (standingRow) {
for (var i = 0; i < this.ISSRankTypeListMappingFifaTag.length; i++) {
var key = this.ISSRankTypeListMappingFifaTag[i].id;
if ((standingRow.providerRankCode & key) > 0) {
return this.ISSRankTypeListMappingFifaTag[i];
}
}
}
};
module.factory('utilityManager', function () {
return utilityManager;
});
module.factory('sliderManager', function () {
return sliderManager;
});
module.factory('standingsManager', function () {
return standingsManager;
});
module.directive('lsMatchesList', ['$compile', function ($compile) {
return {
restrict: 'A',
scope: true,
link: {
post: function ($scope, element, $attr) {
var teamNameLength = $scope.locals && $scope.locals.isMobile ? 10 : 12,
muClassGet = function (match) {
var cssClass = [];
if (match.isClubCompetition) {
cssClass.push('club-competition');
}
else {
cssClass.push('team-competition');
}
if (match.isFinished) {
cssClass.push('result');
}
else if (match.isLive) {
cssClass.push('live');
}
else if (!match.isLive && !match.hasLineup) {
cssClass.push('fixture');
}
return cssClass.join(' ');
},
teamMarkupGet = function (match, idTeam, teamName, teamCountryCode, teamClass) {
var html_buf = [];
html_buf.push('
');
if (!match.isClubCompetition) {
html_buf.push('
');
html_buf.push('
');
html_buf.push('
');
html_buf.push('');
html_buf.push('
');
}
else {
html_buf.push('
');
html_buf.push('
');
html_buf.push('
');
html_buf.push('
');
html_buf.push('');
html_buf.push('
');
}
html_buf.push('
');
html_buf.push('', teamName, '');
html_buf.push('', teamCountryCode, '');
html_buf.push('
');
html_buf.push('
');
return html_buf.join('');
},
matchUnitMarkupGet = function (match) {
var html_buf = [];
/*mu-i*/
html_buf.push('');
html_buf.push('
', match.fullDateTimeFormatted, ' ', $scope.localTimeLabel, '
');
html_buf.push('
', match.fullDateFormatted, '
');
html_buf.push('
', match.matchNumber, '
');
html_buf.push('
', match.competitionName, '
');
html_buf.push('
', match.dayName, '
');
html_buf.push('
', match.fullDateFormatted, '
');
html_buf.push('
');
html_buf.push('
', match.stadiumName, '
');
html_buf.push('
', match.venueName, '
');
html_buf.push('
');
html_buf.push('
');
/*end mu-i*/
/*mu-day*/
html_buf.push('');
html_buf.push('', match.dayNum, '');
html_buf.push('', match.monthNum, '');
html_buf.push('
');
/*end mu-day*/
/*mu-m*/
html_buf.push('');
/*t home*/
html_buf.push(teamMarkupGet(match, match.idHomeTeam, match.homeTeamName, match.homeCountryCode, 'home'));
/*end t home*/
/*t away*/
html_buf.push(teamMarkupGet(match, match.idAwayTeam, match.awayTeamName, match.awayCountryCode, 'away'));
/*end t away*/
/*s*/
html_buf.push('
');
/*s-fixture*/
html_buf.push('
');
/*s-status*/
html_buf.push('
');
if (match.minuteFormatted && (match.minuteFormatted.length > 0 || match.minuteFormatted > 0)) {
html_buf.push('', match.minuteFormatted, '');
}
if (match.minuteFormatted > 0) {
html_buf.push('\'');
}
if (match.showext) {
html_buf.push('+');
}
html_buf.push('
');
/*end s-status*/
/*s-status-abbr*/
html_buf.push('
');
if (match.minuteFormatted && (match.minuteFormatted.length > 0 || match.minuteFormatted > 0)) {
html_buf.push('', match.minuteFormatted, '');
}
if (match.minuteFormatted > 0) {
html_buf.push('\'');
}
if (match.showext) {
html_buf.push('+');
}
html_buf.push('
');
/*end s-status-abbr*/
/*s-score*/
html_buf.push('
');
if (match.isLive || match.isFinished) {
html_buf.push('');
var lang = "en";
if (lang.toLowerCase() !== 'ar') {
html_buf.push('', match.scoreHome, '');
html_buf.push('-');
html_buf.push('', match.scoreAway, '');
} else {
html_buf.push('', match.scoreAway, '');
html_buf.push('-');
html_buf.push('', match.scoreHome, '');
}
html_buf.push('');
}
else if (!match.isLive && !match.isFinished) {
html_buf.push('');
if (match.kickOffTime && match.kickOffTime !== '-:-') {
var dtClient = new Date(match.matchDate), koTime = match.kickOffTime;
if (!isNaN(dtClient.getTime())) {
koTime = [dtClient.getHours().twoDigits(), dtClient.getMinutes().twoDigits()].join(':');
}
html_buf.push('', koTime, '');
}
else {
html_buf.push('-:-');
}
html_buf.push('');
}
html_buf.push('
');
/*end s-score*/
html_buf.push('
');
/*end s-fixture*/
html_buf.push('
');
/*end s*/
/*mu-reasonwin*/
html_buf.push('
');
html_buf.push('', match.winReasonText, '');
html_buf.push('
');
/*end mu-reasonwin*/
/*mu-reasonwin-abbr*/
html_buf.push('
');
html_buf.push('', match.winReasonTextAbbr, '');
html_buf.push('
');
/*end mu-reasonwin-abbr*/
html_buf.push('
');
/*end mu-m*/
return html_buf.join('');
},
matchUnitTemplateSet = function (match) {
var html_buf = [];
html_buf.push([''].join(''));
if (match.link && match.link.length > 0) {
html_buf.push(['
', matchUnitMarkupGet(match), ''].join(''));
}
else {
html_buf.push(matchUnitMarkupGet(match));
}
html_buf.push('
');
return html_buf;
},
matchesListTemplateSet = function (matches) {
matches = matches || $scope.matches;
if (!matches) { return; }
var html_buf = [], i = 0, l = matches.length;
for (i; i < l; i++) {
html_buf.push(matchUnitTemplateSet($scope.matches[i]).join(''));
}
element.html(html_buf.join(''));
};
matchesListTemplateSet();
$scope.$watchCollection($attr.lsMatchesList, function (newValue, oldValue) {
if ((window.fifa && window.fifa.vocManager && window.fifa.vocManager.vocabularies.length > 0) && _.isEqual(newValue, oldValue)) {
return;
}
if (!newValue) {
return;
}
matchesListTemplateSet(newValue);
}, true);
}
}
};
}]);
module.directive('lsMatchUnit', ['$compile', 'matchDataManage', function ($compile, matchDataManage) {
return {
restrict: 'A',
scope: true,
link: {
post: function ($scope, element, $attr) {
var _isMobile = $scope.locals && $scope.locals.isMobile,
teamNameLength = _isMobile ? 16 : 23,
muClassGet = function (match, comp) {
if (match.isLive) {
return 'live';
}
if (matchDataManage.hasLineup(match)) {
return 'lineups';
}
if ((match.reasonWinCode != null) && (match.reasonWinCode > 1)) {
return 'win-reason-view';
}
if (!comp.favouriteByTeam) {
return 'no-duplicated';
}
},
teamMarkupGet = function (match, idTeam, teamName, teamCountryCode, teamClass, userFavObj) {
var html_buf = [];
html_buf.push('');
if (match.isClubCompetition) {
teamCountryCode = undefined;
}
if (teamClass === 't-h') {
if ($scope.checkTeamInFavMatchUnit(idTeam, teamCountryCode, match.countryCode, userFavObj)) {
html_buf.push('');
}
}
html_buf.push('', teamName, '');
if (teamClass === 't-a') {
if ($scope.checkTeamInFavMatchUnit(idTeam, teamCountryCode, match.countryCode, userFavObj)) {
html_buf.push('');
}
}
html_buf.push('
');
return html_buf.join('');
},
matchUnitMarkupGet = function (match, userFavObj) {
var html_buf = [];
html_buf.push('');
if (match.status == 0) {
html_buf.push('', $scope.fullTimeLabel, '');
if (match.cupKindID == 105) {
html_buf.push('', match.venueName, '');
}
}
else {
if (matchDataManage.hasLineup(match)) {
html_buf.push('', $scope.lineupLabel, '');
}
if (match.status != 1) {
html_buf.push('');
if (match.isAwarded) {
html_buf.push(fifa.vocManager.translateAbbr('fifa.forfeited').toUpperCase());
}
if (match.isAbandoned) {
html_buf.push(fifa.vocManager.translateAbbr('fifa.abandonedStatus').toUpperCase());
}
if (match.isSuspended) {
html_buf.push(fifa.vocManager.translateAbbr('fifa.suspendedstatus').toUpperCase());
}
else {
if (match.minuteFormatted || match.minuteFormatted > 0) {
html_buf.push('', match.minuteFormatted, '');
if (match.minuteFormatted > 0) {
html_buf.push("'");
}
}
if (match.showext) {
html_buf.push('+');
}
}
html_buf.push('');
}
if (match.cupKindID == 105) {
html_buf.push('', match.venueName, '');
}
}
html_buf.push('
');
html_buf.push('');
html_buf.push('');
html_buf.push('');
/*t-h*/
html_buf.push(teamMarkupGet(match, match.idHomeTeam, match.homeTeamName, match.homeCountryCode, 't-h', userFavObj));
/*end t-h*/
if (match.status != 1) {
html_buf.push('
', match.scoreHome, ' - ', match.scoreAway, '
');
}
else if (match.status == 1) {
html_buf.push('
');
if (!match.kickOffTime) {
html_buf.push('-:-');
}
else if (match.kickOffTime.length > 0) {
var dt_utc = new Date(match.matchDateUTC), koTime = match.kickOffTime;
if (dt_utc.getFullYear() > 1800) {
var dtClient = new Date(match.matchDateUTC);
if (!isNaN(dtClient.getTime())) {
koTime = [dtClient.getHours().twoDigits(), dtClient.getMinutes().twoDigits()].join(':');
}
}
html_buf.push('', koTime, '');
if (match.isNextDay) {
html_buf.push(' (+1)');
}
}
html_buf.push('
');
}
/*t-a*/
html_buf.push(teamMarkupGet(match, match.idAwayTeam, match.awayTeamName, match.awayCountryCode, 't-a', userFavObj));
/*end t-a*/
html_buf.push('
');
/*end ls-mu-det*/
/*ls-mu-rw*/
if (match.reasonWinCode && match.reasonWinCode > 1) {
html_buf.push('');
var winReasonTxt;
if (_isMobile) {
winReasonTxt = $scope.winReasonTextAbbr(match);
}
else {
winReasonTxt = $scope.winReasonText(match);
}
html_buf.push('', winReasonTxt, '');
html_buf.push('
');
}
/*end ls-mu-rw*/
return html_buf.join('');
},
matchUnitTemplateSet = function (match, elm, userFavObj) {
match = match || $scope.match;
var html_buf = [], comp = $scope.comp;
var _goalHLClass = "";
var isGoalHLHidden = (angular.element(document.querySelector(".goal-hl-hidden")) && angular.element(document.querySelector(".goal-hl-hidden")).length > 0);
if (match.goalHighlight && !isGoalHLHidden) {
_goalHLClass = (match.goalHighlight === "home") ? "goal-hl-home" : "goal-hl-away";
}
html_buf.push('');
(elm || element).html(html_buf.join(''));
};
matchUnitTemplateSet(undefined, undefined, $scope.userFavObj);
}
}
};
}]);
module.directive('lsCompetitionList', ['$compile', '$filter', function ($compile, $filter) {
return {
restrict: 'A',
scope: true,
link: {
post: function ($scope, element, $attr) {
var filter = $attr.lsFilter,
matchesFilter = $attr.lsMatchesFilter,
matchesGroupBy = $attr.lsMatchesGroupBy,
_isMobile = $scope.locals && $scope.locals.isMobile,
competitionListTemplate = function (complist) {
complist = (complist || $scope[$attr.lsCompetitionList]);
if (filter) {
complist = $filter($attr.lsFilter)(complist);
}
if (!complist) { return; }
complist = complist.hasOwnProperty('competitionslist') ? complist.competitionslist : complist;
var html_buf = [];
if (!angular.isArray(complist)) {
var result = [];
for (var compkey in complist) {
result.push(complist[compkey]);
}
complist = result;
}
var i = 0, l = complist.length;
if (_isMobile) {
$scope.userFavObj = $scope.getUserFavObj();
}
for (i; i < l; i++) {
$scope.comp = complist[i];
html_buf.push(competitionUnitTemplate());
}
if (_isMobile) {
delete $scope.userFavObj;
}
element.html(html_buf.join(''));
$(element[0]).find('.favourites-icon-btn').off('click.favourites').on('click.favourites', function () {
var complist = angular.element(this).scope().$parent.competitions.competitionslist;
var idCup = $(this).closest('.competition-row').attr('data-idcup');
if (!angular.isArray(complist)) {
var result = [];
for (var compkey in complist) {
result.push(complist[compkey]);
}
complist = result;
}
var comp = undefined, i = 0, l = complist.length;
for (i; i < l; i++) {
if (complist[i].idCup == idCup) {
comp = complist[i];
break;
}
}
if (!comp) { return; }
$scope.$apply(function () {
$scope.manageFavouriteIcon('competitions', comp);
});
});
},
competitonNameTemplate = function (comp) {
var html_buf = [];
var compImageClass = $scope.CompetitionImageClass(comp);
var compImagePath = $scope.CompetitionImagePath(comp);
var compFifaGenericImage = $scope.checkFifaGenericImage(compImagePath);
html_buf.push('
');
html_buf.push('', comp.name, '');
return html_buf.join('');
},
competitionUnitTemplate = function (comp) {
comp = comp || $scope.comp;
var html_buf = [];
if (!comp.showInFavourites || _isMobile) {
html_buf.push('');
html_buf.push('');
/*Match List*/
html_buf.push('
');
var matchlist = comp.matchlist;
if (matchesFilter) {
matchlist = $filter(matchesFilter)(matchlist);
}
var l = matchlist.length, m = 0;
if (!l) {
return '';
}
var last_group_by_date, match, match_date_format;
for (m; m < l; m++) {
$scope.match = match = matchlist[m];
if (matchesGroupBy === 'date' && last_group_by_date !== (match_date_format = match.matchDate.formatDate('dddd dd/MM/yyyy'))) {
last_group_by_date = match_date_format;
html_buf.push('
', match_date_format, '
');
}
html_buf.push($compile('
')($scope).html());
}
html_buf.push('
');
/*End Match List*/
/*Mobile matches and standings button*/
if (_isMobile) {
html_buf.push('
');
html_buf.push('
');
html_buf.push('
');
html_buf.push('
');
}
html_buf.push('
');
return html_buf.join('');
}
return '';
};
competitionListTemplate();
var _watchCollection = $scope.$watch($attr.lsCompetitionList, function (newValue, oldValue) {
if ((window.fifa && window.fifa.vocManager && window.fifa.vocManager.vocabularies.length > 0) && _.isEqual(newValue, oldValue)) {
return;
}
competitionListTemplate(newValue);
}, true);
element.on('$destroy', function () {
_watchCollection();
});
}
}
};
}]);
module.directive('lsGenericSlider', ['$compile', function ($compile) {
return {
restrict: 'A',
scope: true,
link: function ($scope, element, $attr) {
var sliderItemTemplate = function (listItem) {
var i = 0, l = (listItem || $scope.listItem || []).length, html_buf = [];
if (!l) { return; }
for (i; i < l; i++) {
var item = $scope.listItem[i];
html_buf.push('');
html_buf.push('', item.value, '
');
html_buf.push('');
}
element.html(html_buf.join(''));
$(element[0]).find('.item').off('click.slideritem').on('click.slideritem', function (e) {
$scope.ClickAction(e, { hashValue: this.getAttribute('data-hash') });
});
};
sliderItemTemplate();
var _watchCollection = $scope.$watch($attr.lsGenericSlider, function (newValue, oldValue) {
if ((window.fifa && window.fifa.vocManager && window.fifa.vocManager.vocabularies.length > 0) && _.isEqual(newValue, oldValue)) {
return;
}
if (!newValue) {
return;
}
sliderItemTemplate(newValue);
});
element.on('$destroy', function () {
_watchCollection();
});
}
};
}]);
}());
;var CompetitionPageApp = angular.module("competitionApp", ['ngRoute', 'smoothScroll', 'inline', 'matchDataManage', 'utilityModule', 'middlewareCalls']);
CompetitionPageApp.config(function ($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
CompetitionPageApp.run(function ($location, $rootScope, $templateCache, $http) {
$rootScope.controllerToLoad = 0;
$rootScope.$on('app.controllerLoaderManage', function () {
$rootScope.controllerToLoad = $rootScope.controllerToLoad - 1;
if ($rootScope.controllerToLoad == 0) {
$rootScope.$emit('app.updateRefreshLoader');
}
});
var sliderTemplate = '/trunk/js/internal/angularjs/commonTemplates' + '/slider.template.html';
var sliderTemplateContent = '';
$http.get(sliderTemplate).then(function (response) {
sliderTemplateContent = response.data;
$templateCache.put('sliderTemplate', sliderTemplateContent);
});
window.loadFifaConfig($rootScope);
});
window.loadFifaConfig = function ($rootScope) {
if (window.fifa && window.fifa.vocManager && window.fifa.vocManager.vocabularies.length > 0) {
$rootScope.$emit('FinishLoadFifaConfig');
return;
}
requestAnimationFrame(function () { window.loadFifaConfig($rootScope); });
};
CompetitionPageApp.initializeTranslate = function ($childScope, controllerName) {
$childScope.$apply(function () {
$childScope.idCup = angular.element(document.querySelector("div[data-context='competition']")).attr("data-idcontext");
$childScope.locals = { isMobile: fifa.is_mobile };
$childScope.topScorerTxt = fifa.vocManager.translate('fifa.topScorer');
$childScope.nameTxt = fifa.vocManager.translate('fifa.name');
$childScope.playersTxt = fifa.vocManager.translate('fifa.players');
$childScope.rankTxt = fifa.vocManager.translate('fifa.rank');
$childScope.teamTxt = fifa.vocManager.translate('fifa.team');
$childScope.matchesPlayedTxt = fifa.vocManager.translate('fifa.matchesPlayed');
$childScope.matchesPlayedAbbrTxt = fifa.vocManager.translateAbbr('fifa.matchesPlayed');
$childScope.goalsScoredTxt = fifa.vocManager.translate('fifa.goalsScored');
$childScope.goalsScoredAbbrTxt = fifa.vocManager.translateAbbr('fifa.goalsScored');
$childScope.penaltiesScoredTxt = fifa.vocManager.translate('fifa.penaltiesScored');
$childScope.penaltiesScoredAbbrTxt = fifa.vocManager.translateAbbr('fifa.penaltiesScored');
if (controllerName) {
$childScope.controller = document.querySelector('div[ng-controller="' + controllerName + '"]');
if ($childScope.controller) {
$childScope.limitCount = +($childScope.controller.getAttribute('data-ngrepeatlimit') || 15);
}
else {
$childScope.limitCount = 15;
}
}
});
};
;CompetitionPageApp.controller('initializeController', ['$scope', '$rootScope', 'middlewareCompetitionsCalls', 'utilityManager', '$location', '$timeout', '$http', function ($scope, $rootScope, middlewareCompetitionsCalls, utilityManager, $location, $timeout, $http) {
var _idcup = angular.element(document.querySelector("div[data-context='competition']")).attr("data-idcontext");
$scope.showLoader = true;
var initialize = function () {
middlewareCompetitionsCalls.getCompetitionInfo(function (data) {
utilityManager.registerEmit({ middlewareCall: "middlewareMatchCalls.competitionInfoCallback", emitEvent: "CompetitionInfoLoaded" });
$rootScope.$emit('CompetitionInfoLoaded', data);
}, _idcup, $http);
middlewareCompetitionsCalls.getCompetitionClosestMatches(function (data) {
utilityManager.registerEmit({ middlewareCall: "middlewareMatchCalls.getCompetitionClosestMatchesCallback", emitEvent: "competition.matchesLoaded" });
$rootScope.$emit('competition.matchesLoaded', data);
}, _idcup, $http);
$rootScope.compIdCup = _idcup;
};
$rootScope.$on('app.updateRefreshLoader', function () {
initialize();
$scope.showLoader = false;
});
}]);
;CompetitionPageApp.controller('competitionHeaderController', ['$scope', '$rootScope', '$http', 'matchDataManage', 'utilityManager', '$timeout', function ($scope, $rootScope, $http, matchDataManage, utilityManager, $timeout) {
$scope.competition = undefined;
$scope.matchesTxt = undefined;
$scope.standingsTxt = undefined;
$scope.topScorerTxt = undefined;
$scope.commentsTxt = undefined;
$scope.shareTxt = undefined;
$scope.locals = undefined;
$rootScope.controllerToLoad = $rootScope.controllerToLoad + 1;
var initialize = function () {
$rootScope.$emit('app.controllerLoaderManage');
$scope.matchesTxt = fifa.vocManager.translate('fifa.matches');
$scope.standingsTxt = fifa.vocManager.translate("fifa.standings");
$scope.topScorerTxt = fifa.vocManager.translate("fifa.topScorers");
$scope.commentsTxt = fifa.vocManager.translate("fifa.comments");
$scope.shareTxt = fifa.vocManager.translate('fifa.share');
$scope.locals = { isMobile: fifa.is_mobile };
};
$scope.GetTeamLogo = function (team, type, size, cupKindId, continentalIdCup) {
return matchDataManage.getTeamImage(team, type, size, cupKindId, continentalIdCup);
};
$rootScope.$on('CompetitionInfoLoaded', function (ev, data) {
$scope.competition = data.competitions && data.competitions.length ? data.competitions[0] : {};
$timeout(function () {
fifa.dispatcher.trigger('favourites:view:setActiveFavourites');
fifa.dispatcher.trigger('core:reinit', true);
}, 0);
});
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
}]);
;CompetitionPageApp.controller('matchListController', ['$scope', '$rootScope', 'middlewareMatchCalls', 'matchListManage', '$timeout', '$http', 'matchDataManage', function ($scope, $rootScope, middlewareMatchCalls, matchListManage, $timeout, $http, matchDataManage) {
var enablePollingFeed = true,
dayNow = new Date().getDate();
$rootScope.controllerToLoad = $rootScope.controllerToLoad + 1;
var initialize = function () {
$scope.textAllMatches = fifa.vocManager.translate('fifa.allMatches');
$scope.locals = { isMobile: fifa.is_mobile };
$scope.localTimeLabel = fifa.vocManager.translate('fifa.localtime');
/*Phase Match*/
$scope.lineupLabel = fifa.vocManager.translate('fifa.lineups');
$scope.halfTimeLabel = fifa.vocManager.translate('fifa.half-time');
$scope.endSecondHalfLabel = fifa.vocManager.translate('fifa.end2ndhalf');
$scope.endFirstExtraLabel = fifa.vocManager.translate('fifa.endfirstextra');
$scope.endSecondExtraLabel = fifa.vocManager.translate('fifa.endsecondextra');
$scope.penaltyLabel = fifa.vocManager.translate('fifa.penaltiesphase');
$scope.fullTimeLabel = fifa.vocManager.translate('fifa.full-time');
$scope.abandonedLabel = fifa.vocManager.translate('fifa.abandonedStatus');
$scope.abandonedLabelAbbr = fifa.vocManager.translateAbbr('fifa.abandonedStatus');
$scope.forfeitedLabelAbbr = fifa.vocManager.translateAbbr('fifa.forfeited');
$scope.forfeitedLabel = fifa.vocManager.translate('fifa.forfeited');
$scope.lineupLabelAbbr = fifa.vocManager.translateAbbr('fifa.lineups');
$scope.halfTimeLabelAbbr = fifa.vocManager.translateAbbr('fifa.half-time');
$scope.endSecondHalfLabelAbbr = fifa.vocManager.translateAbbr('fifa.end2ndhalf');
$scope.endFirstExtraLabelAbbr = fifa.vocManager.translateAbbr('fifa.endfirstextra');
$scope.endSecondExtraLabelAbbr = fifa.vocManager.translateAbbr('fifa.endsecondextra');
$scope.penaltyLabelAbbr = fifa.vocManager.translateAbbr('fifa.penaltiesphase');
$scope.fullTimeLabelAbbr = fifa.vocManager.translateAbbr('fifa.full-time');
$rootScope.$emit('app.controllerLoaderManage');
};
var loadMatches = function (data) {
for (var i = 0; i < data.matches.length; i++) {
matchDataManage.matchDataCreate(data.matches[i], $scope);
}
$scope.matches = data.matches;
if (enablePollingFeed) {
$scope.loadLiveMatches();
timedLoadLiveInfo();
}
};
$scope.loadLiveMatches = function (matchLive) {
middlewareMatchCalls.getLiveMatches(function (data) {
$rootScope.$emit('matchListLiveMatchesLoaded', data);
var i = 0, l = $scope.matches.length;
for (i; i < l; i++) {
var _match = $.extend({}, $scope.matches[i]);
var _seasonMatch = data[_match.idCupSeason];
if (_seasonMatch) {
var _matchLiveData = _.find(_seasonMatch.matchlist, function (match) {
return match.id == _match.idMatch;
});
if (_matchLiveData) {
matchDataManage.LiveMatchDataMerge(_match, _matchLiveData, $scope);
$scope.matches[i] = _match;
}
}
}
}, $http);
};
var _live_info_promise = null;
var timedLoadLiveInfo = function () {
if (_live_info_promise) {
$timeout.cancel(_live_info_promise);
$scope.loadLiveMatches();
}
_live_info_promise = $timeout(timedLoadLiveInfo, '10000'.withRandomShift());
};
$rootScope.$on('competition.matchesLoaded', function (ev, data) {
loadMatches(data);
});
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
$scope.GetTeamLogo = function (team, type, size) {
return matchDataManage.getTeamImage(team, type, size);
};
}]);
;CompetitionPageApp.controller('standingController', ['$scope', '$rootScope', '$http', 'middlewareCompetitionsCalls', 'standingsManager', 'matchDataManage', function ($scope, $rootScope, $http, middlewareCompetitionsCalls, standingsManager, matchDataManage) {
$scope.idCup = undefined;
$scope.teamsLabel = undefined;
$scope.clubsLabel = undefined;
$scope.matchPlayedLabel = undefined;
$scope.matchPlayedLabelAbbr = undefined;
$scope.matchWonLabel = undefined;
$scope.matchWonLabelAbbr = undefined;
$scope.matchDrawLabel = undefined;
$scope.matchDrawLabelAbbr = undefined;
$scope.matchLoseLabel = undefined;
$scope.matchLoseLabelAbbr = undefined;
$scope.matchGoalForLabel = undefined;
$scope.matchGoalForLabelAbbr = undefined;
$scope.matchGoalAgainstLabel = undefined;
$scope.matchGoalAgainstLabelAbbr = undefined;
$scope.matchGoalDiffLabel = undefined;
$scope.matchGoalDiffLabelAbbr = undefined;
$scope.pointsLabel = undefined;
$scope.pointsLabelAbbr = undefined;
$scope.competitionListStandingsData = undefined;
$scope.textFullStandings = undefined;
$scope.textLegendTitle = undefined;
$scope.limitDisplay = undefined;
$scope.groupLabel = undefined;
$scope.locals = undefined;
var initialize = function () {
$scope.idCup = angular.element(document.querySelector("div[data-context='competition']")).attr("data-idcontext");
$scope.limitDisplay = (document.querySelector('div[ng-controller="standingController"]').getAttribute('data-ngrepeatlimit') || 50);
$scope.locals = { isMobile: fifa.is_mobile };
$scope.textLegendTitle = fifa.vocManager.translate('fifa.legend');
$scope.teamsLabel = fifa.vocManager.translate('fifa.teams');
$scope.clubsLabel = fifa.vocManager.translate('fifa.clubs');
$scope.matchPlayedLabel = fifa.vocManager.translate('fifa.groupStanding.played');
$scope.matchPlayedLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.played');
$scope.matchWinLabel = fifa.vocManager.translate('fifa.groupStanding.win');
$scope.matchWinLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.win');
$scope.matchDrawLabel = fifa.vocManager.translate('fifa.groupStanding.draw');
$scope.matchDrawLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.draw');
$scope.matchLoseLabel = fifa.vocManager.translate('fifa.groupStanding.loss');
$scope.matchLoseLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.loss');
$scope.matchGoalForLabel = fifa.vocManager.translate('fifa.groupStanding.goalFor');
$scope.matchGoalForLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.goalFor');
$scope.matchGoalAgainstLabel = fifa.vocManager.translate('fifa.groupStanding.goalAgainst');
$scope.matchGoalAgainstLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.goalAgainst');
$scope.matchGoalDiffLabel = fifa.vocManager.translate('fifa.groupStandingsGoalDiff');
$scope.matchGoalDiffLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStandingsGoalDiff');
$scope.pointsLabel = fifa.vocManager.translate('fifa.groupStanding.points');
$scope.pointsLabelAbbr = fifa.vocManager.translateAbbr('fifa.groupStanding.points');
$scope.textFullStandings = fifa.vocManager.translateAbbr('fifa.fullstandings');
$scope.groupLabel = fifa.vocManager.translate('fifa.group');
$rootScope.$emit('competition.reloadStandings', $scope.idCup);
};
$scope.GetStandingsData = function () {
middlewareCompetitionsCalls.getCompetitionStandings(function (data) {
$scope.competitionListStandingsData = data.competitionsStanding;
$scope.checkDisplayStandings($scope.competitionListStandingsData, $rootScope);
}, $scope.idCup, $scope.limitDisplay, $http);
};
$scope.replaceTagPlaceHolder = function (text, value) {
return text.replace('{0}', value);
}
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
$rootScope.$on('competition.reloadStandings', function (event, idCup) {
$scope.idCup = idCup;
$scope.GetStandingsData($rootScope);
});
$scope.checkDisplayStandings = function (competitionListStandingsData) {
if (competitionListStandingsData && competitionListStandingsData.length > 0) {
standingsManager.standingsMarkerManageByCompetitionList(competitionListStandingsData);
angular.element(document.querySelector("div[id='standings']")).removeClass('hidden');
angular.element(document.querySelector("div[id='standings'] > div")).removeClass('hidden');
}
fifa.dispatcher.trigger('menu:view:ajaxDiscoverHideableItems');
$rootScope.$emit('app.controllerLoaderManage');
};
$scope.translateFromTemplate = function (tag) {
return fifa.vocManager.translate(tag);
}
$scope.GetTeamLogo = function (team, type, size) {
return matchDataManage.getTeamImage(team, type, size);
};
}]);
;CompetitionPageApp.controller('topScorersController', ['$scope', '$rootScope', '$http', 'middlewareCompetitionsCalls', 'matchDataManage', function ($scope, $rootScope, $http, middlewareCompetitionsCalls, matchDataManage) {
$scope.limitCount = undefined;
$scope.locals = undefined;
$scope.idCup = undefined;
$scope.topScorersList = undefined;
$scope.rankTxt = undefined;
$scope.nameTxt = undefined;
$scope.teamTxt = undefined;
$scope.playersTxt = undefined;
$scope.matchesPlayedTxt = undefined;
$scope.goalsScoredTxt = undefined;
$scope.penaltiesScoredTxt = undefined;
$scope.topScorerTxt = undefined;
$scope.imageSize = undefined;
var initialize = function () {
CompetitionPageApp.initializeTranslate($scope, 'topScorersController');
$scope.imageSize = 3;
$rootScope.$emit('competition.reloadTopScorers', $scope.idCup, $scope.limitCount);
};
$scope.GetTopScorersData = function () {
middlewareCompetitionsCalls.getTopScorers(function (data) {
$scope.topScorersList = data.topScorers;
if ($scope.topScorersList.length) {
$scope.firstTopScorer = $scope.topScorersList[0];
var domTopScorers = document.getElementById('topscorers');
if (domTopScorers) {
domTopScorers.className = domTopScorers.className.replace('hidden', '');
var domDivTopScorers = domTopScorers.querySelector('div');
domDivTopScorers.className = domDivTopScorers.className.replace('hidden', '');
fifa.dispatcher.trigger('menu:view:discoverHideableItems');
}
var i = 0, l = data.topScorers.length;
for (i; i < l; i++) {
var scorer = data.topScorers[i];
if (scorer.matchesPlayed) {
$scope.locals.hasMatchesPlayed = true;
return;
}
}
}
}, $scope.idCup, $scope.limitCount, $http);
};
$scope.GetTeamLogo = function (team, type, size) {
return matchDataManage.getTeamImage(team, type, size);
};
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
$rootScope.$on('competition.reloadTopScorers', function (event, idCup, count) {
$scope.idCup = idCup;
$scope.limitCount = count;
$scope.GetTopScorersData($rootScope);
});
}]);
;CompetitionPageApp.controller('competitionBackController', ['$scope', '$rootScope', '$http', 'utilityManager', 'middlewareCompetitionsCalls', function ($scope, $rootScope, $http, utilityManager, middlewareCompetitionsCalls) {
$scope.locals = undefined;
$scope.idCup = undefined;
$scope.link = undefined;
$scope.label = undefined;
$rootScope.controllerToLoad = $rootScope.controllerToLoad + 1;
var initialize = function () {
var locals = { isMobile: fifa.is_mobile };
$scope.idCup = angular.element(document.querySelector("div[data-context='competition']")).attr("data-idcontext");
middlewareCompetitionsCalls.getCompetitionInfo(function (data) {
if (data && data.competitions.length) {
locals.link = data.competitions[0].link;
locals.label = data.competitions[0].cupName;
$scope.locals = locals;
$scope.$apply();
}
}, $scope.idCup, $http);
$rootScope.$emit('app.controllerLoaderManage');
};
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
}]);
;CompetitionPageApp.controller('sliderMonthController', ['$scope', '$rootScope', '$location', '$timeout', '$http', 'sliderManager', 'middlewareCompetitionsCalls', function ($scope, $rootScope, $location, $timeout, $http, sliderManager, middlewareCompetitionsCalls) {
$scope.idCup = angular.element(document.querySelector("div[data-context='competition']")).attr("data-idcontext");
$scope.listItem = undefined;
$scope.locals = undefined;
var updateFromHash = false;
var initialize = function () {
$scope.locals = { isMobile: fifa.is_mobile };
middlewareCompetitionsCalls.getListMonthWithMatch(function (data) {
$scope.manageListMonth(data);
}, $scope.idCup, $http);
};
$scope.manageListMonth = function (data) {
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
var _hash = $location.hash();
if (_hash && _hash.length > 0 && _hash != null) {
var hashValue = _hash.replace('month', '').split('-');
month = hashValue[0];
year = hashValue[1];
updateFromHash = true;
}
if (data.listItem) {
var activeIdx = -1;
for (i = 0; i < data.listItem.length; i++) {
var item = data.listItem[i];
if (item.secondvalue == year) {
if (item.value == month) {
activeIdx = i;
item.dataType = 'active';
var nextItem = data.listItem[i + 1];
if (nextItem) {
nextItem.dataType = 'next';
}
var prevItem = data.listItem[i - 1];
if (prevItem) {
prevItem.dataType = 'prev';
}
}
}
item.hashValue = item.value + '-' + item.secondvalue;
item.month = item.value;
if ($scope.locals && $scope.locals.isMobile) {
item.value = fifa.vocManager.translateAbbr('fifa.month_' + item.value) + ' ' + item.secondvalue;
} else {
item.value = fifa.vocManager.translate('fifa.month_' + item.value) + ' ' + item.secondvalue;
}
}
if (activeIdx == -1) {
if (data.listItem[0].secondvalue > year) {
data.listItem[0].dataType = 'active';
activeIdx = 0;
year = data.listItem[0].secondvalue;
month = data.listItem[0].month;
var nextItem = data.listItem[1];
if (nextItem) {
nextItem.dataType = 'next';
}
} else if (data.listItem[data.listItem.length - 1].secondvalue < year) {
var ix = data.listItem.length - 1;
data.listItem[ix].dataType = 'active';
activeIdx = ix;
year = data.listItem[ix].secondvalue;
month = data.listItem[ix].month;
var prevItem = data.listItem[ix - 1];
if (prevItem) {
prevItem.dataType = 'prev';
}
} else {
var _monthsYear = _.filter(data.listItem, function (el) {
return el.secondvalue == year;
});
if (_monthsYear) {
var firstMonthYear = _monthsYear[0],
lastIdx = (data.listItem.length > _monthsYear.length ? _monthsYear.length : data.listItem.length) - 1,
lastMonthYear = _monthsYear[lastIdx];
if (firstMonthYear.month > month) {
data.listItem[0].dataType = 'active';
activeIdx = 0;
month = firstMonthYear.month;
var nextItem = data.listItem[1];
if (nextItem) {
nextItem.dataType = 'next';
}
}
else if (lastMonthYear.month < month) {
var listItemIdx = data.listItem.length - 1;
data.listItem[listItemIdx].dataType = 'active';
activeIdx = listItemIdx;
month = lastMonthYear.month;
var prevItem = data.listItem[listItemIdx - 1];
if (prevItem) {
prevItem.dataType = 'prev';
}
}
}
}
}
$scope.listItem = data.listItem;
if ((activeIdx > -1 && updateFromHash) || ((activeIdx === 0 || activeIdx === data.listItem.length - 1) && !updateFromHash)) {
updateFromHash = false;
$timeout(function () {
sliderManager.setUpdateActiveItemPosition(activeIdx - 1, activeIdx, activeIdx + 1);
}, 0);
}
$rootScope.$emit('competitionApp.loadMatchByYearAndMonth', month, year);
}
};
$scope.ClickAction = function ($event, item) {
var month = sliderManager.click($event);
$location.hash('month' + item.hashValue);
var values = item.hashValue.split('-');
$rootScope.$emit('competitionApp.loadMatchByYearAndMonth', values[0], values[1]);
};
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
}]);
CompetitionPageApp.filter('reverse', function () {
return function (items) {
if (items) {
return items;
}
};
});
;CompetitionPageApp.controller('matchFullListController', ['$scope', '$rootScope', 'middlewareCompetitionsCalls', 'matchListManage', '$timeout', '$http', 'matchDataManage', 'middlewareMatchCalls', function ($scope, $rootScope, middlewareCompetitionsCalls, matchListManage, $timeout, $http, matchDataManage, middlewareMatchCalls) {
var enablePollingFeed = true,
dayNow = new Date().getDate();
var _idcup = angular.element(document.querySelector("div[data-context='competition']")).attr("data-idcontext");
$scope.activeYear = null;
$scope.currentYear = new Date().getFullYear();
$scope.enablePolling = false;
$rootScope.controllerToLoad = $rootScope.controllerToLoad + 1;
$scope.matches = undefined;
var initialize = function () {
$scope.textAllMatches = fifa.vocManager.translate('fifa.allMatches');
$scope.locals = { isMobile: fifa.is_mobile };
/*Phase Match*/
$scope.lineupLabel = fifa.vocManager.translate('fifa.lineups');
$scope.halfTimeLabel = fifa.vocManager.translate('fifa.half-time');
$scope.endSecondHalfLabel = fifa.vocManager.translate('fifa.end2ndhalf');
$scope.endFirstExtraLabel = fifa.vocManager.translate('fifa.endfirstextra');
$scope.endSecondExtraLabel = fifa.vocManager.translate('fifa.endsecondextra');
$scope.penaltyLabel = fifa.vocManager.translate('fifa.penaltiesphase');
$scope.fullTimeLabel = fifa.vocManager.translate('fifa.full-time');
$scope.abandonedLabel = fifa.vocManager.translate('fifa.abandonedStatus');
$scope.abandonedLabelAbbr = fifa.vocManager.translateAbbr('fifa.abandonedStatus');
$scope.forfeitedLabelAbbr = fifa.vocManager.translateAbbr('fifa.forfeited');
$scope.forfeitedLabel = fifa.vocManager.translate('fifa.forfeited');
$scope.lineupLabelAbbr = fifa.vocManager.translateAbbr('fifa.lineups');
$scope.halfTimeLabelAbbr = fifa.vocManager.translateAbbr('fifa.half-time');
$scope.endSecondHalfLabelAbbr = fifa.vocManager.translateAbbr('fifa.end2ndhalf');
$scope.endFirstExtraLabelAbbr = fifa.vocManager.translateAbbr('fifa.endfirstextra');
$scope.endSecondExtraLabelAbbr = fifa.vocManager.translateAbbr('fifa.endsecondextra');
$scope.penaltyLabelAbbr = fifa.vocManager.translateAbbr('fifa.penaltiesphase');
$scope.fullTimeLabelAbbr = fifa.vocManager.translateAbbr('fifa.full-time');
$rootScope.$emit('app.controllerLoaderManage');
};
$scope.loadMatches = function (year, month) {
middlewareCompetitionsCalls.getMatchesByYearAndMonth(function (data) {
if (data && data.matches && data.matches.length) {
for (var i = 0; i < data.matches.length; i++) {
matchDataManage.matchDataCreate(data.matches[i], $scope);
}
$scope.matches = data.matches;
if ($scope.activeYear == $scope.currentYear) {
if (!$scope.enablePolling) {
$scope.enablePolling = true;
$scope.loadLiveMatches();
$scope.timedLoadLiveInfo();
}
} else {
if ($scope.enablePolling) {
$scope.enablePolling = false;
$timeout.cancel(_live_info_promise);
}
}
}
}, _idcup, year, month, $http);
};
var _live_info_promise = null;
$scope.timedLoadLiveInfo = function () {
if (_live_info_promise) {
$timeout.cancel(_live_info_promise);
$scope.loadLiveMatches();
}
_live_info_promise = $timeout($scope.timedLoadLiveInfo, '10000'.withRandomShift());
};
$scope.loadLiveMatches = function () {
middlewareMatchCalls.getLiveMatches(function (data) {
var i = 0, l = $scope.matches.length;
for (i; i < l; i++) {
var _match = $.extend({}, $scope.matches[i]);
var _seasonMatch = data[_match.idCupSeason];
if (_seasonMatch) {
var _matchLiveData = _.find(_seasonMatch.matchlist, function (match) {
return match.id == _match.idMatch;
});
if (_matchLiveData) {
matchDataManage.LiveMatchDataMerge(_match, _matchLiveData, $scope);
$scope.matches[i] = _match;
}
}
}
}, $http);
}
$rootScope.$on('competitionApp.loadMatchByYearAndMonth', function (ev, month, year) {
if (month && year) {
$scope.activeYear = year;
$scope.loadMatches(year, month);
}
});
$rootScope.$on('FinishLoadFifaConfig', function () {
initialize();
});
$scope.GetTeamLogo = function (team, type, size) {
return matchDataManage.getTeamImage(team, type, size);
};
}]);