import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { DashboardService } from 'src/app/services/dashboard.service';
import { SharedService, SITE_PERMISSION_CODE, APIStautusCode } from 'src/app/services/shared.service';
import { Router } from '@angular/router';
import { WebSocketService } from 'src/app/services/websocket-service.service';
import { environment } from 'src/environments/environment';
import { NgxSpinnerService } from 'ngx-spinner';
import * as $ from 'jquery';
selector: 'app-landing-page',
templateUrl: './landing-page.component.html',
styleUrls: ['./landing-page.component.styl']
export class LandingPageComponent implements OnInit, OnDestroy {
slideConfigForThirdPartyGame = {};
thirdPartyGames: any[] = [];
casinoGameList: any[] = [];
selectedSportDetailForFilter: { SportId: any, SportName: string } = { SportId: null, SportName: null };
private dashboardService: DashboardService,
public sharedService: SharedService,
private webSocketService: WebSocketService,
private spinner: NgxSpinnerService
if (this.sharedService.getAuthorizationToken()) {
this.router.navigate(['/dashboard']);
this.getLandingPageDetail();
this.intializationThirdPartyGames();
this.slideConfigForThirdPartyGame = {
this.sharedService.reCaptchaUserKey = '';
this.sharedService.getNewUserCaptcha.next({ isFirstTime: true });
changeSelectedSportTab(sportData) {
if (this.selectedSportDetailForFilter.SportId != sportData.SportOrGameId) {
this.selectedSportDetailForFilter.SportId = sportData.SportOrGameId;
this.selectedSportDetailForFilter.SportName = sportData.Name;
this.highlights = this.allHighlights.filter(x => x.SportId == sportData.SportOrGameId || sportData.SportOrGameId == null);
const t1 = setTimeout(() => {
$('html, body').animate({
scrollTop: $('.games-highlights').offset().top
setupViewport(ticker, tickerItem) {
const itemCount = $(tickerItem).length;
ticker.find(tickerItem).clone().prependTo('[data-ticker="list"]');
ticker.find(tickerItem).clone().prependTo('[data-ticker="list"]');
for (let i = 0; i < itemCount; i++) {
const itemWidth = $(tickerItem).eq(i).outerWidth();
this.tikerViewportWidth = this.tikerViewportWidth + itemWidth;
ticker.css('width', this.tikerViewportWidth);
marginLeft: -this.tikerViewportWidth
}, 10000, 'linear', () => {
ticker.css('margin-left', '0');
this.animateTicker(ticker);
const ticker = $('[data-ticker="list"]');
const tickerItem = '[data-ticker="item"]';
this.tikerViewportWidth = 0;
if (ticker && ticker.length > 0) {
this.setupViewport(ticker, tickerItem);
this.animateTicker(ticker);
ticker.on('mouseenter', function () {
}).on('mouseout', () => {
this.animateTicker(ticker);
{ img: '/assets/images/top-slider/1.png' },
{ img: '/assets/images/top-slider/2.png' },
intializationThirdPartyGames() {
{ Image: '/assets/images/binary.jpg', link: '#', Name: '' },
{ Image: '/assets/images/lotteryclub.jpg', link: '#', Name: '' },
{ Image: '/assets/images/super-spades-games.jpg', link: '#', Name: '' },
this.webSocketService.send({ action: 'unset', markets: this.centralId });
const menuItem = this.sharedService.menuItem || (localStorage.getItem('MenuItem') ? JSON.parse(atob(localStorage.getItem('MenuItem'))) : []);
SportGames = menuItem.filter(x => {
if (x.SportOrGameId == null) {
x.Image = 'assets/images/home-icon.png';
return ((x.SportOrGameId !== 0 && x.SportOrGameId > 0) || x.SportOrGameId == null);
const menuItem = this.sharedService.menuItem || (localStorage.getItem('MenuItem') ? JSON.parse(atob(localStorage.getItem('MenuItem'))) : []);
casinoGames = menuItem.filter(x => x.SportOrGameId !== 0 && x.SportOrGameId != null && x.SportOrGameId < 0);
async getLandingPageDetail() {
await this.dashboardService.getLandingPageDetail().subscribe(({ LandingPageData, Status, VeronicaGameList }) => {
if (LandingPageData && Status && Status.code === 0) {
this.casinoGameList = VeronicaGameList && VeronicaGameList.Status && VeronicaGameList.Status.code == 0 ? VeronicaGameList.GameList : [];
this.count = LandingPageData.Count;
this.allHighlights = LandingPageData.Highlights;
this.highlights = JSON.parse(JSON.stringify(this.allHighlights));
const commonSettings = LandingPageData.CommonSettings;
this.sharedService.sitePermissionForWeb = LandingPageData.SiteHasExteralSitePermission;
localStorage.setItem(btoa('SiteHasExteralSitePermission'), btoa(LandingPageData.SiteHasExteralSitePermission));
this.sharedService.sitePermissionForUser = this.sharedService.sitePermissionForWeb;
const objOfClientSideRegisterAllow = commonSettings.find(x => x.Key.toLowerCase() == 'isclientssideregistration');
const objOfPaytmAllow = commonSettings.find(x => x.Key.toLowerCase() == 'isdepositallow');
const objOfRazorPayAllow = commonSettings.find(x => x.Key.toLowerCase() == 'iswithdrawalallow');
this.sharedService.isClientsSideRegistrationAllow = Boolean(Number(objOfClientSideRegisterAllow.Value));
this.sharedService.isDepositAllow = Boolean(Number(objOfPaytmAllow.Value));
this.sharedService.isWithdrawalAllow = Boolean(Number(objOfRazorPayAllow.Value));
if (this.highlights && this.highlights.length > 0) {
const centralIdList = [];
this.highlights.map(e => e.Match.map(ele => centralIdList.push(ele.CentralId)));
this.centralId = centralIdList.join();
this.sharedService.showToastr(2, Status.returnMessage);
if (this.webSocketService.isConected()) {
this.webSocketService.onClose().then((e) => {
this.webSocketService.connect((data) => {
this.webSocketService.onClose().then((e) => {
this.webSocketService.connect((data) => {
this.webSocketService.onClose().then((e) => {
this.webSocketService.connect((data) => {
this.webSocketService.onClose().then((e) => {
if (environment.isShowLog) { console.log('Error in Socket Connect'); }
const obj = { action: 'set', markets: this.centralId };
this.webSocketService.send(obj, ({ data }) => {
if (data && data.length > 0) {
const marketData = JSON.parse(data);
if (marketData && marketData.length > 0 && marketData[0].appRate) {
const appRate = JSON.parse(marketData[0].appRate);
const runners = this.sharedService.groupBy(appRate, 'appSelectionID_BF');
for (const runnerId in runners) {
if (runners.hasOwnProperty(runnerId)) {
const rates = runners[runnerId];
const backRate = rates.filter((e) => e.appIsBack === true).map((e) => e.appRate);
const layRate = rates.filter((e) => e.appIsBack === false).map((e) => e.appRate);
this.highlights.forEach(sport => {
sport.Match.forEach(market => {
if (market.CentralId && market.CentralId == marketData[0].appMarketID) {
market.Runner.forEach(runner => {
if (runner.BfRunnerId === Number(runnerId)) {
runner.backRate = backRate && backRate.length > 0 ? backRate[0] : '-';
runner.layRate = layRate && layRate.length > 0 ? layRate[0] : '-';
showPleaseLoginWarning() {
this.sharedService.showToastr(APIStautusCode.Warning, 'Please Login to Continue');