PageSourceSearch

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

js arubafc.com collected 2026-10-03 18:20:49 UTC 42,055 bytes, 583 lines download raw bytes

1// ---------------------------------
2// ---------- widgetLeague ----------
3// ---------------------------------
4// Widget for League Display
5// ------------------------
6;
7(function($, window, document, undefined) {
8
9    var widgetLeague = 'widgetLeague';
10
11    function Plugin(element, options) {
12        this.element = element;
13        this._name = widgetLeague;
14        this._defaults = $.fn.widgetLeague.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.leagueDetailsAjaxURL, this.options.league_id, this.options.Widgetkey, this.options.league_name, this.options.leagueLogo, this.options.timezone);
27        },
28
29        // Remove plugin instance completely
30        destroy: function() {
31            this.unbindEvents();
32            this.$element.removeData();
33        },
34
35        // Cache DOM nodes for performance
36        buildCache: function() {
37            this.$element = $(this.element);
38        },
39
40        // Bind events that trigger actions
41        bindEvents: function() {
42            var plugin = this;
43        },
44
45        // Unbind events that trigger actions
46        unbindEvents: function() {
47            this.$element.off('.' + this._name);
48        },
49
50        initialContent: function(leagueDetailsAjaxURL, league_id, Widgetkey, league_name, leagueLogo, timezone) {
51
52            // Get widget location
53            var leagueLocation = $(this.element);
54            // Adding loading screen
55            $('<div class="loading">Loading&#8230;</div>').prependTo($(leagueLocation));
56            // Construct the Standings Tab click
57            $('<a href="#standingsTabC" class="titleWidget nav-tab">Standings</a>').prependTo($(leagueLocation));
58            // Construct the Fixtures Tab click
59            $('<a href="#fixturesTabC" class="titleWidget nav-tab">Fixtures</a>').prependTo($(leagueLocation));
60            // Construct the Results Tab click
61            $('<a href="#resultsTabC" class="titleWidget nav-tab nav-tab-active">Results</a>').prependTo($(leagueLocation));
62            // Construct the header for above tabs with logo and name of league
63            $('<div class="league_nameCon"><div class="league_nameImg" style="background-image: url(\'' + (((leagueLogo == '') || (leagueLogo == 'null') || (leagueLogo == 'https://apiv3.apifootball.com/badges/logo_leagues/-1')) ? noImgLocation.noImgUrl : leagueLogo) + '\');"></div><p class="league_name">' + league_name + '</p></div>').prependTo($(leagueLocation));
64
65            // Adding the "widgetLeague" class for styling and easyer targeting
66            leagueLocation.addClass('widgetLeague');
67
68            // If backgroundColor setting is set, here we activate the color 
69            if (this.options.backgroundColor) {
70                leagueLocation.css('background-color', this.options.backgroundColor);
71            }
72
73            // If widgetWidth setting is set, here we set the width of the list 
74            if (this.options.widgetWidth) {
75                leagueLocation.css('width', this.options.widgetWidth);
76            }
77
78            // Add hook in HTML for Results Tab content infos and make it active
79            var htmlConstructorResults = '<div id="resultsTabC" class="results-nav-tab-wrapper tab-content active">';
80            
81            var getTimeForFixturesResults = setInterval(function () {
82                if (timeForFixtures.length > 0) {
83                    // Set "from" date and "to" date for displaying the wanted interval - currently set to 3 months ago
84                    var formattedDatess = new Date(timeForFixtures + "T00:00");
85                    var dss = formattedDatess.getDate();
86                    var mss = formattedDatess.getMonth() + 1;
87                    var yss = formattedDatess.getFullYear();
88                    var dateForFixtureToNow = yss + '-' + (mss < 10 ? '0' + mss : mss) + '-' + (dss < 10 ? '0' + dss : dss);
89                    var mss2 = formattedDatess.setMonth(formattedDatess.getMonth() - 3);
90                    var formattedDatess2 = new Date(mss2);
91                    var dss2 = formattedDatess2.getDate();
92                    var mss2 = formattedDatess2.getMonth() + 1;
93                    var yss2 = formattedDatess2.getFullYear();
94                    var dateForFixtureFromPast = yss2 + '-' + (mss2 < 10 ? '0' + mss2 : mss2) + '-' + (dss2 < 10 ? '0' + dss2 : dss2);
95                    // Make call to server to get information about league Fixtures
96                    $.ajax({
97                        url: leagueDetailsAjaxURL,
98                        cache: false,
99                        data: {
100                            action: 'get_events',
101                            Widgetkey: Widgetkey,
102                            from: dateForFixtureFromPast,
103                            to: dateForFixtureToNow,
104                            league_id: league_id,
105                            timezone: timezone,
106                            withoutDetails: true
107                        },
108                        dataType: 'json'
109                    }).done(function(res) {
110
111                        // If server send data, hide loading sreen
112                        $('.loading').hide();
113                        // Add HTML hook for results tab content
114                        $('#resultsTabC').append('<section id="resultsContentTable"></section>');
115
116                        // If server send results we populate HTML with sended information
117                        if (!res.error) {
118
119                            // Order information by Event Date and then group them by League Round
120                            var sorted = sortByKey(res, 'key');
121                            var sorted_array = sortByKeyDesc(sorted, "match_date");
122                            var groubedByTeam = groupBy(sorted_array, 'match_round');
123                            var htmlConstructor = '<div class="tablele-container">';
124                            var countryName = res[0].country_name;
125                            var seeWhatTitle = [];
126
127                            $.each(groubedByTeam, function(key, value) {
128
129                                var keyForTitle = key.replace(/\/| |-|  /g, '');
130                                htmlConstructor += '<div class="flex-table header '+((keyForTitle) ? keyForTitle : 'Team')+'" role="rowgroup" style="display: none;">';
131                                htmlConstructor += '<div title="' + ((key) ? key : 'Team') + '" class="flex-row" role="columnheader">' + ((key) ? key : 'Team') + '</div>';
132                                htmlConstructor += '</div>';
133                                htmlConstructor += '<div class="table__body_results">';
134
135                                $.each(value, function(keys, values) {
136                                    // Now time in milliseconds
137                                    var dtNow = new Date();
138                                    var nowTimeMilliseconds = dtNow.getTime();
139                                    // Match time in milliseconds
140                                    var dtMatch = new Date((values.match_date + ' ' + values.match_time).replace(/-/g, "/"));
141                                    var matchTimeMilliseconds = dtMatch.getTime();
142                                    // Compare times for showing just matches before Now time
143                                    if (nowTimeMilliseconds > matchTimeMilliseconds) {
144                                        if (values.match_hometeam_score == null || values.match_awayteam_score == null) {
145                                            var event_final_result_class_away = '';
146                                            var event_final_result_class_home = '';
147                                        } else {
148                                        var event_final_result_class_away = values.match_awayteam_score;
149                                        var event_final_result_class_home = values.match_hometeam_score;
150                                        }
151                                    var formattedDate = new Date(values.match_date.replace(/-/g, "/"));
152                                        var d = formattedDate.getDate();
153                                        var m = formattedDate.getMonth() + 1;
154                                    var str = values.match_time;
155                                        if (str.search(/Postp/i) > 0) {
156                                        var match_time_simple = str.split("\n")[0];
157                                        var match_time_postp = str.split("\n").pop();
158                                        var match_time_exact = '<div class="match_time_text_align"><div class="resultslineThrough">' + d + '.' + m + ' ' + match_time_simple + '</div><div><div>' + match_time_postp + '</div></div></div>';
159                                        } else {
160                                        var match_time_exact = (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + ' ' + values.match_time;
161                                        }
162                                    var generatedLink = countryName+'/'+league_name+'/'+values.match_hometeam_name+'-vs-'+values.match_awayteam_name+'/'+values.match_date+'/'+values.match_id;
163                                        var newGeneratedLink = generatedLink.replace(/\s/g,'-');
164                                    htmlConstructor += '<a href="widgetMatchResults.php?'+newGeneratedLink+'" class="flex-table row" role="rowgroup" onclick="event.preventDefault(); windowOpenMatch(' + values.match_id + ', false, \'' + values.match_date  + '\', \'' + countryName + '\', \'' + league_name + '\', \'' + values.match_hometeam_name + '\', \'' + values.match_awayteam_name + '\')" title="Click for match detail!">';
165                                    htmlConstructor += '<div class="flex-row matchDetails" role="cell">' + match_time_exact + '</div>';
166                                        if (event_final_result_class_home > event_final_result_class_away) {
167                                        htmlConstructor += '<div class="flex-row matchHomeTeam winningMatchStyle" role="cell">' + values.match_hometeam_name + '</div>';
168                                        htmlConstructor += '<div class="flex-row matchDelimiter winningMatchStyle" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>';
169                                        htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>';
170                                        } else if (event_final_result_class_home < event_final_result_class_away) {
171                                        htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>';
172                                        htmlConstructor += '<div class="flex-row matchDelimiter winningMatchStyle" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>';
173                                        htmlConstructor += '<div class="flex-row matchAwayTeam winningMatchStyle" role="cell">' + values.match_awayteam_name + '</div>';
174                                        } else if (event_final_result_class_home == event_final_result_class_away) {
175                                        htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>';
176                                        htmlConstructor += '<div class="flex-row matchDelimiter winningMatchStyle" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>';
177                                        htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>';
178                                        }
179                                        htmlConstructor += '</a>';
180                                        seeWhatTitle.push((keyForTitle) ? keyForTitle : 'Team');
181                                    }
182                                });
183                                htmlConstructor += '</div>';
184                            });
185                            htmlConstructor += '</div>';
186                            $('#resultsContentTable').append(htmlConstructor);
187
188                            $.each(seeWhatTitle, function( index, value ) {
189                                $('#resultsTabC .'+value).show();
190                            });
191                        } else {
192                            // If server dont send results we populate HTML with "Sorry, no data!"
193                            var htmlConstructor = '<div class="tablele-container">';
194                            htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>';
195                            htmlConstructor += '</div>';
196                            $('#resultsContentTable').append(htmlConstructor);
197                        }
198                    }).fail(function(error) {
199
200                    });
201                    clearInterval(getTimeForFixturesResults);
202                }
203            }, 10);
204            htmlConstructorResults += '</div>';
205            // Adding all above data to league location in HTML
206            $(leagueLocation).append(htmlConstructorResults);
207
208            // Add hook in HTML for Fixtures Tab content infos
209            var htmlConstructorFixtures = '<div id="fixturesTabC" class="fixtures-nav-tab-wrapper tab-content">';
210            var getTimeForFixtures = setInterval(function () {
211                if (timeForFixtures.length > 0) {
212                    // Set "from" date and "to" date for displaying the wanted interval - now it is set for tomorrow for up to a year
213                    var formattedDates = new Date(timeForFixtures + "T00:00");
214                    var dsAfter = formattedDates.setDate(formattedDates.getDate());
215                    var formattedDatesAfter = new Date(dsAfter);
216                    var ds = formattedDates.getDate();
217                    var ms = formattedDates.getMonth() + 1;
218                    var ys = formattedDates.getFullYear();
219                    var dateForFixtureFrom = ys + '-' + (ms < 10 ? '0' + ms : ms) + '-' + (ds < 10 ? '0' + ds 
219: ds);
220                    var dateForFixtureTo = (ys + 1) + '-' + (ms < 10 ? '0' + ms : ms) + '-' + (ds < 10 ? '0' + ds : ds)
221                    // Make call to server to get information about league Fixtures
222                    $.ajax({
223                        url: leagueDetailsAjaxURL,
224                        cache: false,
225                        data: {
226                            action: 'get_events',
227                            Widgetkey: Widgetkey,
228                            from: dateForFixtureFrom,
229                            to: dateForFixtureTo,
230                            league_id: league_id,
231                            timezone: timezone,
232                            withoutDetails: true
233                        },
234                        dataType: 'json'
235                    }).done(function(res) {
236
237                        // Add HTML hook for fixtures tab content
238                        $('#fixturesTabC').append('<section id="fixturesContentTable"></section>');
239
240                        // If server send results we populate HTML with sended information
241                        if (!res.error) {
242
243                            // Order information by Event Date and then group them by League Round
244                            var sorted = sortByKey(res, 'key');
245                            var sorted_array = sortByKeyAsc(sorted, "match_date");
246                            var groubedByTeam = groupBy(sorted_array, 'match_round');
247                            var htmlConstructor = '<div class="tablele-container">';
248                            var countryName = res[0].country_name;
249                            var seeWhatTitle = [];
250
251                            $.each(groubedByTeam, function(key, value) {
252
253                                var keyForTitle = key.replace(/\/| |-|  /g, '');
254                                htmlConstructor += '<div class="flex-table header '+((keyForTitle) ? keyForTitle : 'Team')+'" role="rowgroup" style="display: none;">';
255                                htmlConstructor += '<div title="' + ((key) ? key : 'Team') + '" class="flex-row" role="columnheader">' + ((key) ? key : 'Team') + '</div>';
256                                htmlConstructor += '</div>';
257                                htmlConstructor += '<div class="table__body_fixtures">';
258
259                                $.each(value, function(keys, values) {
260                                    // Now time in milliseconds
261                                    var dtNow = new Date();
262                                    var nowTimeMilliseconds = dtNow.getTime();
263                                    // Match time in milliseconds
264                                    var dtMatch = new Date((values.match_date + ' ' + values.match_time).replace(/-/g, "/"));
265                                    var matchTimeMilliseconds = dtMatch.getTime();
266                                    // Compare times for showing just matches before Now time
267                                    if (nowTimeMilliseconds < matchTimeMilliseconds) {
268                                    var formattedDate = new Date(values.match_date.replace(/-/g, "/"));
269                                        var d = formattedDate.getDate();
270                                        var m = formattedDate.getMonth() + 1;
271                                    var str = values.match_time;
272                                        if (str.search(/Postp/i) > 0) {
273                                        var match_time_simple = str.split("\n")[0];
274                                        var match_time_postp = str.split("\n").pop();
275                                        var match_time_exact = '<div class="match_time_text_align"><div class="fixtureslineThrough">' + d + '.' + m + ' ' + match_time_simple + '</div><div><div>' + match_time_postp + '</div></div></div>';
276                                        } else {
277                                        var match_time_exact = (d < 10 ? '0' + d : d) + '.' + (m < 10 ? '0' + m : m) + ' ' + values.match_time;
278                                        }
279                                    var generatedLink = countryName+'/'+league_name+'/'+values.match_hometeam_name+'-vs-'+values.match_awayteam_name+'/'+values.match_date+'/'+values.match_id;
280                                        var newGeneratedLink = generatedLink.replace(/\s/g,'-');
281                                    htmlConstructor += '<a href="widgetMatchResults.php?'+newGeneratedLink+'" class="flex-table row" role="rowgroup" onclick="event.preventDefault(); windowOpenMatch(' + values.match_id + ',\'' + leagueLogo + '\', \'' + values.match_date  + '\', \'' + countryName + '\', \'' + league_name + '\', \'' + values.match_hometeam_name + '\', \'' + values.match_awayteam_name + '\')" title="Click for match detail!">';
282                                    htmlConstructor += '<div class="flex-row matchDetails" role="cell">' + match_time_exact + '</div>';
283                                    htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>';
284                                        htmlConstructor += '<div class="flex-row matchDelimiter" role="cell">-</div>';
285                                    htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>';
286                                        htmlConstructor += '</a>';
287                                        seeWhatTitle.push((keyForTitle) ? keyForTitle : 'Team');
288                                    }
289                                });
290                                htmlConstructor += '</div>';
291                            });
292                            htmlConstructor += '</div>';
293                            $('#fixturesContentTable').append(htmlConstructor);
294                            $.each(seeWhatTitle, function( index, value ) {
295                                $('#fixturesTabC .'+value).show();
296                            });
297                        } else {
298                            // If server dont send results we populate HTML with "Sorry, no data!"
299                            var htmlConstructor = '<div class="tablele-container">';
300                            htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>';
301                            htmlConstructor += '</div>';
302                            $('#fixturesContentTable').append(htmlConstructor);
303                        }
304                    }).fail(function(error) {
305
306                    });
307                    clearInterval(getTimeForFixtures);
308                }
309            }, 10);
310            htmlConstructorFixtures += '</div>';
311            // Adding all above data to league location in HTML
312            $(leagueLocation).append(htmlConstructorFixtures);
313
314            // Add hook in HTML for Standings Tab content infos
315            var htmlConstructor = '<div id="standingsTabC" class="standing-nav-tab-wrapper tab-content">';
316            // Add HTML hook for standings tab content
317            htmlConstructor += '<div class="nav-tab-wrapper">';
318            var htmlTabsConstructor = '';
319            var htmlInsideTabsConstructor = '';
320            var firstElementInJson = 0;
321            // Make call to server to get information about league standings
322            $.ajax({
323                url: leagueDetailsAjaxURL,
324                cache: false,
325                data: {
326                    action: 'get_standings',
327                    Widgetkey: Widgetkey,
328                    league_id: league_id
329                },
330                dataType: 'json'
331            }).done(function(res) {
332                var newStand = {
333                    'total': [],
334                    'home': [],
335                    'away': []
336                };
337                var i = 0;
338
339                if (!res.error) {
340                    $.each(res, function(key, value) {
341                        var ii = i++;
342                        newStand['total'][ii] = {
343                            'country_name': value['country_name'],
344                            'league_id': value['league_id'],
345                            'league_name': value['league_name'],
346                            'team_id': value['team_id'],
347                            'team_name': value['team_name'],
348                            'league_round': value['league_round'],
349                            'league_position': value['overall_league_position'],
350                            'league_payed': value['overall_league_payed'],
351                            'league_W': value['overall_league_W'],
352                            'league_D': value['overall_league_D'],
353                            'league_L': value['overall_league_L'],
354                            'league_GF': value['overall_league_GF'],
355                            'league_GA': value['overall_league_GA'],
356                            'league_PTS': value['overall_league_PTS'],
357                            'promotion': value['overall_promotion']
358                        };
359                        newStand['home'][ii] = {
360                            'country_name': value['country_name'],
361                            'league_id': value['league_id'],
362                            'league_name': value['league_name'],
363                            'team_id': value['team_id'],
364                            'team_name': value['team_name'],
365                            'league_round': value['league_round'],
366                            'league_position': value['home_league_position'],
367                            'league_payed': value['home_league_payed'],
368                            'league_W': value['home_league_W'],
369                            'league_D': value['home_league_D'],
370                            'league_L': value['home_league_L'],
371                            'league_GF': value['home_league_GF'],
372                            'league_GA': value['home_league_GA'],
373                            'league_PTS': value['home_league_PTS']
374                        };
375                        newStand['away'][ii] = {
376                            'country_name': value['country_name'],
377                            'league_id': value['league_id'],
378                            'league_name': value['league_name'],
379                            'team_id': value['team_id'],
380                            'team_name': value['team_name'],
381                            'league_round': value['league_round'],
382                            'league_position': value['away_league_position'],
383                            'league_payed': value['away_league_payed'],
384                            'league_W': value['away_league_W'],
385                            'league_D': value['away_league_D'],
386                            'league_L': value['away_league_L'],
387                            'league_GF': value['away_league_GF'],
388                            'league_GA': value['away_league_GA'],
389                            'league_PTS': value['away_league_PTS']
390                        };
391                    });
392                }
393                // If server send results we populate HTML with sended information
394                $.each(newStand, function(key, value) {
395                    // Order information ascendent, then group them by League Round
396                    newStand[key].sort(groupSortingAsc);
397                    var groubedByTeam = groupBy(newStand[key], 'league_round');
398                    // Making first tab active
399                    if (firstElementInJson == 0) {
400                        htmlConstructor += '<a href="#' + key + '" class="standing-h2 nav-tab nav-tab-active">' + key + '</a>';
401                        htmlInsideTabsConstructor += '<section id="' + key + '" class="tab-content active">';
402                        htmlInsideTabsConstructor += '<div class="tablele-container">';
403                        if ($.isEmptyObject(groubedByTeam)) {
404                            htmlInsideTabsConstructor += '<div class="flex-table header" role="rowgroup">';
405                            htmlInsideTabsConstructor += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
406                            htmlInsideTabsConstructor += '<div title="Team" class="flex-row teams" role="columnheader">Team</div>';
407                            htmlInsideTabsConstructor += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
408                            htmlInsideTabsConstructor += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
409                            htmlInsideTabsConstructor += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
410                            htmlInsideTabsConstructor += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
411                            htmlInsideTabsConstructor += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
412                            htmlInsideTabsConstructor += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
413                            htmlInsideTabsConstructor += '</div>';
414                            htmlInsideTabsConstructor += '<div class="table__body">';
415                            htmlInsideTabsConstructor += '<div class="flex-table-error row" role="rowgroup">';
416                            htmlInsideTabsConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>';
417                            htmlInsideTabsConstructor += '</div>';
418                            htmlInsideTabsConstructor += '</div>';
419                        }
420                        $.each(groubedByTeam, function(keyss, valuess) {
421                            htmlInsideTabsConstructor += '<div class="flex-table header">';
422                            htmlInsideTabsConstructor += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
423                            htmlInsideTabsConstructor += '<div title="' + ((!keyss) ? "Team" : keyss) + '" class="flex-row teams" role="columnheader"><span class="standingsTeamsSpan">' + ((!keyss) ? "Team" : keyss) + '</span></div>';
424                            htmlInsideTabsConstructor += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
425                            htmlInsideTabsConstructor += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
426                            htmlInsideTabsConstructor += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
427                            htmlInsideTabsConstructor += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
428                            htmlInsideTabsConstructor += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
429                            htmlInsideTabsConstructor += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
430                            htmlInsideTabsConstructor += '</div>';
431                            htmlInsideTabsConstructor += '<div class="table__body">';
432                            var colorForStanding = ['colorOne', 'colorTwo', 'colorThree', 'colorFour', 'colorFive', 'colorSix', 'colorSeven', 'colorEight', 'colorNine', 'colorTen'];
433                            var colorStringValue = -1;
434                            var stringToCompareStandings = '';
435                            $.each(valuess, function(keys, values) {
436                                htmlInsideTabsConstructor += '<div class="flex-table row" role="rowgroup">';
437                                if (values.promotion) {
438                                    if (stringToCompareStandings != values.promotion) {
439                                        stringToCompareStandings = values.promotion;
440                                        colorStringValue++;
441                                        colorForStanding[colorStringValue];
442                                        htmlInsideTabsConstructor += '<div class="flex-row first-sticky fix-width ' + colorForStanding[colorStringValue] + '" title="' + values.promotion + '" role="cell">' + values.league_position + '.</div>';
443                                    } else if (stringToCompareStandings == values.promotion) {
444                                        colorForStanding[colorStringValue];
445                                        htmlInsideTabsConstructor += '<div class="flex-row first-sticky fix-width ' + colorForStanding[colorStringValue] + '" title="' + values.promotion + '" role="cell">' + values.league_position + '.</div>';
446                                    }
447                                } else if (!values.promotion) {
448                                    colorStringValue = $(colorForStanding).length / 2;
449                                    htmlInsideTabsConstructor += '<div class="flex-row first-sticky fix-width" role="cell">' + values.league_position + '.</div>';
450                                }
451                                htmlInsideTabsConstructor += '<div class="flex-row teams" role="cell"><a href="#" onclick="windowPreventOpening()">' + values.team_name + '</a></div>';
452                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_payed + '</div>';
453                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_W + '</div>';
454                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_D + '</div>';
455                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_L + '</div>';
456                                htmlInsideTabsConstructor += '<div class="flex-row goals" role="cell">' + values.league_GF + ':' + values.league_GA + '</div>';
457                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_PTS + '</div>';
458                                htmlInsideTabsConstructor += '</div>';
459                            });
460                            htmlInsideTabsConstructor += '</div>';
461                        });
462                        htmlInsideTabsConstructor += '</div>';
463                        htmlInsideTabsConstructor += '</section>';
464                        firstElementInJson++
465                    } else {
466                        htmlConstructor += '<a href="#' + key + '" class="standing-h2 nav-tab">' + key + '</a>';
467                        htmlInsideTabsConstructor += '<section id="' + key + '" class="tab-content">';
468                        htmlInsideTabsConstructor += '<div class="tablele-container">';
469                        if ($.isEmptyObject(groubedByTeam)) {
470                            htmlInsideTabsConstructor += '<div class="flex-table header" role="rowgroup">';
471                            htmlInsideTabsConstructor += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
472                            htmlInsideTabsConstructor += '<div title="Team" class="flex-row teams" role="columnheader">Team</div>';
473                            htmlInsideTabsConstructor += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
474                            htmlInsideTabsConstructor += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
475                            htmlInsideTabsConstructor += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
476                            htmlInsideTabsConstructor += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
477                            htmlInsideTabsConstructor += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
478                            htmlInsideTabsConstructor += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
479                            htmlInsideTabsConstructor += '</div>';
480                            htmlInsideTabsConstructor += '<div class="table__body">';
481                            htmlInsideTabsConstructor += '<div class="flex-table-error row" role="rowgroup">';
482                            htmlInsideTabsConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>';
483                            htmlInsideTabsConstructor += '</div>';
484                            htmlInsideTabsConstructor += '</div>';
485                        }
486                        $.each(groubedByTeam, function(keyss, valuess) {
487                            htmlInsideTabsConstructor += '<div class="flex-table header">';
488                            htmlInsideTabsConstructor += '<div title="Rank" class="flex-row first fix-width" role="columnheader">#</div>';
489                            htmlInsideTabsConstructor += '<div title="' + ((!keyss) ? "Team" : keyss) + '" class="flex-row teams" role="columnheader">' + ((!keyss) ? "Team" : keyss) + '</div>';
490                            htmlInsideTabsConstructor += '<div title="Matches Played" class="flex-row fix-width" role="columnheader">MP</div>';
491                            htmlInsideTabsConstructor += '<div title="Wins" class="flex-row fix-width" role="columnheader">W</div>';
492                            htmlInsideTabsConstructor += '<div title="Draws" class="flex-row fix-width" role="columnheader">D</div>';
493                            htmlInsideTabsConstructor += '<div title="Losses" class="flex-row fix-width" role="columnheader">L</div>';
494                            htmlInsideTabsConstructor += '<div title="Goals" class="flex-row goals" role="columnheader">G</div>';
495                            htmlInsideTabsConstructor += '<div title="Points" class="flex-row fix-width" role="columnheader">Pts</div>';
496                            htmlInsideTabsConstructor += '</div>';
497                            htmlInsideTabsConstructor += '<div class="table__body">';
498
499                            var sortStandingTabs = valuess;
500                            sortStandingTabs.sort(function(a, b){
501                                return b.league_PTS-a.league_PTS
502                            });
503
504                            var league_position_nb = 1;
505                            $.each(sortStandingTabs, function(keys, values) {
506                                htmlInsideTabsConstructor += '<div class="flex-table row" role="rowgroup">';
507                                htmlInsideTabsConstructor += '<div class="flex-row first fix-width" role="cell">' + league_position_nb + '.</div>';
508                                htmlInsideTabsConstructor += '<div class="flex-row teams" role="cell"><a href="#" onclick="windowPreventOpening()">' + values.team_name + '</a></div>';
509                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_payed + '</div>';
510                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_W + '</div>';
511                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_D + '</div>';
512                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_L + '</div>';
513                                htmlInsideTabsConstructor += '<div class="flex-row goals" role="cell">' + values.league_GF + ':' + values.league_GA + '</div>';
514                                htmlInsideTabsConstructor += '<div class="flex-row fix-width" role="cell">' + values.league_PTS + '</div>';
515                                htmlInsideTabsConstructor += '</div>';
516                                league_position_nb ++;
517                            });
518                            htmlInsideTabsConstructor += '</div>';
519                        });
520                        htmlInsideTabsConstructor += '</div>';
521                        htmlInsideTabsConstructor += '</section>';
522                    }
523                });
524                htmlConstructor += '</div>';
525                htmlConstructor += '</div>';
526                // Adding all above data to league location in HTML
527                $(leagueLocation).append(htmlConstructor);
528
529                // Switching tabs on click
530                $('.widgetLeague .nav-tab').unbind('click').on('click', function(e) {
531                    e.preventDefault();
532                    //Toggle tab link
533                    $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
534                    //Toggle target tab
535                    $($(this).attr('href')).addClass('active').siblings().removeClass('active');
536                });
537                $('.widgetLeague .standing-nav-tab-wrapper .nav-tab-wrapper').after(htmlInsideTabsConstructor);
538                $('.widgetLeague .standing-nav-tab-wrapper .nav-tab').unbind('click').on('click', function(e) {
539                    e.preventDefault();
540                    //Toggle tab link
541                    $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active');
542                    //Toggle target tab
543                    $($(this).attr('href')).addClass('active').siblings().removeClass('active');
544                });
545                    // });
546            }).fail(function(error) {
547
548            });
549        },
550
551        callback: function() {
552
553        }
554
555    });
556
557    $.fn.widgetLeague = function(options) {
558        this.each(function() {
559            if (!$.data(this, "plugin_" + widgetLeague)) {
560                $.data(this, "plugin_" + widgetLeague, new Plugin(this, options));
561            }
562        });
563        return this;
564    };
565
566    $.fn.widgetLeague.defaults = {
567        // Widgetkey will be set in jqueryGlobals.js and can be obtained from your account
568        Widgetkey: Widgetkey,
569        // Link to server data
570        leagueDetailsAjaxURL: 'https://apiv3.apifootball.com/?',
571        // Get Leagues information, name and image (reuqested automaticaly from server when you click on a league from country list)
572        league_id: null,
573        league_name: null,
574        leagueLogo: null,
575        // Background color for your Leagues Widget
576        backgroundColor: null,
577        // Width for your Countries Widget
578        widgetWidth: '81%',
579        // Get the time zone of your location
580        timezone: getTimeZone()
581    };
582
583})(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.