PageSourceSearch

https://arubafc.com/wp-content/plugins/apifootball/js/jquery.widgetMatchResults.js?ver=1.0

js arubafc.com collected 2026-10-03 18:20:53 UTC 191,772 bytes, 2,147 lines download raw bytes

1// ---------------------------------
2// ---------- widgetMatchResults ----------
3// ---------------------------------
4// Widget for MatchResults Display
5// ------------------------
6;
7(function($, window, document, undefined) {
8
9    var widgetMatchResults = 'widgetMatchResults';
10
11    function Plugin(element, options) {
12        this.element = element;
13        this._name = widgetMatchResults;
14        this._defaults = $.fn.widgetMatchResults.defaults;
15        this.options = $.extend({}, this._defaults, options);
16
17        this.init();
18    }
19
20    $.extend(Plugin.prototype, {
21
22        // Initialization logic
23        init: function() {
24            this.buildCache();
25            this.bindEvents();
26            this.initialContent(this.options.matchResultsDetailsAjaxURL, this.options.match_id, this.options.action, this.options.Widgetkey, this.options.leagueLogo);
27            socketsLive(this.options.match_id, this.options.Widgetkey);
28        },
29
30        // Remove plugin instance completely
31        destroy: function() {
32            this.unbindEvents();
33            this.$element.removeData();
34        },
35
36        // Cache DOM nodes for performance
37        buildCache: function() {
38            this.$element = $(this.element);
39        },
40
41        // Bind events that trigger actions
42        bindEvents: function() {
43            var plugin = this;
44        },
45
46        // Unbind events that trigger actions
47        unbindEvents: function() {
48            this.$element.off('.' + this._name);
49        },
50
51        initialContent: function(matchResultsDetailsAjaxURL, match_id, action, Widgetkey, leagueLogo) {
52
53            // Get widget location
54            var matchResultsLocation = $(this.element);
55
56             // Adding the "widgetMatchResults" class for styling and easyer targeting
57            matchResultsLocation.addClass('widgetMatchResults');
58
59            // If backgroundColor setting is set, here we activate the color
60            if (this.options.backgroundColor) {
61                matchResultsLocation.css('background-color', this.options.backgroundColor);
62            }
63
64            // If widgetWidth setting is set, here we set the width of the list
65            if (this.options.widgetWidth) {
66                matchResultsLocation.css('width', this.options.widgetWidth);
67            }
68
69            // We send a request to server for Match infos
70            $.ajax({
71                url: matchResultsDetailsAjaxURL,
72                cache: false,
73                data: {
74                    action: action,
75                    Widgetkey: Widgetkey,
76                    match_id: match_id,
77                    from: sessionStorage.getItem('fixturesDate'),
78                    to: sessionStorage.getItem('fixturesDate'),
79                    timezone: getTimeZone()
80                },
81                dataType: 'json'
82            }).done(function(res) {
83                // If server send results we populate HTML with sended information
84                if (!res.error) {
85
86                    // Check if we get the time
87                    var seeWhatMatchDetailsToShow = setInterval(function() {
88                        if (timeForFixtures.length > 0) {
89                            // If date is in local storage or event status dose not exist we show predefined HTML
90                            if ((sessionStorage.getItem('fixturesDate') > timeForFixtures) || ((res[0].match_status == null) || (res[0].match_status === ''))) {
91                                // Hide loading screen
92                                $('.loading').hide();
93                                // Details for match
94                                var otherMatchDetails = '<div class="otherMatchDetails">';
95                                otherMatchDetails += '<div class="otherMatchDetailsInfos">';
96                                otherMatchDetails += '<div class="leagueImg" style="background-image: url(\'' + (((leagueLogo == '') || (leagueLogo == 'null') || (leagueLogo == null) || (leagueLogo == 'https://apiv3.apifootball.com/badges/logo_leagues/-1')) ? 'img/no-img.png' : leagueLogo) + '\');"></div>';
97                                otherMatchDetails += '<div>' + res[0].country_name + ': ' + res[0].league_name + '</div>';
98                                otherMatchDetails += '</div>';
99                                var formattedDate = new Date(res[0].match_date + "T00:00");
100                                var d = formattedDate.getDate();
101                                var m = formattedDate.getMonth() + 1;
102                                var y = formattedDate.getFullYear();
103                                otherMatchDetails += '<div>' + (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + '.' + y + ' ' + res[0].match_time + '</div>';
104                                otherMatchDetails += '</div>';
105                                $(matchResultsLocation).prepend(otherMatchDetails);
106
107                                // Add hook in HTML for Match Results Tab content infos
108                                $(matchResultsLocation).append('<section id="matchResultsContentTable"></section>');
109                                var htmlConstructor = '<div id="matchResultsDates">';
110                                htmlConstructor += '<div id="matchResultsDatesTitle">';
111                                if (!res.error) {
112                                    htmlConstructor += '<div class="match_hometeam_name">';
113                                    htmlConstructor += '<div class="match_hometeam_name_part">';
114                                    htmlConstructor += '<div class="match_hometeam_name_part_img">';
115                                    htmlConstructor += '<div class="image-style-for-flag" style="background-image: url(\'' + ((!res[0].team_home_badge) ? 'img/no-img.png' : ((res[0].team_home_badge == '') ? 'img/no-img.png' : res[0].team_home_badge)) + '\');"></div>';
116                                    htmlConstructor += '</div>';
117                                    htmlConstructor += '<div class="match_hometeam_name_part_name">';
118                                    htmlConstructor += '<div>' + res[0].match_hometeam_name + '</div>';
119                                    htmlConstructor += '</div>';
120                                    htmlConstructor += '</div>';
121                                    htmlConstructor += '<div class="event_info">';
122                                    htmlConstructor += '<div class="event_info_score">';
123                                    htmlConstructor += '<div>-</div>';
124                                    htmlConstructor += '</div>';
125                                    htmlConstructor += '<div class="event_info_status">';
126                                    htmlConstructor += '<div>' + ((res[0].match_status) ? res[0].match_status : '') + '</div>';
127                                    htmlConstructor += '</div>';
128                                    htmlConstructor += '</div>';
129                                    htmlConstructor += '<div class="match_awayteam_name_part">';
130                                    htmlConstructor += '<div class="match_awayteam_name_part_img">';
131                                    htmlConstructor += '<div class="image-style-for-flag" style="background-image: url(\'' + ((!res[0].team_away_badge) ? 'img/no-img.png' : ((res[0].team_away_badge == '') ? 'img/no-img.png' : res[0].team_away_badge)) + '\');"></div>';
132                                    htmlConstructor += '</div>';
133                                    htmlConstructor += '<div class="match_awayteam_name_part_name">';
134                                    htmlConstructor += '<div>' + res[0].match_awayteam_name + '</div>';
135                                    htmlConstructor += '</div>';
136                                    htmlConstructor += '</div>';
137                                    htmlConstructor += '</div>';
138                                }
139                                htmlConstructor += '</div>';
140                                htmlConstructor += '<div class="nav-tab-wrapper-all">';
141                                htmlConstructor += '<ul class="nav-tab-wrapper-all-container">';
142                                htmlConstructor += '<li><span><a href="#matchSummary" class="matchResults-h2 nav-tab nav-tab-active">Match Summary</a></span></li>';
143                                htmlConstructor += '<li><span><a href="#matchOdds" class="matchResults-h2 nav-tab d-none-tab-odds">Odds</a></span></li>';
144                                htmlConstructor += '<li><span><a href="#matchPredictions" class="matchResults-h2 nav-tab d-none-tab-prediction">Predictions</a></span></li>';
145                                htmlConstructor += '</ul>';
146                                htmlConstructor += '</div>';
147                                htmlConstructor += '<section id="matchSummary" class="tab-content active">';
148                                htmlConstructor += '<div class="tab-container futureMatch">';
149                                htmlConstructor += '<p>No live score information available now.</p>';
150                                htmlConstructor += '</div>';
151                                htmlConstructor += '</section>';
152
153                                // Populate Match Odds section
154                                htmlConstructor += '<section id="matchOdds" class="tab-content">';
155                                htmlConstructor += '<div class="tab-container">';
156
157                                // Send server request for Standings
158                                $.ajax({
159                                    url: matchResultsDetailsAjaxURL,
160                                    cache: false,
161                                    data: {
162                                        action: 'get_odds',
163                                        Widgetkey: Widgetkey,
164                                        from: sessionStorage.getItem('fixturesDate'),
165                                        to: sessionStorage.getItem('fixturesDate'),
166                                        match_id: res[0].match_id
167                                    },
168                                    dataType: 'json'
169                                }).done(function(res) {
170
171                                    // If server send results hide loading
172                                    $('.loading').hide();
173
174                                    if(!res.error){
175
176                                        $('.d-none-tab-odds').removeClass('d-none-tab-odds');
177
178                                        var htmlInsideTabsConstructorO = '<div class="nav-tab-wrapper">';
179                                        var htmlConstructorO = '<a href="#1x2" class="standing-h2 nav-tab nav-tab-active">1x2</a>';
180                                        htmlConstructorO += '<a href="#ah" class="standing-h2 nav-tab">Asian Handicap</a>';
181                                        htmlConstructorO += '<a href="#ou" class="standing-h2 nav-tab">O/U</a>';
182                                        htmlConstructorO += '<a href="#bts" class="standing-h2 nav-tab">BTS</a>';
183
184                                        htmlInsideTabsConstructorO += '<section id="1x2" class="tab-content active">';
185                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
186                                        htmlInsideTabsConstructorO += '<div class="flex-table header" role="rowgroup">';
187                                        htmlInsideTabsConstructorO += '<div title="Bookmakers" class="flex-row bookmakers" role="columnheader">Bookmakers</div>';
188                                        htmlInsideTabsConstructorO += '<div title="1" class="flex-row oddWidth" role="columnheader">1</div>';
189                                        htmlInsideTabsConstructorO += '<div title="X" class="flex-row oddWidth" role="columnheader">X</div>';
190                                        htmlInsideTabsConstructorO += '<div title="2" class="flex-row oddWidth" role="columnheader">2</div>';
191                                        htmlInsideTabsConstructorO += '</div>';
192                                        htmlInsideTabsConstructorO += '<div class="table__body">';
193                                        var onextwo = '';
194                                        htmlInsideTabsConstructorO += '</div>';
195                                        htmlInsideTabsConstructorO += '</div>';
196                                        htmlInsideTabsConstructorO += '</section>';
197
198                                        htmlInsideTabsConstructorO += '<section id="ou" class="tab-content">';
199                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
200                                        htmlInsideTabsConstructorO += '</div>';
201                                        htmlInsideTabsConstructorO += '</section>';
202
203                                        htmlInsideTabsConstructorO += '<section id="bts" class="tab-content">';
204                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
205                                        htmlInsideTabsConstructorO += '<div class="flex-table header" role="rowgroup">';
206                                        htmlInsideTabsConstructorO += '<div title="Bookmakers" class="flex-row bookmakers" role="columnheader">Bookmakers</div>';
207                                        htmlInsideTabsConstructorO += '<div title="Yes" class="flex-row oddWidth" role="columnheader">Yes</div>';
208                                        htmlInsideTabsConstructorO += '<div title="No" class="flex-row oddWidth" role="columnheader">No</div>';
209                                        htmlInsideTabsConstructorO += '</div>';
210                                        htmlInsideTabsConstructorO += '<div class="table__body">';
211                                        var btsyesno = '';
212                                        htmlInsideTabsConstructorO += '</div>';
213                                        htmlInsideTabsConstructorO += '</div>';
214                                        htmlInsideTabsConstructorO += '</section>';
215
216                                        htmlInsideTabsConstructorO += '<section id="ah" class="tab-content">';
217                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
218                                        htmlInsideTabsConstructorO += '</div>';
219                                        htmlInsideTabsConstructorO += '</section>';
220
221                                        var ahminus45 = [], ahminus4 = [], ahminus35 = [], ahminus3 = [], ahminus25 = [], ahminus2 = [], ahminus15 = [], ahminus1 
221= [], ahminus05 = [], ah0 = [], ahplus05 = [], ahplus1 = [], ahplus15 = [], ahplus2 = [], ahplus25 = [], ahplus3 = [], ahplus35 = [], ahplus4 = [], ahplus45 = [], ou05 = [], ou1 = [], ou15 = [], ou2 = [], ou25 = [], ou3 = [], ou35 = [], ou4 = [], ou45 = [], ou5 = [], ou55 = [];
222
223                                        var asianHandicapArray = {
224                                            'ah-4.5' : ahminus45 = [],
225                                            'ah-4' : ahminus4 = [],
226                                            'ah-3.5' : ahminus35 = [],
227                                            'ah-3' : ahminus3 = [],
228                                            'ah-2.5' : ahminus25 = [],
229                                            'ah-2' : ahminus2 = [],
230                                            'ah-1.5' : ahminus15 = [],
231                                            'ah-1' : ahminus1 = [],
232                                            'ah-0.5' : ahminus05 = [],
233                                            'ah-0' : ah0 = [],
234                                            'ah+0.5' : ahplus05 = [],
235                                            'ah+1' : ahplus1 = [],
236                                            'ah+1.5' : ahplus15 = [],
237                                            'ah+2' : ahplus2 = [],
238                                            'ah+2.5' : ahplus25 = [],
239                                            'ah+3' : ahplus3 = [],
240                                            'ah+3.5' : ahplus35 = [],
241                                            'ah+4' : ahplus4 = [],
242                                            'ah+4.5' : ahplus45 = [],
243                                        };
244
245                                        var overUnderArray = {
246                                            '0.5' : ou05 = [],
247                                            '1' : ou1 = [],
248                                            '1.5' : ou15 = [],
249                                            '2' : ou2 = [],
250                                            '2.5' : ou25 = [],
251                                            '3' : ou3 = [],
252                                            '3.5' : ou35 = [],
253                                            '4' : ou4 = [],
254                                            '4.5' : ou45 = [],
255                                            '5' : ou5 = [],
256                                            '5.5' : ou55 = [],
257                                        };
258
259                                        $.each(res, function(key, value) {
260
261                                            if(value['odd_1'] !== '' || value['odd_x'] !== '' || value['odd_2'] !== '') {
262                                                onextwo += '<div class="flex-table row" role="rowgroup">';
263                                                onextwo += '<div class="flex-row bookmakers" role="cell">' + ((typeof value.odd_bookmakers != 'undefined') ? value.odd_bookmakers : '' ) + '</div>';
264                                                onextwo += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.odd_1 != 'undefined') ? value.odd_1 : '' ) + '</div>';
265                                                onextwo += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.odd_x != 'undefined') ? value.odd_x : '' ) + '</div>';
266                                                onextwo += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.odd_2 != 'undefined') ? value.odd_2 : '' ) + '</div>';
267                                                onextwo += '</div>';
268                                            }
269
270                                            if(value['bts_no'] !== '' || value['bts_yes'] !== '') {
271                                                btsyesno += '<div class="flex-table row" role="rowgroup">';
272                                                btsyesno += '<div class="flex-row bookmakers" role="cell">' + ((typeof value.odd_bookmakers != 'undefined') ? value.odd_bookmakers : '' ) + '</div>';
273                                                btsyesno += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.bts_yes != 'undefined') ? value.bts_yes : '' ) + '</div>';
274                                                btsyesno += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.bts_no != 'undefined') ? value.bts_no : '' ) + '</div>';
275                                                btsyesno += '</div>';
276                                            }
277
278                                            $.each(asianHandicapArray, function(key, values) {
279                                                if((typeof value[key + '_1'] !== 'undefined' && value[key + '_1'] !== '') || (typeof value[key + '_2'] !== 'undefined' && value[key + '_2'] !== '')){
280                                                    whatToPush(values, value.odd_bookmakers, value[key + '_1'], value[key + '_2']);
281                                                }
282                                            });
283
284                                            $.each(overUnderArray, function(key, values) {
285                                                if((typeof value['o+' + key] !== 'undefined' && value['o+' + key] !== '') || (typeof value['u+' + key] !== 'undefined' && value['u+' + key] !== '')){
286                                                    whatToPush(values, value.odd_bookmakers, value['o+' + key], value['u+' + key]);
287                                                }
288                                            });
289
290                                        });
291
292                                        var asianHandicapData = {
293                                            "Asian handicap -4.5" : ahminus45,
294                                            "Asian handicap -4" : ahminus4,
295                                            "Asian handicap -3.5" : ahminus35,
296                                            "Asian handicap -3" : ahminus3,
297                                            "Asian handicap -2.5" : ahminus25,
298                                            "Asian handicap -2" : ahminus2,
299                                            "Asian handicap -1.5" : ahminus15,
300                                            "Asian handicap -1" : ahminus1,
301                                            "Asian handicap -0.5" : ahminus05,
302                                            "Asian handicap 0" : ah0,
303                                            "Asian handicap +0.5" : ahplus05,
304                                            "Asian handicap +1" : ahplus1,
305                                            "Asian handicap +1.5" : ahplus15,
306                                            "Asian handicap +2" : ahplus2,
307                                            "Asian handicap +2.5" : ahplus25,
308                                            "Asian handicap +3" : ahplus3,
309                                            "Asian handicap +3.5" : ahplus35,
310                                            "Asian handicap +4" : ahplus4,
311                                            "Asian handicap +4.5" : ahplus45
312                                        };
313
314                                        var allHandicaps = '';
315
316                                        $.each(asianHandicapData, function(key, value) {
317                                            if(value != ''){
318                                                allHandicaps += '<div class="flex-table header" role="rowgroup">';
319                                                allHandicaps += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
320                                                allHandicaps += '<div title="Home" class="flex-row oddWidth" role="columnheader">Home</div>';
321                                                allHandicaps += '<div title="Away" class="flex-row oddWidth" role="columnheader">Away</div>';
322                                                allHandicaps += '</div>';
323                                                allHandicaps += '<div class="table__body">';
324                                                $.each(value, function(keys, values) {
325                                                    allHandicaps += '<div class="flex-table row" role="rowgroup">';
326                                                    allHandicaps += '<div class="flex-row bookmakers" role="cell">' + values.bookmaker + '</div>';
327                                                    allHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.one + '</div>';
328                                                    allHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.two + '</div>';
329                                                    allHandicaps += '</div>';
330                                                });
331                                                allHandicaps += '</div>';
332                                            }
333                                        });
334
335                                        var ouData = {
336                                            "Over/Under +0.5" : ou05,
337                                            "Over/Under +1" : ou1,
338                                            "Over/Under +1.5" : ou15,
339                                            "Over/Under +2" : ou2,
340                                            "Over/Under +2.5" : ou25,
341                                            "Over/Under +3" : ou3,
342                                            "Over/Under +3.5" : ou35,
343                                            "Over/Under +4" : ou4,
344                                            "Over/Under +4.5" : ou45,
345                                            "Over/Under +5" : ou5,
346                                            "Over/Under +5.5" : ou55
347                                        };
348
349                                        var allou = '';
350
351                                        $.each(ouData, function(key, value) {
352                                            if(value != ''){
353                                                allou += '<div class="flex-table header" role="rowgroup">';
354                                                allou += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
355                                                allou += '<div title="Over" class="flex-row oddWidth" role="columnheader">Over</div>';
356                                                allou += '<div title="Under" class="flex-row oddWidth" role="columnheader">Under</div>';
357                                                allou += '</div>';
358                                                allou += '<div class="table__body">';
359                                                $.each(value, function(keys, values) {
360                                                    allou += '<div class="flex-table row" role="rowgroup">';
361                                                    allou += '<div class="flex-row bookmakers" role="cell">' + values.bookmaker + '</div>';
362                                                    allou += '<div class="flex-row oddWidth" role="cell">' + values.one + '</div>';
363                                                    allou += '<div class="flex-row oddWidth" role="cell">' + values.two + '</div>';
364                                                    allou += '</div>';
365                                                });
366                                                allou += '</div>';
367                                            }
368                                        });
369
370                                        htmlInsideTabsConstructorO += '</div>';
371                                        $('#matchOdds .tab-container').append(htmlInsideTabsConstructorO);
372                                        $('#matchOdds .nav-tab-wrapper').prepend(htmlConstructorO);
373
374                                        if(onextwo.length > 0){
375                                            $('#1x2 .tablele-container .table__body').append(onextwo);
376                                        } else {
377                                            $('#1x2 .tablele-container .table__body').append('<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>');
378                                        }
379
380                                        if(btsyesno.length > 0){
381                                            $('#bts .tablele-container .table__body').append(btsyesno);
382                                        } else {
383                                            $('#bts .tablele-container .table__body').append('<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>');
384                                        }
385
386                                        if(allHandicaps.length > 0){
387                                            $('#ah .tablele-container').append(allHandicaps);
388                                        } else {
389                                            $('#ah .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Asian handicap" class="flex-row bookmakers" role="columnheader">Asian handicap</div><div title="1" class="flex-row oddWidth" role="columnheader">1</div><div title="2" class="flex-row oddWidth" role="columnheader">2</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
390                                        }
391
392                                        if(allou.length > 0){
393                                            $('#ou .tablele-container').append(allou);
394                                        } else {
395                                            $('#ou .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Over/Under" class="flex-row bookmakers" role="columnheader">Over/Under</div><div title="Over" class="flex-row oddWidth" role="columnheader">Over</div><div title="Under" class="flex-row oddWidth" role="columnheader">Under</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
396                                        }
397
398                                        // Switching tabs on click
399                                        $('#matchOdds .nav-tab').unbind('click').on('click', function(e) {
400                                            e.preventDefault();
401                                            //Toggle tab link
402                                            $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
403                                            //Toggle target tab
404                                            $($(this).attr('href')).addClass('active').siblings().removeClass('active');
405                                        });
406                                    } else {
407                                        $('#matchOdds .tab-container').addClass('lineForNoData').prepend('<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>');
408                                    }
409                                });
410                                htmlConstructor += '</div>';
411                                htmlConstructor += '</section>';
412
413                                // Populate Match Prediction section
414                                htmlConstructor += '<section id="matchPredictions" class="tab-content">';
415                                htmlConstructor += '<div class="tab-container">';
416
417                                // Send server request for Standings
418                                $.aja
418x({
419                                    url: matchResultsDetailsAjaxURL,
420                                    cache: false,
421                                    data: {
422                                        action: 'get_predictions',
423                                        Widgetkey: Widgetkey,
424                                        from: sessionStorage.getItem('fixturesDate'),
425                                        to: sessionStorage.getItem('fixturesDate'),
426                                        match_id: res[0].match_id
427                                    },
428                                    dataType: 'json'
429                                }).done(function(res) {
430
431                                    // If server send results hide loading
432                                    $('.loading').hide();
433
434                                    if(!res.error){
435
436                                        $('.d-none-tab-prediction').removeClass('d-none-tab-prediction');
437
438                                        var htmlInsideTabsConstructorP = '<div class="nav-tab-wrapper">';
439                                        var htmlConstructorO = '<a href="#p1x2" class="standing-h2 nav-tab nav-tab-active">1x2</a>';
440                                        htmlConstructorO += '<a href="#pdc" class="standing-h2 nav-tab">Double Chance</a>';
441                                        htmlConstructorO += '<a href="#pah" class="standing-h2 nav-tab">Asian Handicap</a>';
442                                        htmlConstructorO += '<a href="#pou" class="standing-h2 nav-tab">O/U</a>';
443                                        htmlConstructorO += '<a href="#pbts" class="standing-h2 nav-tab">BTS</a>';
444
445                                        htmlInsideTabsConstructorP += '<section id="p1x2" class="tab-content active">';
446                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
447                                        htmlInsideTabsConstructorP += '<div class="flex-table header" role="rowgroup">';
448                                        htmlInsideTabsConstructorP += '<div title="" class="flex-row bookmakers" role="columnheader"></div>';
449                                        htmlInsideTabsConstructorP += '<div title="1" class="flex-row oddWidth" role="columnheader">1</div>';
450                                        htmlInsideTabsConstructorP += '<div title="X" class="flex-row oddWidth" role="columnheader">X</div>';
451                                        htmlInsideTabsConstructorP += '<div title="2" class="flex-row oddWidth" role="columnheader">2</div>';
452                                        htmlInsideTabsConstructorP += '</div>';
453                                        htmlInsideTabsConstructorP += '<div class="table__body">';
454                                        if(res[0]['prob_HW'] !== '' || res[0]['prob_D'] !== '' || res[0]['prob_AW'] !== '') {
455                                            htmlInsideTabsConstructorP += '<div class="flex-table row" role="rowgroup">';
456                                            htmlInsideTabsConstructorP += '<div class="flex-row bookmakers" role="cell">Chance</div>';
457                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_HW != 'undefined') ? res[0].prob_HW : '' ) + '</div>';
458                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_D != 'undefined') ? res[0].prob_D : '' ) + '</div>';
459                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_AW != 'undefined') ? res[0].prob_AW : '' ) + '</div>';
460                                            htmlInsideTabsConstructorP += '</div>';
461                                        } else {
462                                            htmlInsideTabsConstructorP += '<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>';
463                                        }
464                                        htmlInsideTabsConstructorP += '</div>';
465                                        htmlInsideTabsConstructorP += '</div>';
466                                        htmlInsideTabsConstructorP += '</section>';
467
468                                        htmlInsideTabsConstructorP += '<section id="pdc" class="tab-content">';
469                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
470                                        htmlInsideTabsConstructorP += '<div class="flex-table header" role="rowgroup">';
471                                        htmlInsideTabsConstructorP += '<div title="" class="flex-row bookmakers" role="columnheader"></div>';
472                                        htmlInsideTabsConstructorP += '<div title="1" class="flex-row oddWidth" role="columnheader">1</div>';
473                                        htmlInsideTabsConstructorP += '<div title="X" class="flex-row oddWidth" role="columnheader">X</div>';
474                                        htmlInsideTabsConstructorP += '<div title="2" class="flex-row oddWidth" role="columnheader">2</div>';
475                                        htmlInsideTabsConstructorP += '</div>';
476                                        htmlInsideTabsConstructorP += '<div class="table__body">';
477                                        if(res[0]['prob_HW_D'] !== '' || res[0]['prob_HW_AW'] !== '' || res[0]['prob_AW_D'] !== '') {
478                                            htmlInsideTabsConstructorP += '<div class="flex-table row" role="rowgroup">';
479                                            htmlInsideTabsConstructorP += '<div class="flex-row bookmakers" role="cell">Chance</div>';
480                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_HW_D != 'undefined') ? res[0].prob_HW_D : '' ) + '</div>';
481                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_HW_AW != 'undefined') ? res[0].prob_HW_AW : '' ) + '</div>';
482                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_AW_D != 'undefined') ? res[0].prob_AW_D : '' ) + '</div>';
483                                            htmlInsideTabsConstructorP += '</div>';
484                                        } else {
485                                            htmlInsideTabsConstructorP += '<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>';
486                                        }
487                                        htmlInsideTabsConstructorP += '</div>';
488                                        htmlInsideTabsConstructorP += '</div>';
489                                        htmlInsideTabsConstructorP += '</section>';
490
491                                        htmlInsideTabsConstructorP += '<section id="pah" class="tab-content">';
492                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
493
494                                        var pasianHandicapData = {
495                                            "Asian handicap -4.5" : [{
496                                                home : res[0]['prob_ah_h_-45'],
497                                                away : res[0]['prob_ah_a_-45']
498                                            }],
499                                            "Asian handicap -3.5" : [{
500                                                home : res[0]['prob_ah_h_-35'],
501                                                away : res[0]['prob_ah_a_-35']
502                                            }],
503                                            "Asian handicap -2.5" : [{
504                                                home : res[0]['prob_ah_h_-25'],
505                                                away : res[0]['prob_ah_a_-25']
506                                            }],
507                                            "Asian handicap -1.5" : [{
508                                                home : res[0]['prob_ah_h_-15'],
509                                                away : res[0]['prob_ah_a_-15']
510                                            }],
511                                            "Asian handicap -0.5" : [{
512                                                home : res[0]['prob_ah_h_-05'],
513                                                away : res[0]['prob_ah_a_-05']
514                                            }],
515                                            "Asian handicap +0.5" : [{
516                                                home : res[0]['prob_ah_h_05'],
517                                                away : res[0]['prob_ah_a_05']
518                                            }],
519                                            "Asian handicap +1.5" : [{
520                                                home : res[0]['prob_ah_h_15'],
521                                                away : res[0]['prob_ah_a_15']
522                                            }],
523                                            "Asian handicap +2.5" : [{
524                                                home : res[0]['prob_ah_h_25'],
525                                                away : res[0]['prob_ah_a_25']
526                                            }],
527                                            "Asian handicap +3.5" : [{
528                                                home : res[0]['prob_ah_h_35'],
529                                                away : res[0]['prob_ah_a_35']
530                                            }],
531                                            "Asian handicap +4.5" : [{
532                                                home : res[0]['prob_ah_h_45'],
533                                                away : res[0]['prob_ah_a_45']
534                                            }]
535                                        };
536
537                                        var pallHandicaps = '';
538
539                                        $.each(pasianHandicapData, function(key, value) {
540                                            if(value != ''){
541                                                pallHandicaps += '<div class="flex-table header" role="rowgroup">';
542                                                pallHandicaps += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
543                                                pallHandicaps += '<div title="Home" class="flex-row oddWidth" role="columnheader">Home</div>';
544                                                pallHandicaps += '<div title="Away" class="flex-row oddWidth" role="columnheader">Away</div>';
545                                                pallHandicaps += '</div>';
546                                                pallHandicaps += '<div class="table__body">';
547                                                $.each(value, function(keys, values) {
548                                                    pallHandicaps += '<div class="flex-table row" role="rowgroup">';
549                                                    pallHandicaps += '<div class="flex-row bookmakers" role="cell">Chance</div>';
550                                                    pallHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.home + '</div>';
551                                                    pallHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.away + '</div>';
552                                                    pallHandicaps += '</div>';
553                                                });
554                                                pallHandicaps += '</div>';
555                                            }
556                                        });
557
558                                        htmlInsideTabsConstructorP += '</div>';
559                                        htmlInsideTabsConstructorP += '</section>';
560
561                                        htmlInsideTabsConstructorP += '<section id="pou" class="tab-content">';
562                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
563
564                                        var pouData = {
565                                            "Over/Under" : [{
566                                                over : res[0]['prob_O'],
567                                                under : res[0]['prob_U']
568                                            }],
569                                            "Over/Under +1" : [{
570                                                over : res[0]['prob_O_1'],
571                                                under : res[0]['prob_U_1']
572                                            }],
573                                            "Over/Under +3" : [{
574                                                over : res[0]['prob_O_3'],
575                                                under : res[0]['prob_U_3']
576                                            }]
577                                        };
578
579                                        var pallou = '';
580
581                                        $.each(pouData, function(key, value) {
582                                            if(value != ''){
583                                                pallou += '<div class="flex-table header" role="rowgroup">';
584                                                pallou += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
585                                                pallou += '<div title="Over" class="flex-row oddWidth" role="columnheader">Over</div>';
586                                                pallou += '<div title="Under" class="flex-row oddWidth" role="columnheader">Under</div>';
587                                                pallou += '</div>';
588                                                pallou += '<div class="table__body">';
589                                                $.each(value, function(keys, values) {
590                                                    pallou += '<div class="flex-table row" role="rowgroup">';
591                                                    pallou += '<div class="flex-row bookmakers" role="cell">Chance</div>';
592                                                    pallou += '<div class="flex-row oddWidth" role="cell">' + values.over + '</div>';
593                                                    pallou += '<div class="flex-row oddWidth" role="cell">' + values.under + '</div>';
594                                                    pallou += '</div>';
595                                                });
596                                                pallou += '</div>';
597                                            }
598                                        });
599
600                                        htmlInsideTabsConstructorP += '</div>';
601                                        htmlInsideTabsConstructorP += '</section>';
602
603                                        htmlInsideTabsConstructorP += '<section id="pbts" class="tab-content">';
604                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
605                                        htmlInsideTabsConstructorP += '<div class="flex-table header" role="rowgroup">';
606                                        htmlInsideTabsConstructorP += '<div title="" class="flex-row bookmakers" role="columnheader"></div>';
607                                        htmlInsideTabsConstructorP += '<div title="Yes" class="flex-row oddWidth" role="columnheader">Yes</div>';
608                                        htmlInsideTabsConstructorP += '<div title="No" class="flex-row oddWidth" role="columnheader">No</div>';
609                                        htmlInsideTabsConstructorP += '</div>';
610                                        htmlInsideTabsConstructorP += '<div class="table__body">';
611                                        if(res[0]['prob_bts'] !== '' || res[0]['prob_ots'] !== '') {
612                                            htmlInsideTabsConstructorP += '<div class="flex-table row" role="rowgroup">';
613                                            htmlInsideTabsConstructorP += '<div class="flex-row bookmakers" role="cell">Chance</div>';
614                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_bts != 'undefined') ? res[0].prob_bts : '' ) + '</div>';
615                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_ots != 'undefined') ? res[0].prob_ots : '' ) + '</div>';
616                                            htmlInsideTabsConstructorP += '</div>';
617                                        } else {
618                                            htmlInsideTabsConstructorP += '<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>';
619                                        }
620                                        htmlInsideTabsConstructorP += '</div>';
621                                        htmlInsideTabsConstructorP += '</div>';
622                                        htmlInsideTabsConstructorP += '</section>';
623
624                                        htmlInsideTabsConstructorP += '</div>';
625                                        $('#matchPredictions .tab-container').append(htmlInsideTabsConstructorP);
626                                        $('#matchPredictions .nav-tab-wrapper').prepend(htmlConstructorO);
627
628                                        if(pallHandicaps.length > 0){
629                                            $('#pah .tablele-container').append(pallHandicaps);
630                                        } else {
631                                            $('#pah .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Asian handicap" class="flex-row bookmakers" role="columnheader">Asian handicap</div><div title="1" class="flex-row oddWidth" role="columnheader">1</div><div title="2" class="flex-row oddWidth" role="columnheader">2</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
632                                        }
633
634                                        if(pallou.length > 0){
635                                            $('#pou .tablele-container').append(pallou);
636                                        } else {
637                                            $('#pou .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Over/Under" class="flex-row bookmakers" role="columnheader">Over/Under</div><div title="Over" class="flex-row oddWidth" role="columnheader">Over</div><div title="Under" class="flex-row oddWidth" role="columnheader">Under</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
638                                        }
639
640                                        // Switching tabs on click
641                                        $('#matchPredictions .nav-tab').unbind('click').on('click', function(e) {
642                                            e.preventDefault();
643                                            //Toggle tab link
644                                            $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
645                                            //Toggle target tab
646                                            $($(this).attr('href')).addClass('active').siblings().removeClass('active');
647                                        });
648                                    } else {
649                                        $('#matchPredictions .tab-container').addClass('lineForNoData').prepend('<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>');
650                                    }
651                                });
652                                htmlConstructor += '</div>';
653                                htmlConstructor += '</section>';
654
655                                $('#matchResultsContentTable').append(htmlConstructor);
656
657                                // Remove Fixture Date from local storage
658                                sessionStorage.removeItem('fixturesDate');
659
660                                // Added close button in HTML
661                                $('#matchResultsContentTable').append('<p class="closeWindow">close window</p>');
662                                // Added click function to close window
663                                $('.closeWindow').click(function() {
664                                    window.close();
665                                });
666
667                                // Switching tabs on click
668                                $('.nav-tab').unbind('click').on('click', function(e) {
669                                    e.preventDefault();
670                                    //Toggle tab link
671                                    $(this).addClass('nav-tab-active').parent().parent().siblings().find('a').removeClass('nav-tab-active');
672                                    //Toggle target tab
673                                    $($(this).attr('href')).addClass('active').siblings().removeClass('active');
674                                });
675
676                                // Added click function to header close window
677                                $('.backButton').click(function() {
678                                    window.close();
679                                });
680
681                            } else {
682
683                                // If server send details for match we populate HTML
684                                // Set key for Home Team
685                                var hometeamKeyMain = res[0].match_hometeam_id;
686                                // Set key for Away Team
687                                var awayteamKeyMain = res[0].match_awayteam_id;
688
689                                // Hide loading sreen
690                                $('.loading').hide();
691
692                                // Details for match
693                                var otherMatchDetails = '<div class="otherMatchDetails">';
694                                otherMatchDetails += '<div class="otherMatchDetailsInfos">';
695                                otherMatchDetails += '<div class="leagueImg" style="background-image: url(\'' + (((leagueLogo == '') || (leagueLogo == 'null') || (leagueLogo == null) || (leagueLogo == 'https://apiv3.apifootball.com/badges/logo_leagues/-1')) ? 'img/no-img.png' : leagueLogo) + '\');"></div>';
696                                otherMatchDetails += '<div>' + res[0].country_name + ': ' + res[0].league_name + '</div>';
697                                otherMatchDetails += '</div>';
698                                var formattedDate = new Date(res[0].match_date + "T00:00");
699                                var d = formattedDate.getDate();
700                                var m = formattedDate.getMonth() + 1;
701                                var y = formattedDate.getFullYear();
702                                otherMatchDetails += '<div>' + (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + '.' + y + ' ' + res[0].match_time + '</div>';
703                                otherMatchDetails += '</div>';
704                                $(matchResultsLocation).prepend(otherMatchDetails);
705                                // Added click function to header close window
706                                $('.backButton').click(function() {
707                                    window.close();
708                                });
709                                // Add hook in HTML for Match Results Tab content infos
710                                $(matchResultsLocation).append('<section id="matchResultsContentTable"></section>');
711                                var htmlConstructor = '<div id="matchResultsDates">';
712                                htmlConstructor += '<div id="matchResultsDatesTitle">';
713                                if (!res.error) {
714                                    htmlConstructor += '<div class="match_hometeam_name">';
715                                    htmlConstructor += '<div class="match_hometeam_name_part">';
716                                    htmlConstructor += '<div class="match_hometeam_name_part_img">';
717                                    htmlConstructor += '<div class="image-style-for-flag" style="background-image: url(\'' + (((res[0].team_home_badge == '') || (res[0].team_home_badge == 'null') || (res[0].team_home_badge == null)) ? 'img/no-img.png' : res[0].team_home_badge) + '\');"></div>';
718                                    htmlConstructor += '</div>';
719                                    htmlConstructor += '<div class="match_hometeam_name_part_name">';
720                                    htmlConstructor += '<div>' + res[0].match_hometeam_name + '</div>';
721                                    htmlConstructor += '</div>';
722                                    htmlConstructor += '</div>';
723                                    htmlConstructor += '<div class="event_info">';
724                                    htmlConstructor += '<div class="event_info_score">';
725                                    htmlConstructor += '<div>' + res[0].match_hometeam_score + ' - ' + res[0].match_awayteam_score + '</div>';
726                                    htmlConstructor += '</div>';
727                                    htmlConstructor += '<div class="event_info_status">';
728                                    var removeNumericAdd = res[0].match_status.replace('+', '');
729                                    htmlConstructor += '<div class="' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? 'matchIsLive' : '') + '"> ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? res[0].match_status + ((removeNumericAdd == 'Half Time') ? '' : '\'') : res[0].match_status) + '</div>';
730                                    htmlConstructor += '</div>';
731                                    htmlConstructor += '</div>';
732                                    htmlConstructor += '<div class="match_awayteam_name_part">';
733                                    htmlConstructor += '<div class="match_awayteam_name_part_img">';
734                                    htmlConstructor += '<div class="image-style-for-flag" style="background-image: url(\'' + (((res[0].team_away_badge == '') || (res[0].team_away_badge == 'null') || (res[0].team_away_badge == null)) ? 'img/no-img.png' : res[0].team_away_badge) + '\');"></div>';
735                                    htmlConstructor += '</div>';
736                                    htmlConstructor += '<div class="match_awayteam_name_part_name">';
737                                    htmlConstructor += '<div>' + res[0].match_awayteam_name + '</div>';
738                                    htmlConstructor += '</div>';
739                                    htmlConstructor += '</div>';
740                                    htmlConstructor += '</div>';
741                                }
742                                htmlConstructor += '</div>';
743                                htmlConstructor += '<div class="nav-tab-wrapper-all">';
744                                htmlConstructor += '<ul class="nav-tab-wrapper-all-container">';
745                                htmlConstructor += '<li><span><a href="#matchSummary" class="matchResults-h2 nav-tab nav-tab-active">Match Summary</a></span></li>';
746                                htmlConstructor += '<li><span><a href="#matchStatistics" class="matchResults-h2 nav-tab">Statistics</a></span></li>';
747                                htmlConstructor += '<li><span><a href="#lineups" class="matchResults-h2 nav-tab">Lineups</a></span></li>';
748                                htmlConstructor += '<li><span><a href="#matchh2h" class="matchResults-h2 nav-tab">H2H</a></span></li>';
749                                // If match_round: contains "finals" then hide Standings Tab
750                                htmlConstructor += ((res[0].match_round.indexOf('finals') != -1) ? '' : '<li><span><a href="#matchStandings" class="matchResults-h2 nav-tab">Standings</a></span></li>');
751                                htmlConstructor += '<li><span><a href="#matchTopScorers" class="matchResults-h2 nav-tab">Top Scorers</a></span></li>';
752                                htmlConstructor += '<li><span><a href="#matchOdds" class="matchResults-h2 nav-tab d-none-tab-odds">Odds</a></span></li>';
753                                htmlConstructor += '<li><span><a href="#matchPredictions" class="matchResults-h2 nav-tab d-none-tab-prediction">Predictions</a></span></li>';
754                                htmlConstructor += '</ul>';
755                                htmlConstructor += '</div>';
756
757                                // Populate Match Summary section
758                                htmlConstructor += '<section id="matchSummary" class="tab-content active">';
759                                htmlConstructor += '<div class="tab-container">';
760
761                                var substitutions_home_array = [res[0].substitutions.home];
762                                substitutions_home_array[0].forEac
762h(function (whatTeam) {
763                                    whatTeam.whatTeam = 'home_team';
764                                });
765
766                                var substitutions_away_array = [res[0].substitutions.away];
767                                substitutions_away_array[0].forEach(function (whatTeam) {
768                                    whatTeam.whatTeam = 'away_team';
769                                });
770
771                                var multipleArrays = [res[0].goalscorer, substitutions_home_array[0], substitutions_away_array[0], res[0].cards];
772                                var flatArray = [].concat.apply([], multipleArrays);
773                                var nrArray = flatArray;
774                                nrArray.sort(naturalCompare);
775                                var newArray = {};
776                                $.each(nrArray, function(key, value) {
777                                  if (!newArray[value['score_info_time']]) {
778                                    newArray[value['score_info_time']] = [];
779                                  }
780                                  newArray[value['score_info_time']].push(value);
781                                });
782                                var orderedNewArray = {
783                                  '1st Half': newArray['1st Half'] ? newArray['1st Half'] : false,
784                                  '2nd Half': newArray['2nd Half'] ? newArray['2nd Half'] : false,
785                                  'Extra Time': newArray['Extra Time'] ? newArray['Extra Time'] : false,
786                                  'Penalty': newArray['Penalty'] ? newArray['Penalty'] : false
787                                };
788                                if (nrArray.length == 0) {
789                                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>';
790                                } else {
791                                    var htmlCC = 0;
792                                    var htmlCC2 = 0;
793                                    var first = true;
794                                    $.each(orderedNewArray, function(key, valueSub) {
795                                      if (valueSub) {
796                                        if (first && key != '1st Half') {
797                                                htmlConstructor += '<div class="lineupsTitle">1st Half</div>';
798                                          htmlConstructor += '<div class="noHalfEvent">-</div>';
799                                            }
800                                        first = false;
801                                        htmlConstructor += '<div class="lineupsTitle">'+key+'</div>';
802                                        $.each(valueSub, function(key2, value) {
803                                          if ((value.home_scorer || value.away_scorer || value.info) && value.score !== "substitution" && value.score ) {
804                                              htmlConstructor += '<div class="' + ((value.home_scorer || value.info == 'home') ? 'action_home' : 'action_away') + '">' + ((value.home_scorer || value.info == 'home' ) ? value.time + '\'<div class="imgMatchSummary" style="background-image: url(img/ball.png);"></div>' + value.home_scorer : '') + ' ' + ((value.away_scorer || value.info == 'away' ) ? value.time + '\'' + '<div class="imgMatchSummary" style="background-image: url(img/ball.png);"></div>' + value.away_scorer : '') + '</div>';
805                                            }
806                                          if ((value.home_scorer == '') && (value.away_scorer == '') && value.info == '') {
807                                                htmlConstructor += '<div class="action_unknown">' + (value.time + '\'<div class="imgMatchSummary" style="background-image: url(img/ball.png);"></div>') + '</div>';
808                                            }
809                                          if ((value.home_fault || value.away_fault || value.info)  && !value.score) {
810                                              htmlConstructor += '<div class="' + ((value.home_fault || value.info == 'home') ? 'action_home' : 'action_away') + '">' + ((value.home_fault || value.info == 'home') ? value.time + '\' ' + ((value.card == 'yellow card') ? '<div class="imgMatchSummary" style="background-image: url(img/yellow_card.svg);"></div>' : '<div class="imgMatchSummary" style="background-image: url(img/red_card.svg);"></div>') + ' ' + value.home_fault : '') + ' ' + ((value.away_fault || value.info == 'away') ? value.time + '\'' + ' ' + ((value.card == 'yellow card') ? '<div class="imgMatchSummary" style="background-image: url(img/yellow_card.svg);"></div>' : '<div class="imgMatchSummary" style="background-image: url(img/red_card.svg);"></div>') + ' ' + value.away_fault : '') + '</div>';
811                                            }
812                                          if ((value.home_fault == '') && (value.away_fault == '') && value.info == ''  && !value.score) {
813                                                htmlConstructor += '<div class="action_unknown">' + ((value.card == 'yellow card') ? '<div class="imgMatchSummary" style="background-image: url(img/yellow_card.svg);"></div>' : '<div class="imgMatchSummary" style="background-image: url(img/red_card.svg);"></div>') + '</div>';
814                                            }
815                                          if (value.score === "substitution") {
816                                              htmlConstructor += '<div class="' + ((value.home_scorer.in) ? 'action_home' : 'action_away') + '">' + ((value.home_scorer.in) ? value.time + '\'<div class="imgMatchSummary" style="background-image: url(img/match_green.png);"></div>' + value.home_scorer.in + '<div class="imgMatchSummary" style="background-image: url(img/match_red.png);"></div>' + value.home_scorer.out : '') + ' ' + ((value.away_scorer.in) ? value.time + '\'' + '<div class="imgMatchSummary" style="background-image: url(img/match_green.png);"></div>' + value.away_scorer.in + '<div class="imgMatchSummary" style="background-image: url(img/match_red.png);"></div>' + value.away_scorer.out : '') + '</div>';
817                                            }
818                                        });
819                                        }
820                                    });
821                                htmlConstructor += '</div>';
822                                }
823                                if ((res[0].match_referee != '') || (res[0].match_stadium != '')) {
824                                    htmlConstructor += '<div>';
825                                    htmlConstructor += '<div class="matchExtraInfosTitle">Match Information</div>';
826                                    htmlConstructor += '<div class="matchExtraInfos">' + ((res[0].match_referee != '') ? 'Referee: ' + res[0].match_referee : '') + ' ' + ((res[0].match_stadium != '') ? 'Stadium: ' + res[0].match_stadium : '') + '</div>';
827                                    htmlConstructor += '</div>';
828                                }
829                                htmlConstructor += '</section>';
830
831                                // Populate Match Statistics section
832                                htmlConstructor += '<section id="matchStatistics" class="tab-content">';
833                                htmlConstructor += '<div class="tab-container">';
834                                if (res[0].statistics.length == 0) {
835                                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>';
836                                } else {
837                                    $.each(res[0].statistics, function(key, value) {
838                                        if (JSON.stringify(value).indexOf('%') > -1) {
839                                            htmlConstructor += '<div class="matchStatisticsRow">';
840                                            htmlConstructor += '<div class="matchStatisticsRowText">';
841                                            htmlConstructor += '<div class="matchStatisticsRowHome">' + value.home + '</div>';
842                                            htmlConstructor += '<div class="matchStatisticsRowType">' + value.type + '</div>';
843                                            htmlConstructor += '<div class="matchStatisticsRowAway">' + value.away + '</div>';
844                                            htmlConstructor += '</div>';
845                                            htmlConstructor += '<div class="matchStatisticsRowBar">';
846                                            htmlConstructor += '<div class="matchStatisticsRowBarHome">';
847                                            htmlConstructor += '<div class="matchStatisticsRowBarHomeBg">';
848                                            htmlConstructor += '<div class="matchStatisticsRowHomeLine" style="width:' + value.home + ';background-color:' + ((value.home > value.away) ? 'red' : '') + ';"></div>';
849                                            htmlConstructor += '</div>';
850                                            htmlConstructor += '</div>';
851                                            htmlConstructor += '<div class="matchStatisticsRowBarAway">';
852                                            htmlConstructor += '<div class="matchStatisticsRowBarAwayBg">';
853                                            htmlConstructor += '<div class="matchStatisticsRowAwayLine" style="width:' + value.away + ';background-color:' + ((value.away > value.home) ? 'red' : '') + ';"></div>';
854                                            htmlConstructor += '</div>';
855                                            htmlConstructor += '</div>';
856                                            htmlConstructor += '</div>';
857                                            htmlConstructor += '</div>';
858                                        } else {
859                                            var x = parseInt(value.home) + parseInt(value.away);
860                                            var xx = 100 / x;
861                                            var tt = xx * value.home;
862                                            var vv = xx * value.away;
863                                            htmlConstructor += '<div class="matchStatisticsRow">';
864                                            htmlConstructor += '<div class="matchStatisticsRowText">';
865                                            htmlConstructor += '<div class="matchStatisticsRowHome">' + value.home + '</div>';
866                                            htmlConstructor += '<div class="matchStatisticsRowType">' + value.type + '</div>';
867                                            htmlConstructor += '<div class="matchStatisticsRowAway">' + value.away + '</div>';
868                                            htmlConstructor += '</div>';
869                                            htmlConstructor += '<div class="matchStatisticsRowBar">';
870                                            htmlConstructor += '<div class="matchStatisticsRowBarHome">';
871                                            htmlConstructor += '<div class="matchStatisticsRowBarHomeBg">';
872                                            htmlConstructor += '<div class="matchStatisticsRowHomeLine" style="width:' + tt + '%;background-color:' + ((tt > vv) ? 'red' : '') + ';"></div>';
873                                            htmlConstructor += '</div>';
874                                            htmlConstructor += '</div>';
875                                            htmlConstructor += '<div class="matchStatisticsRowBarAway">';
876                                            htmlConstructor += '<div class="matchStatisticsRowBarAwayBg">';
877                                            htmlConstructor += '<div class="matchStatisticsRowAwayLine" style="width:' + vv + '%;background-color:' + ((vv > tt) ? 'red' : '') + ';"></div>';
878                                            htmlConstructor += '</div>';
879                                            htmlConstructor += '</div>';
880                                            htmlConstructor += '</div>';
881                                            htmlConstructor += '</div>';
882                                        }
883                                    });
884                                }
885                                htmlConstructor += '</div>';
886                                htmlConstructor += '</section>';
887
888                                // Populate Match Lineups section
889                                htmlConstructor += '<section id="lineups" class="tab-content">';
890                                htmlConstructor += '<div class="tab-container">';
891                                htmlConstructor += '<div class="lineupsTitle">Starting Lineups</div>';
892                                htmlConstructor += '<div class="lineupsContainer">';
893                                if ((res[0].lineup.home.starting_lineups.length == 0) || (res[0].lineup.away.starting_lineups.length == 0)) {
894                                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px;">Sorry, no data!</p>';
895                                } else {
896                                    htmlConstructor += '<div class="col-left">';
897                                    $.each(res[0].lineup.home.starting_lineups, function(key, value) {
898                                        htmlConstructor += '<div class="lineupsContainerHome"><div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_home_badge + '\');"></div> <div class="lineupsPlayer">' + value.lineup_player + '</div></div>';
899                                    });
900                                    htmlConstructor += '</div>';
901                                    htmlConstructor += '<div class="col-right">';
902                                    $.each(res[0].lineup.away.starting_lineups, function(key, value) {
903                                        htmlConstructor += '<div class="lineupsContainerAway"><div class="lineupsPlayer">' + value.lineup_player + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_away_badge + '\');"></div> <div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div></div>';
904                                    });
905                                    htmlConstructor += '</div>';
906                                }
907                                htmlConstructor += '</div>';
908
909                                // Populate Match Substitutes section
910                                htmlConstructor += '<div class="lineupsTitle">Substitutes</div>';
911                                htmlConstructor += '<div class="lineupsContainer">';
912                                if ((res[0].lineup.home.substitutes.length == 0) || (res[0].lineup.away.substitutes.length == 0)) {
913                                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px;">Sorry, no data!</p>';
914                                } else {
915                                    htmlConstructor += '<div class="col-left">';
916                                    $.each(res[0].lineup.home.substitutes, function(key, value) {
917                                        htmlConstructor += '<div class="lineupsContainerHome"><div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_home_badge + '\');"></div> <div class="lineupsPlayer">' + value.lineup_player + '</div></div>';
918                                    });
919                                    htmlConstructor += '</div>';
920                                    htmlConstructor += '<div class="col-right">';
921                                    $.each(res[0].lineup.a
921way.substitutes, function(key, value) {
922                                        htmlConstructor += '<div class="lineupsContainerAway"><div class="lineupsPlayer">' + value.lineup_player + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_away_badge + '\');"></div> <div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div></div>';
923                                    });
924                                    htmlConstructor += '</div>';
925                                }
926                                htmlConstructor += '</div>';
927                                htmlConstructor += '<div class="lineupsTitle">Coaches</div>';
928                                htmlConstructor += '<div class="lineupsContainer">';
929                                if ((res[0].lineup.home.coach.length == 0) || (res[0].lineup.away.coach.length == 0)) {
930                                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px;">Sorry, no data!</p>';
931                                } else {
932                                    htmlConstructor += '<div class="col-left">';
933                                    $.each(res[0].lineup.home.coach, function(key, value) {
934                                        htmlConstructor += '<div class="lineupsContainerHome"><div class="lineupsNb"></div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_home_badge + '\');"></div> <div class="lineupsPlayer">' + value.lineup_player + '</div></div>';
935                                    });
936                                    htmlConstructor += '</div>';
937                                    htmlConstructor += '<div class="col-right">';
938                                    $.each(res[0].lineup.away.coach, function(key, value) {
939                                        htmlConstructor += '<div class="lineupsContainerAway"><div class="lineupsPlayer">' + value.lineup_player + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_away_badge + '\');"></div> <div class="lineupsNb"></div></div>';
940                                    });
941                                    htmlConstructor += '</div>';
942                                }
943                                htmlConstructor += '</div>';
944                                htmlConstructor += '</div>';
945                                htmlConstructor += '</section>';
946
947                                // Populate Match H2H (Head to head) section
948                                htmlConstructor += '<section id="matchh2h" class="tab-content">';
949                                htmlConstructor += '<div class="tab-container">';
950                                var htmlInsideTabsConstructorh2h = '';
951                                // Send server request for H2H
952                                $.ajax({
953                                    url: matchResultsDetailsAjaxURL,
954                                    cache: false,
955                                    data: {
956                                        action: 'get_H2H',
957                                        Widgetkey: Widgetkey,
958                                        firstTeamId: res[0].match_hometeam_id,
959                                        secondTeamId: res[0].match_awayteam_id,
960                                        timezone:getTimeZone()
961                                    },
962                                    dataType: 'json'
963                                }).done(function(res2) {
964                                    // If server send results we populate HTML with sended information
965                                    if(!res2.error){
966                                        htmlInsideTabsConstructorh2h += '<div class="flex-table header">';
967                                        htmlInsideTabsConstructorh2h += '<div title="hh22hh" class="flex-row matchh2hHeader fix-width" role="columnheader">Last matches: ' + res[0].match_hometeam_name + '</div>';
968                                        htmlInsideTabsConstructorh2h += '</div>';
969                                        htmlInsideTabsConstructorh2h += '<div class="tablele-container">';
970                                        htmlInsideTabsConstructorh2h += '<div class="table__body">';
971                                        $.each(res2.firstTeam_lastResults, function(key, value) {
972                                            var event_final_result_class = value.match_hometeam_score + ' - ' + value.match_awayteam_score;
973                                            var event_final_result_class_away = value.match_awayteam_score;
974                                            var event_final_result_class_home = value.match_hometeam_score;
975                                            var formattedDate = new Date(value.match_date + "T00:00");
976                                            var d = formattedDate.getDate();
977                                            var m = formattedDate.getMonth() + 1;
978                                            var y = formattedDate.getFullYear().toString().substr(-2);
979                                            var value_country_name = value.country_name.toString().toLowerCase();
980                                            htmlInsideTabsConstructorh2h += '<div class="flex-table row" role="rowgroup">';
981                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hDate" role="cell">' + (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + '.' + y + '</div>';
982                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hFlags" role="cell"><div class="matchh2hFlag" style="background-image: url(\'' + (((leagueLogo == '') || (leagueLogo == 'null') || (leagueLogo == null) || (leagueLogo == 'https://apiv3.apifootball.com/badges/logo_leagues/-1')) ? 'img/no-img.png' : leagueLogo) + '\');"></div></div>';
983                                            htmlInsideTabsConstructorh2h += '<div class="flex-row countryNameStyle" role="cell">' + value_country_name + '</div>';
984                                            if (event_final_result_class_home > event_final_result_class_away) {
985                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hWinnerHome flex-row fix-width ' + (((res[0].match_hometeam_name == value.match_hometeam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_hometeam_name + '</div>';
986                                                htmlInsideTabsConstructorh2h += '<div class="flex-row fix-width ' + (((res[0].match_hometeam_name == value.match_awayteam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_awayteam_name + '</div>';
987                                            } else if (event_final_result_class_home < event_final_result_class_away) {
988                                                htmlInsideTabsConstructorh2h += '<div class="flex-row fix-width ' + (((res[0].match_hometeam_name == value.match_hometeam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_hometeam_name + '</div>';
989                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hWinnerAway flex-row fix-width ' + (((res[0].match_hometeam_name == value.match_awayteam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_awayteam_name + '</div>';
990                                            } else if (event_final_result_class_home == event_final_result_class_away) {
991                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hEqual flex-row fix-width ' + (((res[0].match_hometeam_name == value.match_hometeam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_hometeam_name + '</div>';
992                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hEqual flex-row fix-width ' + (((res[0].match_hometeam_name == value.match_awayteam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_awayteam_name + '</div>';
993                                            }
994                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hEventFinalResult" role="cell">' + event_final_result_class + '</div>';
995                                            htmlInsideTabsConstructorh2h += '</div>';
996                                        });
997                                        htmlInsideTabsConstructorh2h += '</div>';
998                                        htmlInsideTabsConstructorh2h += '</div>';
999                                        htmlInsideTabsConstructorh2h += '<div class="flex-table header">';
1000                                        htmlInsideTabsConstructorh2h += '<div title="hh22hh" class="flex-row matchh2hHeader fix-width" role="columnheader">Last matches: ' + res[0].match_awayteam_name + '</div>';
1001                                        htmlInsideTabsConstructorh2h += '</div>';
1002                                        htmlInsideTabsConstructorh2h += '<div class="tablele-container">';
1003                                        htmlInsideTabsConstructorh2h += '<div class="table__body">';
1004                                        $.each(res2.secondTeam_lastResults, function(key, value) {
1005                                            var event_final_result_class = value.match_hometeam_score + ' - ' + value.match_awayteam_score;
1006                                            var event_final_result_class_away = value.match_awayteam_score;
1007                                            var event_final_result_class_home = value.match_hometeam_score;
1008                                            var formattedDate = new Date(value.match_date + "T00:00");
1009                                            var d = formattedDate.getDate();
1010                                            var m = formattedDate.getMonth() + 1;
1011                                            var y = formattedDate.getFullYear().toString().substr(-2);
1012                                            var value_country_name = value.country_name.toString().toLowerCase();
1013                                            htmlInsideTabsConstructorh2h += '<div class="flex-table row" role="rowgroup">';
1014                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hDate" role="cell">' + (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + '.' + y + '</div>';
1015                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hFlags" role="cell"><div class="matchh2hFlag" style="background-image: url(\'' + (((leagueLogo == '') || (leagueLogo == 'null') || (leagueLogo == null) || (leagueLogo == 'https://apiv3.apifootball.com/badges/logo_leagues/-1')) ? 'img/no-img.png' : leagueLogo) + '\');"></div></div>';
1016                                            htmlInsideTabsConstructorh2h += '<div class="flex-row countryNameStyle" role="cell">' + value_country_name + '</div>';
1017                                            if (event_final_result_class_home > event_final_result_class_away) {
1018                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hWinnerHome flex-row fix-width ' + (((res[0].match_awayteam_name == value.match_hometeam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_hometeam_name + '</div>';
1019                                                htmlInsideTabsConstructorh2h += '<div class="flex-row fix-width ' + (((res[0].match_awayteam_name == value.match_awayteam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_awayteam_name + '</div>';
1020                                            } else if (event_final_result_class_home < event_final_result_class_away) {
1021                                                htmlInsideTabsConstructorh2h += '<div class="flex-row fix-width ' + (((res[0].match_awayteam_name == value.match_hometeam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_hometeam_name + '</div>';
1022                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hWinnerAway flex-row fix-width ' + (((res[0].match_awayteam_name == value.match_awayteam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_awayteam_name + '</div>';
1023                                            } else if (event_final_result_class_home == event_final_result_class_away) {
1024                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hEqual flex-row fix-width ' + (((res[0].match_awayteam_name == value.match_hometeam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_hometeam_name + '</div>';
1025                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hEqual flex-row fix-width ' + (((res[0].match_awayteam_name == value.match_awayteam_name)) ? 'selectedMatchH2H' : '') + '" role="cell">' + value.match_awayteam_name + '</div>';
1026                                            }
1027                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hEventFinalResult" role="cell">' + event_final_result_class + '</div>';
1028                                            htmlInsideTabsConstructorh2h += '</div>';
1029                                        });
1030                                        htmlInsideTabsConstructorh2h += '</div>';
1031                                        htmlInsideTabsConstructorh2h += '</div>';
1032                                        htmlInsideTabsConstructorh2h += '<div class="flex-table header">';
1033                                        htmlInsideTabsConstructorh2h += '<div title="hh22hh" class="flex-row matchh2hHeader fix-width" role="columnheader">Head-to-head matches: ' + res[0].match_hometeam_name + ' - ' + res[0].match_awayteam_name + '</div>';
1034                                        htmlInsideTabsConstructorh2h += '</div>';
1035                                        htmlInsideTabsConstructorh2h += '<div class="tablele-container">';
1036                                        htmlInsideTabsConstructorh2h += '<div class="table__body">';
1037                                        $.each(res2.firstTeam_VS_secondTeam, function(key, value) {
1038                                            var event_final_result_class = value.match_hometeam_score + ' - ' + value.match_awayteam_score;
1039                                            var event_final_result_class_away = value.match_awayteam_score;
1040                                            var event_final_result_class_home = value.match_hometeam_score;
1041                                            var formattedDate = new Date(value.match_date + "T00:00");
1042                                            var d = formattedDate.getDate();
1043                                            var m = formattedDate.getMonth() + 1;
1044                                            var y = formattedDate.getFullYear().toString().substr(-2);
1045                                            var value_country_name = value.country_name.toString().toLowerCase();
1046                                            htmlInsideTabsConstructorh2h += '<div class="flex-table row" role="rowgroup">';
1047                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hDate" role="cell">' + (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + '.' + y + '</div>';
1048                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hFlags" role="cell"><div class="matchh2hFlag" style="background-image: url(\'' + (((leagueLogo == '') || (leagueLogo == 'null') || (leagueLogo == null) || (leagueLogo == 'https://apiv3.apifootball.com/badges/logo_leagues/-1')) ? 'img/no-img.png' : leagueLogo) + '\');"></div></div>';
1049                                            htmlInsideTabsConstructorh2h += '<div class="flex-row countryNameStyle" role="cell">' + value_country_name + '</div>';
1050                                            if (event_final_result_class_home > event_final_result_class_away) {
1051                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hWinnerHome flex-row fix-width" role="cell">' + value.match_hometeam_name + '</div>';
1052                                                htmlInsideTabsConstructorh2h += '<div class="flex-row fix-width" role="cell">' + value.match_awayteam_name + '</div>';
1053                                            } else if (event_final_result_class_home < event_final_result_class_away) {
1054                                                htmlInsideTabsConstructorh2h += '<div class="flex-row fix-width" role="cell">' + value.match_hometeam_name + '</div>';
1055                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hWinnerAway flex-row fix-width" role="cell">' + value.match_awayteam_name + '</div>';
1056                                            } else if (event_final_result_class_home == event_final_result_class_away) {
1057                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hEqual flex-row fix-width" role="cell">' + value.match_hometeam_name + '</div>';
1058                                                htmlInsideTabsConstructorh2h += '<div class="teamClassStyleH2hEqual flex-row fix-width" role="cell">' + value.match_awayteam_name + '</div>';
1059                                            }
1060                                            htmlInsideTabsConstructorh2h += '<div class="flex-row matchh2hEventFinalResult" role="cell">' + event_final_result_class + '</div>';
1061                                            htmlInsideTabsConstructorh2h += '</div>';
1062                                        });
1063                                        htmlInsideTabsConstructorh2h += '</div>';
1064                                        htmlInsideTabsConstructorh2h += '</div>';
1065                                        $('#matchh2h .tab-container').append(htmlInsideTabsConstructorh2h);
1066                                    } else {
1067                                        htmlInsideTabsConstructorh2h += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>';
1068                                        $('#matchh2h .tab-container').append(htmlInsideTabsConstructorh2h);
1069                                    }
1070                                });
1071                                htmlConstructor += '</div>';
1072                                htmlConstructor += '</section>';
1073
1074                                // Populate Match Top Scorers section
1075                                htmlConstructor += '<section id="matchTopScorers" class="tab-content">';
1076                                htmlConstructor += '<div class="tab-container">';
1077                                var htmlInsideTabsConstructorTS = '';
1078                                // Send ser
1078ver request for Topscorers
1079                                $.ajax({
1080                                    url: matchResultsDetailsAjaxURL,
1081                                    cache: false,
1082                                    data: {
1083                                        action: 'get_topscorers',
1084                                        Widgetkey: Widgetkey,
1085                                        league_id: res[0].league_id
1086                                    },
1087                                    dataType: 'json'
1088                                }).done(function(res) {
1089                                    // If server send results we populate HTML with sended information
1090                                    if (!res.error) {
1091                                        htmlInsideTabsConstructorTS += '<div class="tablele-container">';
1092                                        htmlInsideTabsConstructorTS += '<div class="flex-table header">';
1093                                        htmlInsideTabsConstructorTS += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
1094                                        htmlInsideTabsConstructorTS += '<div title="Player" class="flex-row players" role="columnheader">Player</div>';
1095                                        htmlInsideTabsConstructorTS += '<div title="Team" class="flex-row playerTeam fix-width" role="columnheader">Team</div>';
1096                                        htmlInsideTabsConstructorTS += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
1097                                        htmlInsideTabsConstructorTS += '</div>';
1098                                        htmlInsideTabsConstructorTS += '<div class="table__body">';
1099                                        $.each(res, function(key, value) {
1100                                            htmlInsideTabsConstructorTS += '<div class="flex-table row" role="rowgroup">';
1101                                            htmlInsideTabsConstructorTS += '<div class="flex-row first fix-width" role="cell">' + value.player_place + '.</div>';
1102                                            htmlInsideTabsConstructorTS += '<div class="flex-row players" role="cell"><a href="#">' + value.player_name + '</a></div>';
1103                                            htmlInsideTabsConstructorTS += '<div class="flex-row playerTeam" role="cell"><a href="#">' + value.team_name + '</a></div>';
1104                                            htmlInsideTabsConstructorTS += '<div class="flex-row goals fix-width" role="cell">' + value.goals + '</div>';
1105                                            htmlInsideTabsConstructorTS += '</div>';
1106                                        });
1107                                        htmlInsideTabsConstructorTS += '</div>';
1108                                        htmlInsideTabsConstructorTS += '</div>';
1109                                    } else {
1110                                        htmlInsideTabsConstructorTS += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>';
1111                                    }
1112                                    $('#matchTopScorers .tab-container').append(htmlInsideTabsConstructorTS);
1113                                });
1114                                htmlConstructor += '</div>';
1115                                htmlConstructor += '</section>';
1116
1117                                // Populate Match Standings section
1118                                // If match_round: contains "finals" then hide Standings Tab
1119                                if (res[0].match_round.indexOf('finals') == -1) {
1120                                    htmlConstructor += '<section id="matchStandings" class="tab-content">';
1121                                    htmlConstructor += '<div class="tab-container">';
1122                                    // Send server request for Standings
1123                                    $.ajax({
1124                                        url: matchResultsDetailsAjaxURL,
1125                                        cache: false,
1126                                        data: {
1127                                            action: 'get_standings',
1128                                            Widgetkey: Widgetkey,
1129                                            league_id: res[0].league_id,
1130                                            stage_key: res[0].fk_stage_key
1131                                        },
1132                                        dataType: 'json'
1133                                    }).done(function (res) {
1134                                        var newStand = {
1135                                            'total': [],
1136                                            'home': [],
1137                                            'away': []
1138                                        };
1139                                        var i = 0;
1140
1141                                        if (!res.error) {
1142                                            $.each(res, function (key, value) {
1143                                                var ii = i++;
1144                                                newStand['total'][ii] = {
1145                                                    'country_name': value['country_name'],
1146                                                    'league_id': value['league_id'],
1147                                                    'league_name': value['league_name'],
1148                                                    'team_id': value['team_id'],
1149                                                    'team_name': value['team_name'],
1150                                                    'league_round': value['league_round'],
1151                                                    'league_position': value['overall_league_position'],
1152                                                    'league_payed': value['overall_league_payed'],
1153                                                    'league_W': value['overall_league_W'],
1154                                                    'league_D': value['overall_league_D'],
1155                                                    'league_L': value['overall_league_L'],
1156                                                    'league_GF': value['overall_league_GF'],
1157                                                    'league_GA': value['overall_league_GA'],
1158                                                    'league_PTS': value['overall_league_PTS'],
1159                                                    'promotion': value['overall_promotion']
1160                                                };
1161                                                newStand['home'][ii] = {
1162                                                    'country_name': value['country_name'],
1163                                                    'league_id': value['league_id'],
1164                                                    'league_name': value['league_name'],
1165                                                    'team_id': value['team_id'],
1166                                                    'team_name': value['team_name'],
1167                                                    'league_round': value['league_round'],
1168                                                    'league_position': value['home_league_position'],
1169                                                    'league_payed': value['home_league_payed'],
1170                                                    'league_W': value['home_league_W'],
1171                                                    'league_D': value['home_league_D'],
1172                                                    'league_L': value['home_league_L'],
1173                                                    'league_GF': value['home_league_GF'],
1174                                                    'league_GA': value['home_league_GA'],
1175                                                    'league_PTS': value['home_league_PTS']
1176                                                };
1177                                                newStand['away'][ii] = {
1178                                                    'country_name': value['country_name'],
1179                                                    'league_id': value['league_id'],
1180                                                    'league_name': value['league_name'],
1181                                                    'team_id': value['team_id'],
1182                                                    'team_name': value['team_name'],
1183                                                    'league_round': value['league_round'],
1184                                                    'league_position': value['away_league_position'],
1185                                                    'league_payed': value['away_league_payed'],
1186                                                    'league_W': value['away_league_W'],
1187                                                    'league_D': value['away_league_D'],
1188                                                    'league_L': value['away_league_L'],
1189                                                    'league_GF': value['away_league_GF'],
1190                                                    'league_GA': value['away_league_GA'],
1191                                                    'league_PTS': value['away_league_PTS']
1192                                                };
1193                                            });
1194                                        }
1195                                        // If server send results hide loading
1196                                        $('.loading').hide();
1197                                        var htmlInsideTabsConstructorS = '<div class="nav-tab-wrapper">';
1198                                        var firstElementInJson = 0;
1199                                        var htmlConstructorS = '';
1200                                        $.each(newStand, function (key, value) {
1201                                            var sorted = sortByKey(newStand[key], 'key');
1202                                            var sorted_array = sortByKeyAsc(sorted, "league_round");
1203                                            var groubedByTeam = groupBy(sorted_array, 'league_round');
1204                                            var leagueRoundMatchResult = '';
1205                                            var leagueRoundName = '';
1206                                            $.each(groubedByTeam, function (keyss, valuess) {
1207                                                $.each(valuess, function (keyssss, valuessss) {
1208                                                    if (valuessss.team_id == hometeamKeyMain) {
1209                                                        leagueRoundName = valuessss.league_round;
1210                                                        leagueRoundMatchResult = valuessss.league_round;
1211                                                    }
1212                                                });
1213                                            });
1214                                            var onlySelectedGroup = groubedByTeam[leagueRoundMatchResult];
1215                                            if (firstElementInJson == 0) {
1216                                                htmlConstructorS += '<a href="#' + key + '" class="standing-h2 nav-tab nav-tab-active">' + key + '</a>';
1217                                                htmlInsideTabsConstructorS += '<section id="' + key + '" class="tab-content active">';
1218                                                htmlInsideTabsConstructorS += '<div class="tablele-container">';
1219                                                if ($.isEmptyObject(onlySelectedGroup)) {
1220                                                    htmlInsideTabsConstructorS += '<div class="flex-table header" role="rowgroup">';
1221                                                    htmlInsideTabsConstructorS += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
1222                                                    htmlInsideTabsConstructorS += '<div title="Team" class="flex-row teams" role="columnheader">Team</div>';
1223                                                    htmlInsideTabsConstructorS += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
1224                                                    htmlInsideTabsConstructorS += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
1225                                                    htmlInsideTabsConstructorS += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
1226                                                    htmlInsideTabsConstructorS += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
1227                                                    htmlInsideTabsConstructorS += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
1228                                                    htmlInsideTabsConstructorS += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
1229                                                    htmlInsideTabsConstructorS += '</div>';
1230                                                    htmlInsideTabsConstructorS += '<div class="table__body">';
1231                                                    htmlInsideTabsConstructorS += '<div class="flex-table-error row" role="rowgroup">';
1232                                                    htmlInsideTabsConstructorS += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>';
1233                                                    htmlInsideTabsConstructorS += '</div>';
1234                                                    htmlInsideTabsConstructorS += '</div>';
1235                                                } else {
1236                                                    htmlInsideTabsConstructorS += '<div class="flex-table header">';
1237                                                    htmlInsideTabsConstructorS += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
1238                                                    htmlInsideTabsConstructorS += '<div title="' + ((!leagueRoundName) ? "Team" : leagueRoundName) + '" class="flex-row teams" role="columnheader">' + ((!leagueRoundName) ? "Team" : leagueRoundName) + '</div>';
1239                                                    htmlInsideTabsConstructorS += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
1240                                                    htmlInsideTabsConstructorS += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
1241                                                    htmlInsideTabsConstructorS += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
1242                                                    htmlInsideTabsConstructorS += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
1243                                                    htmlInsideTabsConstructorS += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
1244                                                    htmlInsideTabsConstructorS += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
1245                                                    htmlInsideTabsConstructorS += '</div>';
1246                                                    htmlInsideTabsConstructorS += '<div class="table__body">';
1247                                                    var colorForStanding = ['colorOne', 'colorTwo', 'colorThree', 'colorFour', 'colorFive', 'colorSix', 'colorSeven', 'colorEight', 'colorNine', 'colorTen'];
1248                                                    var colorStringValue = -1;
1249                                                    var stringToCompareStandings = '';
1250                                                    $.each(onlySelectedGroup, function (keys, values) {
1251                                                        htmlInsideTabsConstructorS += '<div class="flex-table row" role="rowgroup">';
1252                                                        if (values.promotion) {
1253                                                            if (stringToCompareStandings != values.promotion) {
1254                                                                str
1254ingToCompareStandings = values.promotion;
1255                                                                colorStringValue++;
1256                                                                colorForStanding[colorStringValue];
1257                                                                htmlInsideTabsConstructorS += '<div class="flex-row first-sticky fix-width ' + colorForStanding[colorStringValue] + '" title="' + values.promotion + '" role="cell">' + values.league_position + '.</div>';
1258                                                            } else if (stringToCompareStandings == values.promotion) {
1259                                                                colorForStanding[colorStringValue];
1260                                                                htmlInsideTabsConstructorS += '<div class="flex-row first-sticky fix-width ' + colorForStanding[colorStringValue] + '" title="' + values.promotion + '" role="cell">' + values.league_position + '.</div>';
1261                                                            }
1262                                                        } else if (!values.promotion) {
1263                                                            colorStringValue = $(colorForStanding).length / 2;
1264                                                            htmlInsideTabsConstructorS += '<div class="flex-row first-sticky fix-width ' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + '" role="cell">' + values.league_position + '.</div>';
1265                                                        }
1266                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row teams" role="cell"><a href="#" onclick="windowPreventOpening()">' + values.team_name + '</a></div>';
1267                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_payed + '</div>';
1268                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_W + '</div>';
1269                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_D + '</div>';
1270                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_L + '</div>';
1271                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row goals" role="cell">' + values.league_GF + ':' + values.league_GA + '</div>';
1272                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_PTS + '</div>';
1273                                                        htmlInsideTabsConstructorS += '</div>';
1274                                                    });
1275                                                    htmlInsideTabsConstructorS += '</div>';
1276                                                }
1277                                                htmlInsideTabsConstructorS += '</div>';
1278                                                htmlInsideTabsConstructorS += '</section>';
1279                                                firstElementInJson++
1280                                            } else {
1281                                                htmlConstructorS += '<a href="#' + key + '" class="standing-h2 nav-tab">' + key + '</a>';
1282                                                htmlInsideTabsConstructorS += '<section id="' + key + '" class="tab-content">';
1283                                                htmlInsideTabsConstructorS += '<div class="tablele-container">';
1284                                                if ($.isEmptyObject(onlySelectedGroup)) {
1285                                                    htmlInsideTabsConstructorS += '<div class="flex-table header" role="rowgroup">';
1286                                                    htmlInsideTabsConstructorS += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
1287                                                    htmlInsideTabsConstructorS += '<div title="Team" class="flex-row teams" role="columnheader">Team</div>';
1288                                                    htmlInsideTabsConstructorS += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
1289                                                    htmlInsideTabsConstructorS += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
1290                                                    htmlInsideTabsConstructorS += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
1291                                                    htmlInsideTabsConstructorS += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
1292                                                    htmlInsideTabsConstructorS += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
1293                                                    htmlInsideTabsConstructorS += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
1294                                                    htmlInsideTabsConstructorS += '</div>';
1295                                                    htmlInsideTabsConstructorS += '<div class="table__body">';
1296                                                    htmlInsideTabsConstructorS += '<div class="flex-table-error row" role="rowgroup">';
1297                                                    htmlInsideTabsConstructorS += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>';
1298                                                    htmlInsideTabsConstructorS += '</div>';
1299                                                    htmlInsideTabsConstructorS += '</div>';
1300                                                } else {
1301                                                    htmlInsideTabsConstructorS += '<div class="flex-table header">';
1302                                                    htmlInsideTabsConstructorS += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
1303                                                    htmlInsideTabsConstructorS += '<div title="' + ((!leagueRoundName) ? "Team" : leagueRoundName) + '" class="flex-row teams" role="columnheader">' + ((!leagueRoundName) ? "Team" : leagueRoundName) + '</div>';
1304                                                    htmlInsideTabsConstructorS += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
1305                                                    htmlInsideTabsConstructorS += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
1306                                                    htmlInsideTabsConstructorS += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
1307                                                    htmlInsideTabsConstructorS += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
1308                                                    htmlInsideTabsConstructorS += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
1309                                                    htmlInsideTabsConstructorS += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
1310                                                    htmlInsideTabsConstructorS += '</div>';
1311                                                    htmlInsideTabsConstructorS += '<div class="table__body">';
1312
1313                                                    var sortStandingTabs = onlySelectedGroup;
1314                                                    sortStandingTabs.sort(function (a, b) {
1315                                                        return b.league_PTS - a.league_PTS
1316                                                    });
1317
1318                                                    var league_position_nb = 1;
1319                                                    $.each(sortStandingTabs, function (keys, values) {
1320                                                        htmlInsideTabsConstructorS += '<div class="flex-table row" role="rowgroup">';
1321                                                        htmlInsideTabsConstructorS += '<div class="flex-row first fix-width" role="cell">' + league_position_nb + '.</div>';
1322                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row teams" role="cell"><a href="#" onclick="windowPreventOpening()">' + values.team_name + '</a></div>';
1323                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_payed + '</div>';
1324                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_W + '</div>';
1325                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_D + '</div>';
1326                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_L + '</div>';
1327                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row goals" role="cell">' + values.league_GF + ':' + values.league_GA + '</div>';
1328                                                        htmlInsideTabsConstructorS += '<div class="' + (((hometeamKeyMain == values.team_id) || (awayteamKeyMain == values.team_id)) ? 'selectedMatchStandings' : '') + ' flex-row fix-width" role="cell">' + values.league_PTS + '</div>';
1329                                                        htmlInsideTabsConstructorS += '</div>';
1330                                                        league_position_nb++;
1331                                                    });
1332                                                    htmlInsideTabsConstructorS += '</div>';
1333                                                }
1334                                                htmlInsideTabsConstructorS += '</div>';
1335                                                htmlInsideTabsConstructorS += '</section>';
1336                                            }
1337                                        });
1338                                        htmlInsideTabsConstructorS += '</div>';
1339                                        $('#matchStandings .tab-container').append(htmlInsideTabsConstructorS);
1340                                        $('#matchStandings .nav-tab-wrapper').prepend(htmlConstructorS);
1341
1342                                        // Switching tabs on click
1343                                        $('#matchStandings .nav-tab').unbind('click').on('click', function (e) {
1344                                            e.preventDefault();
1345                                            //Toggle tab link
1346                                            $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
1347                                            //Toggle target tab
1348                                            $($(this).attr('href')).addClass('active').siblings().removeClass('active');
1349                                        });
1350                                    });
1351                                    htmlConstructor += '</div>';
1352                                    htmlConstructor += '</section>';
1353                                }
1354
1355                                // Populate Match Odds section
1356                                htmlConstructor += '<section id="matchOdds" class="tab-content">';
1357                                htmlConstructor += '<div class="tab-container">';
1358
1359                                // Send server request for Standings
1360                                $.ajax({
1361                                    url: matchResultsDetailsAjaxURL,
1362                                    cache: false,
1363                                    data: {
1364                                        action: 'get_odds',
1365                                        Widgetkey: Widgetkey,
1366                                        from: sessionStorage.getItem('fixturesDate'),
1367                                        to: sessionStorage.getItem('fixturesDate'),
1368                                        match_id: res[0].match_id
1369                                    },
1370                                    dataType: 'json'
1371                                }).done(function(res) {
1372
1373                                    // If server send results hide loading
1374                                    $('.loading').hide();
1375
1376                                    if(!res.error){
1377
1378                                        $('.d-none-tab-odds').removeClass('d-none-tab-odds');
1379
1380                                        var htmlInsideTabsConstructorO = '<div class="nav-tab-wrapper">';
1381                                        var htmlConstructorO = '<a href="#1x2" class="standing-h2 nav-tab nav-tab-active">1x2</a>';
1382                                        htmlConstructorO += '<a href="#ah" class="standing-h2 nav-tab">Asian Handicap</a>';
1383                                        htmlConstructorO += '<a href="#ou" class="standing-h2 nav-tab">O/U</a>';
1384                                        htmlConstructorO += '<a href="#bts" class="standing-h2 nav-tab">BTS</a>';
1385
1386                                        htmlInsideTabsConstructorO += '<section id="1x2" class="tab-content active">';
1387                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
1388                                        htmlInsideTabsConstructorO += '<div class="flex-table header" role="rowgroup">';
1389                                        htmlInsideTabsConstructorO += '<div title="Bookmakers" class="flex-row bookmakers" role="columnheader">Bookmakers</div>';
1390                                        htmlInsideTabsConstructorO += '<div title="1" class="flex-row oddWidth" role="columnheader">1</div>';
1391                                        htmlInsideTabsConstructorO += '<div title="X" class="flex-row oddWidth" role="columnheader">X</div>';
1392                                        htmlInsideTabsConstructorO += '<div title="2" class="flex-row oddWidth" role="columnheader">2</div>';
1393                                        htmlInsideTabsConstructorO += '</div>';
1394                                        htmlInsideTabsConstructorO += '<div class="table__body">';
1395                                        var onextwo = '';
1396                                        htmlInsideTabsConstructorO += '</div>';
1397                                        htmlInsideTabsConstructorO += '</div>';
1398                                        htmlInsideTabsConstructorO += '</section>';
1399
1400                                        htmlInsideTabsConstructorO += '<section id="ou" class="tab-content">';
1401                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
1402                                        htmlInsideTabsConstructorO += '</div>';
1403                                        htmlInsideTabsConstructorO += '</section>';
1404
1405                                        htmlInsideTabsConstructorO += '<section id="bts" class="tab-content">';
1406                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
1407                                        htmlInsideTabsConstructorO += '<div class="flex-table header" role="rowgroup">';
1408                                        htmlInsideTabsConstructorO += '<div title="Bookmakers" class="flex-row bookmakers" role="columnheader">Bookmakers</div>';
1409                                        htmlInsideTabsConstructorO += '<div title="Yes" class="flex-row oddWidth" role="columnheader">Yes</div>';
1410                                        htmlInsideTabsConstructorO += '<div title="No" class="flex-row oddWidth" role="columnheader">No</div>';
1411                                        htmlInsideTabsConstructorO += '</div>';
1412                                        htmlInsideTabsConstructorO += '<div class="table__body">';
1413                                        var btsyesno = '';
1414                                        htmlInsideTabsConstructorO += '</div>';
1415                                        htmlInsideTabsConstructorO += '</div>';
1416                                        htmlInsideTabsConstructorO += '</section>';
1417
1418                                        htmlInsideTabsConstructorO += '<section id="ah" class="tab-content">';
1419                                        htmlInsideTabsConstructorO += '<div class="tablele-container">';
1420                                        htmlInsideTabsConstructorO += '</div>';
1421                                        htmlInsideTabsConstructorO += '</section>';
1422
1423                                        var ahminus45 = [], ahminus4 = [], ahminus35 = [], ahminus3 = [], ahminus25 = [], ahminus2 = [], ahminus15 = [], ahminus1 
1423= [], ahminus05 = [], ah0 = [], ahplus05 = [], ahplus1 = [], ahplus15 = [], ahplus2 = [], ahplus25 = [], ahplus3 = [], ahplus35 = [], ahplus4 = [], ahplus45 = [], ou05 = [], ou1 = [], ou15 = [], ou2 = [], ou25 = [], ou3 = [], ou35 = [], ou4 = [], ou45 = [], ou5 = [], ou55 = [];
1424
1425                                        var asianHandicapArray = {
1426                                            'ah-4.5' : ahminus45 = [],
1427                                            'ah-4' : ahminus4 = [],
1428                                            'ah-3.5' : ahminus35 = [],
1429                                            'ah-3' : ahminus3 = [],
1430                                            'ah-2.5' : ahminus25 = [],
1431                                            'ah-2' : ahminus2 = [],
1432                                            'ah-1.5' : ahminus15 = [],
1433                                            'ah-1' : ahminus1 = [],
1434                                            'ah-0.5' : ahminus05 = [],
1435                                            'ah-0' : ah0 = [],
1436                                            'ah+0.5' : ahplus05 = [],
1437                                            'ah+1' : ahplus1 = [],
1438                                            'ah+1.5' : ahplus15 = [],
1439                                            'ah+2' : ahplus2 = [],
1440                                            'ah+2.5' : ahplus25 = [],
1441                                            'ah+3' : ahplus3 = [],
1442                                            'ah+3.5' : ahplus35 = [],
1443                                            'ah+4' : ahplus4 = [],
1444                                            'ah+4.5' : ahplus45 = [],
1445                                        };
1446
1447                                        var overUnderArray = {
1448                                            '0.5' : ou05 = [],
1449                                            '1' : ou1 = [],
1450                                            '1.5' : ou15 = [],
1451                                            '2' : ou2 = [],
1452                                            '2.5' : ou25 = [],
1453                                            '3' : ou3 = [],
1454                                            '3.5' : ou35 = [],
1455                                            '4' : ou4 = [],
1456                                            '4.5' : ou45 = [],
1457                                            '5' : ou5 = [],
1458                                            '5.5' : ou55 = [],
1459                                        };
1460
1461                                        $.each(res, function(key, value) {
1462
1463                                            if(value['odd_1'] !== '' || value['odd_x'] !== '' || value['odd_2'] !== '') {
1464                                                onextwo += '<div class="flex-table row" role="rowgroup">';
1465                                                onextwo += '<div class="flex-row bookmakers" role="cell">' + ((typeof value.odd_bookmakers != 'undefined') ? value.odd_bookmakers : '' ) + '</div>';
1466                                                onextwo += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.odd_1 != 'undefined') ? value.odd_1 : '' ) + '</div>';
1467                                                onextwo += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.odd_x != 'undefined') ? value.odd_x : '' ) + '</div>';
1468                                                onextwo += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.odd_2 != 'undefined') ? value.odd_2 : '' ) + '</div>';
1469                                                onextwo += '</div>';
1470                                            }
1471
1472                                            if(value['bts_no'] !== '' || value['bts_yes'] !== '') {
1473                                                btsyesno += '<div class="flex-table row" role="rowgroup">';
1474                                                btsyesno += '<div class="flex-row bookmakers" role="cell">' + ((typeof value.odd_bookmakers != 'undefined') ? value.odd_bookmakers : '' ) + '</div>';
1475                                                btsyesno += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.bts_yes != 'undefined') ? value.bts_yes : '' ) + '</div>';
1476                                                btsyesno += '<div class="flex-row oddWidth" role="cell">' + ((typeof value.bts_no != 'undefined') ? value.bts_no : '' ) + '</div>';
1477                                                btsyesno += '</div>';
1478                                            }
1479
1480                                            $.each(asianHandicapArray, function(key, values) {
1481                                                if((typeof value[key + '_1'] !== 'undefined' && value[key + '_1'] !== '') || (typeof value[key + '_2'] !== 'undefined' && value[key + '_2'] !== '')){
1482                                                    whatToPush(values, value.odd_bookmakers, value[key + '_1'], value[key + '_2']);
1483                                                }
1484                                            });
1485
1486                                            $.each(overUnderArray, function(key, values) {
1487                                                if((typeof value['o+' + key] !== 'undefined' && value['o+' + key] !== '') || (typeof value['u+' + key] !== 'undefined' && value['u+' + key] !== '')){
1488                                                    whatToPush(values, value.odd_bookmakers, value['o+' + key], value['u+' + key]);
1489                                                }
1490                                            });
1491
1492                                        });
1493
1494                                        var asianHandicapData = {
1495                                            "Asian handicap -4.5" : ahminus45,
1496                                            "Asian handicap -4" : ahminus4,
1497                                            "Asian handicap -3.5" : ahminus35,
1498                                            "Asian handicap -3" : ahminus3,
1499                                            "Asian handicap -2.5" : ahminus25,
1500                                            "Asian handicap -2" : ahminus2,
1501                                            "Asian handicap -1.5" : ahminus15,
1502                                            "Asian handicap -1" : ahminus1,
1503                                            "Asian handicap -0.5" : ahminus05,
1504                                            "Asian handicap 0" : ah0,
1505                                            "Asian handicap +0.5" : ahplus05,
1506                                            "Asian handicap +1" : ahplus1,
1507                                            "Asian handicap +1.5" : ahplus15,
1508                                            "Asian handicap +2" : ahplus2,
1509                                            "Asian handicap +2.5" : ahplus25,
1510                                            "Asian handicap +3" : ahplus3,
1511                                            "Asian handicap +3.5" : ahplus35,
1512                                            "Asian handicap +4" : ahplus4,
1513                                            "Asian handicap +4.5" : ahplus45
1514                                        };
1515
1516                                        var allHandicaps = '';
1517
1518                                        $.each(asianHandicapData, function(key, value) {
1519                                            if(value != ''){
1520                                                allHandicaps += '<div class="flex-table header" role="rowgroup">';
1521                                                allHandicaps += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
1522                                                allHandicaps += '<div title="Home" class="flex-row oddWidth" role="columnheader">Home</div>';
1523                                                allHandicaps += '<div title="Away" class="flex-row oddWidth" role="columnheader">Away</div>';
1524                                                allHandicaps += '</div>';
1525                                                allHandicaps += '<div class="table__body">';
1526                                                $.each(value, function(keys, values) {
1527                                                    allHandicaps += '<div class="flex-table row" role="rowgroup">';
1528                                                    allHandicaps += '<div class="flex-row bookmakers" role="cell">' + values.bookmaker + '</div>';
1529                                                    allHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.one + '</div>';
1530                                                    allHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.two + '</div>';
1531                                                    allHandicaps += '</div>';
1532                                                });
1533                                                allHandicaps += '</div>';
1534                                            }
1535                                        });
1536
1537                                        var ouData = {
1538                                            "Over/Under +0.5" : ou05,
1539                                            "Over/Under +1" : ou1,
1540                                            "Over/Under +1.5" : ou15,
1541                                            "Over/Under +2" : ou2,
1542                                            "Over/Under +2.5" : ou25,
1543                                            "Over/Under +3" : ou3,
1544                                            "Over/Under +3.5" : ou35,
1545                                            "Over/Under +4" : ou4,
1546                                            "Over/Under +4.5" : ou45,
1547                                            "Over/Under +5" : ou5,
1548                                            "Over/Under +5.5" : ou55
1549                                        };
1550
1551                                        var allou = '';
1552
1553                                        $.each(ouData, function(key, value) {
1554                                            if(value != ''){
1555                                                allou += '<div class="flex-table header" role="rowgroup">';
1556                                                allou += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
1557                                                allou += '<div title="Over" class="flex-row oddWidth" role="columnheader">Over</div>';
1558                                                allou += '<div title="Under" class="flex-row oddWidth" role="columnheader">Under</div>';
1559                                                allou += '</div>';
1560                                                allou += '<div class="table__body">';
1561                                                $.each(value, function(keys, values) {
1562                                                    allou += '<div class="flex-table row" role="rowgroup">';
1563                                                    allou += '<div class="flex-row bookmakers" role="cell">' + values.bookmaker + '</div>';
1564                                                    allou += '<div class="flex-row oddWidth" role="cell">' + values.one + '</div>';
1565                                                    allou += '<div class="flex-row oddWidth" role="cell">' + values.two + '</div>';
1566                                                    allou += '</div>';
1567                                                });
1568                                                allou += '</div>';
1569                                            }
1570                                        });
1571
1572                                        htmlInsideTabsConstructorO += '</div>';
1573                                        $('#matchOdds .tab-container').append(htmlInsideTabsConstructorO);
1574                                        $('#matchOdds .nav-tab-wrapper').prepend(htmlConstructorO);
1575
1576                                        if(onextwo.length > 0){
1577                                            $('#1x2 .tablele-container .table__body').append(onextwo);
1578                                        } else {
1579                                            $('#1x2 .tablele-container .table__body').append('<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>');
1580                                        }
1581
1582                                        if(btsyesno.length > 0){
1583                                            $('#bts .tablele-container .table__body').append(btsyesno);
1584                                        } else {
1585                                            $('#bts .tablele-container .table__body').append('<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>');
1586                                        }
1587
1588                                        if(allHandicaps.length > 0){
1589                                            $('#ah .tablele-container').append(allHandicaps);
1590                                        } else {
1591                                            $('#ah .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Asian handicap" class="flex-row bookmakers" role="columnheader">Asian handicap</div><div title="1" class="flex-row oddWidth" role="columnheader">1</div><div title="2" class="flex-row oddWidth" role="columnheader">2</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
1592                                        }
1593
1594                                        if(allou.length > 0){
1595                                            $('#ou .tablele-container').append(allou);
1596                                        } else {
1597                                            $('#ou .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Over/Under" class="flex-row bookmakers" role="columnheader">Over/Under</div><div title="Over" class="flex-row oddWidth" role="columnheader">Over</div><div title="Under" class="flex-row oddWidth" role="columnheader">Under</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
1598                                        }
1599
1600                                        // Switching tabs on click
1601                                        $('#matchOdds .nav-tab').unbind('click').on('click', function(e) {
1602                                            e.preventDefault();
1603                                            //Toggle tab link
1604                                            $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
1605                                            //Toggle target tab
1606                                            $($(this).attr('href')).addClass('active').siblings().removeClass('active');
1607                                        });
1608                                    } else {
1609                                        $('#matchOdds .tab-container').addClass('lineForNoData').prepend('<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>');
1610                                    }
1611                                });
1612                                htmlConstructor += '</div>';
1613                                htmlConstructor += '</section>';
1614
1615                                // Populate Match Prediction section
1616                                htmlConstructor += '<section id="matchPredictions" class="tab-content">';
1617                                htmlConstructor += '<div class="tab-container">';
1618
1619                                // Send server request for Standings
1620                                $.aja
1620x({
1621                                    url: matchResultsDetailsAjaxURL,
1622                                    cache: false,
1623                                    data: {
1624                                        action: 'get_predictions',
1625                                        Widgetkey: Widgetkey,
1626                                        from: sessionStorage.getItem('fixturesDate'),
1627                                        to: sessionStorage.getItem('fixturesDate'),
1628                                        match_id: res[0].match_id
1629                                    },
1630                                    dataType: 'json'
1631                                }).done(function(res) {
1632
1633                                    // If server send results hide loading
1634                                    $('.loading').hide();
1635
1636                                    if(!res.error){
1637
1638                                        $('.d-none-tab-prediction').removeClass('d-none-tab-prediction');
1639
1640                                        var htmlInsideTabsConstructorP = '<div class="nav-tab-wrapper">';
1641                                        var htmlConstructorO = '<a href="#p1x2" class="standing-h2 nav-tab nav-tab-active">1x2</a>';
1642                                        htmlConstructorO += '<a href="#pdc" class="standing-h2 nav-tab">Double Chance</a>';
1643                                        htmlConstructorO += '<a href="#pah" class="standing-h2 nav-tab">Asian Handicap</a>';
1644                                        htmlConstructorO += '<a href="#pou" class="standing-h2 nav-tab">O/U</a>';
1645                                        htmlConstructorO += '<a href="#pbts" class="standing-h2 nav-tab">BTS</a>';
1646
1647                                        htmlInsideTabsConstructorP += '<section id="p1x2" class="tab-content active">';
1648                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
1649                                        htmlInsideTabsConstructorP += '<div class="flex-table header" role="rowgroup">';
1650                                        htmlInsideTabsConstructorP += '<div title="" class="flex-row bookmakers" role="columnheader"></div>';
1651                                        htmlInsideTabsConstructorP += '<div title="1" class="flex-row oddWidth" role="columnheader">1</div>';
1652                                        htmlInsideTabsConstructorP += '<div title="X" class="flex-row oddWidth" role="columnheader">X</div>';
1653                                        htmlInsideTabsConstructorP += '<div title="2" class="flex-row oddWidth" role="columnheader">2</div>';
1654                                        htmlInsideTabsConstructorP += '</div>';
1655                                        htmlInsideTabsConstructorP += '<div class="table__body">';
1656                                        if(res[0]['prob_HW'] !== '' || res[0]['prob_D'] !== '' || res[0]['prob_AW'] !== '') {
1657                                            htmlInsideTabsConstructorP += '<div class="flex-table row" role="rowgroup">';
1658                                            htmlInsideTabsConstructorP += '<div class="flex-row bookmakers" role="cell">Chance</div>';
1659                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_HW != 'undefined') ? res[0].prob_HW : '' ) + '</div>';
1660                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_D != 'undefined') ? res[0].prob_D : '' ) + '</div>';
1661                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_AW != 'undefined') ? res[0].prob_AW : '' ) + '</div>';
1662                                            htmlInsideTabsConstructorP += '</div>';
1663                                        } else {
1664                                            htmlInsideTabsConstructorP += '<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>';
1665                                        }
1666                                        htmlInsideTabsConstructorP += '</div>';
1667                                        htmlInsideTabsConstructorP += '</div>';
1668                                        htmlInsideTabsConstructorP += '</section>';
1669
1670                                        htmlInsideTabsConstructorP += '<section id="pdc" class="tab-content">';
1671                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
1672                                        htmlInsideTabsConstructorP += '<div class="flex-table header" role="rowgroup">';
1673                                        htmlInsideTabsConstructorP += '<div title="" class="flex-row bookmakers" role="columnheader"></div>';
1674                                        htmlInsideTabsConstructorP += '<div title="1" class="flex-row oddWidth" role="columnheader">1</div>';
1675                                        htmlInsideTabsConstructorP += '<div title="X" class="flex-row oddWidth" role="columnheader">X</div>';
1676                                        htmlInsideTabsConstructorP += '<div title="2" class="flex-row oddWidth" role="columnheader">2</div>';
1677                                        htmlInsideTabsConstructorP += '</div>';
1678                                        htmlInsideTabsConstructorP += '<div class="table__body">';
1679                                        if(res[0]['prob_HW_D'] !== '' || res[0]['prob_HW_AW'] !== '' || res[0]['prob_AW_D'] !== '') {
1680                                            htmlInsideTabsConstructorP += '<div class="flex-table row" role="rowgroup">';
1681                                            htmlInsideTabsConstructorP += '<div class="flex-row bookmakers" role="cell">Chance</div>';
1682                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_HW_D != 'undefined') ? res[0].prob_HW_D : '' ) + '</div>';
1683                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_HW_AW != 'undefined') ? res[0].prob_HW_AW : '' ) + '</div>';
1684                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_AW_D != 'undefined') ? res[0].prob_AW_D : '' ) + '</div>';
1685                                            htmlInsideTabsConstructorP += '</div>';
1686                                        } else {
1687                                            htmlInsideTabsConstructorP += '<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>';
1688                                        }
1689                                        htmlInsideTabsConstructorP += '</div>';
1690                                        htmlInsideTabsConstructorP += '</div>';
1691                                        htmlInsideTabsConstructorP += '</section>';
1692
1693                                        htmlInsideTabsConstructorP += '<section id="pah" class="tab-content">';
1694                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
1695
1696                                        var pasianHandicapData = {
1697                                            "Asian handicap -4.5" : [{
1698                                                home : res[0]['prob_ah_h_-45'],
1699                                                away : res[0]['prob_ah_a_-45']
1700                                            }],
1701                                            "Asian handicap -3.5" : [{
1702                                                home : res[0]['prob_ah_h_-35'],
1703                                                away : res[0]['prob_ah_a_-35']
1704                                            }],
1705                                            "Asian handicap -2.5" : [{
1706                                                home : res[0]['prob_ah_h_-25'],
1707                                                away : res[0]['prob_ah_a_-25']
1708                                            }],
1709                                            "Asian handicap -1.5" : [{
1710                                                home : res[0]['prob_ah_h_-15'],
1711                                                away : res[0]['prob_ah_a_-15']
1712                                            }],
1713                                            "Asian handicap -0.5" : [{
1714                                                home : res[0]['prob_ah_h_-05'],
1715                                                away : res[0]['prob_ah_a_-05']
1716                                            }],
1717                                            "Asian handicap +0.5" : [{
1718                                                home : res[0]['prob_ah_h_05'],
1719                                                away : res[0]['prob_ah_a_05']
1720                                            }],
1721                                            "Asian handicap +1.5" : [{
1722                                                home : res[0]['prob_ah_h_15'],
1723                                                away : res[0]['prob_ah_a_15']
1724                                            }],
1725                                            "Asian handicap +2.5" : [{
1726                                                home : res[0]['prob_ah_h_25'],
1727                                                away : res[0]['prob_ah_a_25']
1728                                            }],
1729                                            "Asian handicap +3.5" : [{
1730                                                home : res[0]['prob_ah_h_35'],
1731                                                away : res[0]['prob_ah_a_35']
1732                                            }],
1733                                            "Asian handicap +4.5" : [{
1734                                                home : res[0]['prob_ah_h_45'],
1735                                                away : res[0]['prob_ah_a_45']
1736                                            }]
1737                                        };
1738
1739                                        var pallHandicaps = '';
1740
1741                                        $.each(pasianHandicapData, function(key, value) {
1742                                            if(value != ''){
1743                                                pallHandicaps += '<div class="flex-table header" role="rowgroup">';
1744                                                pallHandicaps += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
1745                                                pallHandicaps += '<div title="Home" class="flex-row oddWidth" role="columnheader">Home</div>';
1746                                                pallHandicaps += '<div title="Away" class="flex-row oddWidth" role="columnheader">Away</div>';
1747                                                pallHandicaps += '</div>';
1748                                                pallHandicaps += '<div class="table__body">';
1749                                                $.each(value, function(keys, values) {
1750                                                    pallHandicaps += '<div class="flex-table row" role="rowgroup">';
1751                                                    pallHandicaps += '<div class="flex-row bookmakers" role="cell">Chance</div>';
1752                                                    pallHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.home + '</div>';
1753                                                    pallHandicaps += '<div class="flex-row oddWidth" role="cell">' + values.away + '</div>';
1754                                                    pallHandicaps += '</div>';
1755                                                });
1756                                                pallHandicaps += '</div>';
1757                                            }
1758                                        });
1759
1760                                        htmlInsideTabsConstructorP += '</div>';
1761                                        htmlInsideTabsConstructorP += '</section>';
1762
1763                                        htmlInsideTabsConstructorP += '<section id="pou" class="tab-content">';
1764                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
1765
1766                                        var pouData = {
1767                                            "Over/Under" : [{
1768                                                over : res[0]['prob_O'],
1769                                                under : res[0]['prob_U']
1770                                            }],
1771                                            "Over/Under +1" : [{
1772                                                over : res[0]['prob_O_1'],
1773                                                under : res[0]['prob_U_1']
1774                                            }],
1775                                            "Over/Under +3" : [{
1776                                                over : res[0]['prob_O_3'],
1777                                                under : res[0]['prob_U_3']
1778                                            }]
1779                                        };
1780
1781                                        var pallou = '';
1782
1783                                        $.each(pouData, function(key, value) {
1784                                            if(value != ''){
1785                                                pallou += '<div class="flex-table header" role="rowgroup">';
1786                                                pallou += '<div title="'+key+'" class="flex-row bookmakers" role="columnheader">'+key+'</div>';
1787                                                pallou += '<div title="Over" class="flex-row oddWidth" role="columnheader">Over</div>';
1788                                                pallou += '<div title="Under" class="flex-row oddWidth" role="columnheader">Under</div>';
1789                                                pallou += '</div>';
1790                                                pallou += '<div class="table__body">';
1791                                                $.each(value, function(keys, values) {
1792                                                    pallou += '<div class="flex-table row" role="rowgroup">';
1793                                                    pallou += '<div class="flex-row bookmakers" role="cell">Chance</div>';
1794                                                    pallou += '<div class="flex-row oddWidth" role="cell">' + values.over + '</div>';
1795                                                    pallou += '<div class="flex-row oddWidth" role="cell">' + values.under + '</div>';
1796                                                    pallou += '</div>';
1797                                                });
1798                                                pallou += '</div>';
1799                                            }
1800                                        });
1801
1802                                        htmlInsideTabsConstructorP += '</div>';
1803                                        htmlInsideTabsConstructorP += '</section>';
1804
1805                                        htmlInsideTabsConstructorP += '<section id="pbts" class="tab-content">';
1806                                        htmlInsideTabsConstructorP += '<div class="tablele-container">';
1807                                        htmlInsideTabsConstructorP += '<div class="flex-table header" role="rowgroup">';
1808                                        htmlInsideTabsConstructorP += '<div title="" class="flex-row bookmakers" role="columnheader"></div>';
1809                                        htmlInsideTabsConstructorP += '<div title="Yes" class="flex-row oddWidth" role="columnheader">Yes</div>';
1810                                        htmlInsideTabsConstructorP += '<div title="No" class="flex-row oddWidth" role="columnheader">No</div>';
1811                                        htmlInsideTabsConstructorP += '</div>';
1812                                        htmlInsideTabsConstructorP += '<div class="table__body">';
1813                                        if(res[0]['prob_bts'] !== '' || res[0]['prob_ots'] !== '') {
1814                                            htmlInsideTabsConstructorP += '<div class="flex-table row" role="rowgroup">';
1815                                            htmlInsideTabsConstructorP += '<div class="flex-row bookmakers" role="cell">Chance</div>';
1816                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_bts != 'undefined') ? res[0].prob_bts : '' ) + '</div>';
1817                                            htmlInsideTabsConstructorP += '<div class="flex-row oddWidth" role="cell">' + ((typeof res[0].prob_ots != 'undefined') ? res[0].prob_ots : '' ) + '</div>';
1818                                            htmlInsideTabsConstructorP += '</div>';
1819                                        } else {
1820                                            htmlInsideTabsConstructorP += '<div class="flex-table-error row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 6px;">Sorry, no data!</p></div>';
1821                                        }
1822                                        htmlInsideTabsConstructorP += '</div>';
1823                                        htmlInsideTabsConstructorP += '</div>';
1824                                        htmlInsideTabsConstructorP += '</section>';
1825
1826                                        htmlInsideTabsConstructorP += '</div>';
1827                                        $('#matchPredictions .tab-container').append(htmlInsideTabsConstructorP);
1828                                        $('#matchPredictions .nav-tab-wrapper').prepend(htmlConstructorO);
1829
1830                                        if(pallHandicaps.length > 0){
1831                                            $('#pah .tablele-container').append(pallHandicaps);
1832                                        } else {
1833                                            $('#pah .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Asian handicap" class="flex-row bookmakers" role="columnheader">Asian handicap</div><div title="1" class="flex-row oddWidth" role="columnheader">1</div><div title="2" class="flex-row oddWidth" role="columnheader">2</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
1834                                        }
1835
1836                                        if(pallou.length > 0){
1837                                            $('#pou .tablele-container').append(pallou);
1838                                        } else {
1839                                            $('#pou .tablele-container').append('<div class="flex-table header" role="rowgroup"><div title="Over/Under" class="flex-row bookmakers" role="columnheader">Over/Under</div><div title="Over" class="flex-row oddWidth" role="columnheader">Over</div><div title="Under" class="flex-row oddWidth" role="columnheader">Under</div></div><div class="table__body"><div class="flex-table row" role="rowgroup"><p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p></div></div>');
1840                                        }
1841
1842                                        // Switching tabs on click
1843                                        $('#matchPredictions .nav-tab').unbind('click').on('click', function(e) {
1844                                            e.preventDefault();
1845                                            //Toggle tab link
1846                                            $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
1847                                            //Toggle target tab
1848                                            $($(this).attr('href')).addClass('active').siblings().removeClass('active');
1849                                        });
1850                                    } else {
1851                                        $('#matchPredictions .tab-container').addClass('lineForNoData').prepend('<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>');
1852                                    }
1853                                });
1854                                htmlConstructor += '</div>';
1855                                htmlConstructor += '</section>';
1856
1857                                htmlConstructor += '</div>';
1858                                htmlConstructor += '</div>';
1859                                $('#matchResultsContentTable').append(htmlConstructor);
1860                                // Added close button in HTML
1861                                $('#matchResultsContentTable').append('<p class="closeWindow">close window</p>');
1862                                // Added click function to close window
1863                                $('.closeWindow').click(function() {
1864                                    window.close();
1865                                });
1866                                // Switching tabs on click
1867                                $('.nav-tab').unbind('click').on('click', function(e) {
1868                                    e.preventDefault();
1869                                    //Toggle tab link
1870                                    $(this).addClass('nav-tab-active').parent().parent().siblings().find('a').removeClass('nav-tab-active');
1871                                    //Toggle target tab
1872                                    $($(this).attr('href')).addClass('active').siblings().removeClass('active');
1873                                });
1874                            }
1875                            clearInterval(seeWhatMatchDetailsToShow);
1876                        }
1877                    }, 10);
1878                } else {
1879                    // If server not sending data, show pop-up and after click closing window
1880                    alert('Sorry, no data!');
1881                    window.close();
1882                }
1883
1884            }).fail(function(error) {
1885
1886            });
1887        },
1888
1889        callback: function() {
1890
1891        }
1892
1893    });
1894
1895    function socketsLive(matchId, widgetKey){
1896      var socket  = new WebSocket('wss://wss.apifootball.com/livescore?matchId='+matchId+'&Widgetkey='+widgetKey+'&timezone='+getTimeZone());
1897      // Define the
1898      socket.onmessage = function(e) {
1899//                alert( e.data );
1900          if (e.data) {
1901            var data = JSON.parse(e.data);
1902              var windowWidthSize = $(window).width();
1903              res = Object();
1904              res = data;
1905              htmlConstructor = '';
1906              if (res) {
1907                htmlConstructor += '<div class="event_info_score">';
1908                htmlConstructor += '<div>' + res[0].match_hometeam_score + ' - ' + res[0].match_awayteam_score + '</div>';
1909                htmlConstructor += '</div>';
1910                htmlConstructor += '<div class="event_info_status">';
1911                var removeNumericAdd = res[0].match_status.replace('+', '');
1912                htmlConstructor += '<div class="' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? 'matchIsLive' : '') + '"> ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? res[0].match_status + ((removeNumericAdd == 'Half Time') ? '' : '\'') : res[0].match_status) + '</div>';
1913                htmlConstructor += '</div>';
1914                htmlConstructor += '</div>';
1915                $('.event_info').html(htmlConstructor);
1916                // Populate Match Summary section
1917                htmlConstructor = '';
1918                htmlConstructor += '<div class="tab-container">';
1919
1920                var substitutions_home_array = [res[0].substitutions.home];
1921                substitutions_home_array[0].forEach(function (whatTeam) {
1922                    whatTeam.whatTeam = 'home_team';
1923                });
1924
1925                var substitutions_away_array = [res[0].substitutions.away];
1926                substitutions_away_array[0].forEach(function (whatTeam) {
1927                    whatTeam.whatTeam = 'away_team';
1928                });
1929                var multipleArrays = [res[0].goalscorer, substitutions_home_array[0], substitutions_away_array[0], res[0].cards];
1930                var flatArray = [].concat.apply([], multipleArrays);
1931                var nrArray = flatArray;
1932                nrArray.sort(naturalCompare);
1933                var newArray = {};
1934                $.each(nrArray, function(key, value) {
1935                  if (!newArray[value['score_info_time']]) {
1936                    newArray[value['score_info_time']] = [];
1937                  }
1938                  newArray[value['score_info_time']].push(value);
1939                });
1940                var orderedNewArray = {
1941                  '1st Half': newArray['1st Half'] ? newArray['1st Half'] : false,
1942                  '2nd Half': newArray['2nd Half'] ? newArray['2nd Half'] : false,
1943                  'Extra Time': newArray['Extra Time'] ? newArray['Extra Time'] : false,
1944                  'Penalty': newArray['Penalty'] ? newArray['Penalty'] : false
1945                };
1946                if (nrArray.length == 0) {
1947                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>';
1948                } else {
1949                    var htmlCC = 0;
1950                    var htmlCC2 = 0;
1951                    var first = true;
1952                    $.each(orderedNewArray, function(key, valueSub) {
1953                      if (valueSub) {
1954                        if (first && key != '1st Half') {
1955                          htmlConstructor += '<div class="lineupsTitle">1st Half</div>';
1956                          htmlConstructor += '<div class="noHalfEvent">-</div>';
1957                        }
1958                        first = false;
1959                        htmlConstructor += '<div class="lineupsTitle">'+key+'</div>';
1960                        $.each(valueSub, function(key2, value) {
1961                          if ((value.home_scorer || value.away_scorer || value.info) && value.score !== "substitution" && value.score ) {
1962                              htmlConstructor += '<div class="' + ((value.home_scorer || value.info == 'home') ? 'action_home' : 'action_away') + '">' + ((value.home_scorer || value.info == 'home' ) ? value.time + '\'<div class="imgMatchSummary" style="background-image: url(img/ball.png);"></div>' + value.home_scorer : '') + ' ' + ((value.away_scorer || value.info == 'away' ) ? value.time + '\'' + '<div class="imgMatchSummary" style="background-image: url(img/ball.png);"></div>' + value.away_scorer : '') + '</div>';
1963                          }
1964                          if ((value.home_scorer == '') && (value.away_scorer == '') && value.info == '') {
1965                              htmlConstructor += '<div class="action_unknown">' + (value.time + '\'<div class="imgMatchSummary" style="background-image: url(img/ball.png);"></div>') + '</div>';
1966                          }
1967                          if ((value.home_fault || value.away_fault || value.info)  && !value.score) {
1968                              htmlConstructor += '<div class="' + ((value.home_fault || value.info == 'home') ? 'action_home' : 'action_away') + '">' + ((value.home_fault || value.info == 'home') ? value.time + '\' ' + ((value.card == 'yellow card') ? '<div class="imgMatchSummary" style="background-image: url(img/yellow_card.svg);"></div>' : '<div class="imgMatchSummary" style="background-image: url(img/red_card.svg);"></div>') + ' ' + value.home_fault : '') + ' ' + ((value.away_fault || value.info == 'away') ? value.time + '\'' + ' ' + ((value.card == 'yellow card') ? '<div class="imgMatchSummary" style="background-image: url(img/yellow_card.svg);"></div>' : '<div class="imgMatchSummary" style="background-image: url(img/red_card.svg);"></div>') + ' ' + value.away_fault : '') + '</div>';
1969                          }
1970                          if ((value.home_fault == '') && (value.away_fault == '') && value.info == ''  && !value.score) {
1971                              htmlConstructor += '<div class="action_unknown">' + ((value.card == 'yellow card') ? '<div class="imgMatchSummary" style="background-image: url(img/yellow_card.svg);"></div>' : '<div class="imgMatchSummary" style="background-image: url(img/red_card.svg);"></div>') + '</div>';
1972                          }
1973                          if (value.score === "substitution") {
1974                              htmlConstructor += '<div class="' + ((value.home_scorer.in) ? 'action_home' : 'action_away') + '">' + ((value.home_scorer.in) ? value.time + '\'<div class="imgMatchSummary" style="background-image: url(img/match_green.png);"></div>' + value.home_scorer.in + '<div class="imgMatchSummary" style="background-image: url(img/match_red.png);"></div>' + value.home_scorer.out : '') + ' ' + ((value.away_scorer.in) ? value.time + '\'' + '<div class="imgMatchSummary" style="background-image: url(img/match_green.png);"></div>' + value.away_scorer.in + '<div class="imgMatchSummary" style="background-image: url(img/match_red.png);"></div>' + value.away_scorer.out : '') + '</div>';
1975                          }
1976                        });
1977                      }
1978                    });
1979                    htmlConstructor += '</div>';
1980                }
1981                if ((res[0].match_referee != '') || (res[0].match_stadium != '')) {
1982                    htmlConstructor += '<div>';
1983                    htmlConstructor += '<div class="matchExtraInfosTitle">Match Information</div>';
1984                    htmlConstructor += '<div class="matchExtraInfos">' + ((res[0].match_referee != '') ? 'Referee: ' + res[0].match_referee : '') + ' ' + ((res[0].match_stadium != '') ? 'Stadium: ' + res[0].match_stadium : '') + '</div>';
1985                    htmlConstructor += '</div>';
1986                }
1987                $("#matchSummary").html(htmlConstructor);
1988
1989                // Populate Match Statistics section
1990                htmlConstructor = '';
1991                htmlConstructor += '<div class="tab-container">';
1992                if (res[0].statistics.length == 0) {
1993                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px; text-align:center;">Sorry, no data!</p>';
1994                } else {
1995                    $.each(res[0].statistics, function(key, value) {
1996                        if (JSON.stringify(value).indexOf('%') > -1) {
1997                            htmlConstructor += '<div class="matchStatisticsRow">';
1998                            htmlConstructor += '<div class="matchStatisticsRowText">';
1999                            htmlConstructor += '<div class="matchStatisticsRowHome">' + value.home + '</div>';
2000                            htmlConstructor += '<div class="matchStatisticsRowType">' + value.type + '</div>';
2001                            htmlConstructor += '<div class="matchStatisticsRowAway">' + value.away + '</div>';
2002                            htmlConstructor += '</div>';
2003                            htmlConstructor += '<div class="matchStatisticsRowBar">';
2004                            htmlConstructor += '<div class="matchStatisticsRowBarHome">';
2005                            htmlConstructor += '<div class="matchStatisticsRowBarHomeBg">';
2006                            htmlConstructor += '<div class="matchStatisticsRowHomeLine" style="width:' + value.home + ';background-color:' + ((value.home > value.away) ? 'red' : '') + ';"></div>';
2007                            htmlConstructor += '</div>';
2008                            htmlConstructor += '</div>';
2009                            htmlConstructor += '<div class="matchStatisticsRowBarAway">';
2010                            htmlConstructor += '<div class="matchStatisticsRowBarAwayBg">';
2011                            htmlConstructor += '<div class="matchStatisticsRowAwayLine" style="width:' + value.away + ';background-color:' + ((value.away > value.home) ? 'red' : '') + ';"></div>';
2012                            htmlConstructor += '</div>';
2013                            htmlConstructor += '</div>';
2014                            htmlConstructor += '</div>';
2015                            htmlConstructor += '</div>';
2016                        } else {
2017                            var x = parseInt(value.home) + parseInt(value.away);
2018                            var xx = 100 / x;
2019                            var tt = xx * value.home;
2020                            var vv = xx * value.away;
2021                            htmlConstructor += '<div class="matchStatisticsRow">';
2022                            htmlConstructor += '<div class="matchStatisticsRowText">';
2023                            htmlConstructor += '<div class="matchStatisticsRowHome">' + value.home + '</div>';
2024                            htmlConstructor += '<div class="matchStatisticsRowType">' + value.type + '</div>';
2025                            htmlConstructor += '<div class="matchStatisticsRowAway">' + value.away + '</div>';
2026                            htmlConstructor += '</div>';
2027                            htmlConstructor += '<div class="matchStatisticsRowBar">';
2028                            htmlConstructor += '<div class="matchStatisticsRowBarHome">';
2029                            htmlConstructor += '<div class="matchStatisticsRowBarHomeBg">';
2030                            htmlConstructor += '<div class="matchStatisticsRowHomeLine" style="width:' + tt + '%;background-color:' + ((tt > vv) ? 'red' : '') + ';"></div>';
2031                            htmlConstructor += '</div>';
2032                            htmlConstructor += '</div>';
2033                            htmlConstructor += '<div class="matchStatisticsRowBarAway">';
2034                            htmlConstructor += '<div class="matchStatisticsRowBarAwayBg">';
2035                            htmlConstructor += '<div class="matchStatisticsRowAwayLine" style="width:' + vv + '%;background-color:' + ((vv > tt) ? 'red' : '') + ';"></div>';
2036                            htmlConstructor += '</div>';
2037                            htmlConstructor += '</div>';
2038                            htmlConstructor += '</div>';
2039                            htmlConstructor += '</div>';
2040                        }
2041                    });
2042                }
2043                htmlConstructor += '</div>';
2044                $('#matchStatistics').html(htmlConstructor);
2045
2046                htmlConstructor = '';
2047                // Populate Match Lineups section
2048                htmlConstructor += '<section id="lineups" class="tab-content">';
2049                htmlConstructor += '<div class="tab-container">';
2050                htmlConstructor += '<div class="lineupsTitle">Starting Lineups</div>';
2051                htmlConstructor += '<div class="lineupsContainer">';
2052                if ((res[0].lineup.home.starting_lineups.length == 0) || (res[0].lineup.away.starting_lineups.length == 0)) {
2053                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px;">Sorry, no data!</p>';
2054                } else {
2055                    htmlConstructor += '<div class="col-left">';
2056                    $.each(res[0].lineup.home.starting_lineups, function(key, value) {
2057                        htmlConstructor += '<div class="lineupsContainerHome"><div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_home_badge + '\');"></div> <div class="lineupsPlayer">' + value.lineup_player + '</div></div>';
2058                    });
2059                    htmlConstructor += '</div>';
2060                    htmlConstructor += '<div class="col-right">';
2061                    $.each(res[0].lineup.away.starting_lineups, function(key, value) {
2062                        htmlConstructor += '<div class="lineupsContainerAway"><div class="lineupsPlayer">' + value.lineup_player + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_away_badge + '\');"></div> <div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div></div>';
2063                    });
2064                    htmlConstructor += '</div>';
2065                }
2066                htmlConstructor += '</div>';
2067
2068                // Populate Match Substitutes section
2069                htmlConstructor += '<div class="lineupsTitle">Substitutes</div>';
2070                htmlConstructor += '<div class="lineupsContainer">';
2071                if ((res[0].lineup.home.substitutes.length == 0) || (res[0].lineup.away.substitutes.length == 0)) {
2072                    htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px;">Sorry, no data!</p>';
2073                } else {
2074                    htmlConstructor += '<div class="col-left">';
2075                    $.each(res[0].lineup.home.substitutes, function(key, value) {
2076                        htmlConstructor += '<div class="lineupsContainerHome"><div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_home_badge + '\');"></div> <div class="lineupsPlayer">' + value.lineup_player + '</div></div>';
2077                    });
2078                    htmlConstructor += '</div>';
2079                    htmlConstructor += '<div class="col-right">';
2080                    $.each(res[0].lineup.away.substitutes, function(key, value) {
2081                        htmlConstructor += '<div class="lineupsContainerAway"><div class="lineupsPlayer">' + value.lineup_player + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_away_badge + '\');"></div> <div class="lineupsNb">' + ((value.lineup_number == '-1' ? ' ' : value.lineup_number)) + '</div></div>';
2082                    });
2083                    htmlConstructor += '</div>';
2084                }
2085                htmlConstructor += '</div>';
2086                htmlConstructor += '<div class="lineupsTitle">Coaches</div>';
2087                htmlConstructor += '<div class="lineupsContainer">';
2088                if ((res[0].lineup.home.coach.length == 0) || (res[0].lineup.away.coach.length == 0)) {
2089         
2089           htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 13px;">Sorry, no data!</p>';
2090                } else {
2091                    htmlConstructor += '<div class="col-left">';
2092                    $.each(res[0].lineup.home.coach, function(key, value) {
2093                        htmlConstructor += '<div class="lineupsContainerHome"><div class="lineupsNb"></div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_home_badge + '\');"></div> <div class="lineupsPlayer">' + value.lineup_player + '</div></div>';
2094                    });
2095                    htmlConstructor += '</div>';
2096                    htmlConstructor += '<div class="col-right">';
2097                    $.each(res[0].lineup.away.coach, function(key, value) {
2098                        htmlConstructor += '<div class="lineupsContainerAway"><div class="lineupsPlayer">' + value.lineup_player + '</div> <div class="lineupsFlag" style="background-image: url(\'' + res[0].team_away_badge + '\');"></div> <div class="lineupsNb"></div></div>';
2099                    });
2100                    htmlConstructor += '</div>';
2101                }
2102                htmlConstructor += '</div>';
2103                htmlConstructor += '</div>';
2104                $('#lineups').html(htmlConstructor);
2105              }
2106
2107              console.log(htmlConstructor);
2108          } else {
2109              // If server dont send new data we populate console.log with "No new data!"
2110              console.log('No new data!');
2111          }
2112      }
2113      socket.onclose = function(){
2114        // connection closed, discard old websocket and create a new one in 5s
2115        socket = null;
2116        setTimeout(function() {socketsLive(matchId, widgetKey); }, 5000);
2117      }
2118
2119    }
2120
2121    $.fn.widgetMatchResults = function(options) {
2122        this.each(function() {
2123            if (!$.data(this, "plugin_" + widgetMatchResults)) {
2124                $.data(this, "plugin_" + widgetMatchResults, new Plugin(this, options));
2125            }
2126        });
2127        return this;
2128    };
2129
2130    $.fn.widgetMatchResults.defaults = {
2131        // Widgetkey will be set in jqueryGlobals.js and can be obtained from your account
2132        Widgetkey: Widgetkey,
2133        // Action for this widget
2134        action: 'get_events',
2135        // Link to server data
2136        matchResultsDetailsAjaxURL: 'https://apiv3.apifootball.com/?',
2137        // Background color for your Leagues Widget
2138        backgroundColor: null,
2139        // Width for your widget
2140        widgetWidth: '100%',
2141        // Set the match Id (it will be set automaticaly when you click on a match)
2142        match_id: (sessionStorage.getItem('matchDetailsKey') ? sessionStorage.getItem('matchDetailsKey') : null),
2143        // Set the match league logo (it will be set automaticaly when you click on a match)
2144        leagueLogo: (sessionStorage.getItem('leagueLogo') ? sessionStorage.getItem('leagueLogo') : 'img/no-img.png')
2145    };
2146
2147})(jQuery, window, document);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.