1// --------------------------------- 2// ---------- widgetLiveScore ---------- 3// --------------------------------- 4// Widget for LiveScore Display 5// ------------------------ 6; 7(function($, window, document, undefined) { 8 9 var widgetLiveScore = 'widgetLiveScore'; 10 11 function Plugin(element, options) { 12 this.element = element; 13 this._name = widgetLiveScore; 14 this._defaults = $.fn.widgetLiveScore.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.liveScoreDetailsAjaxURL, this.options.action, this.options.Widgetkey, 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(liveScoreDetailsAjaxURL, action, Widgetkey, timezone) { 51 52 // Get widget location 53 var liveScoreLocation = $(this.element); 54 55 // Construct the Live Games Tab click 56 $('<a href="#liveGame" class="titleWidget nav-tab">Live Games</a>').prependTo($(liveScoreLocation)); 57 // Construct the All Games Tab click 58 $('<a href="#allGame" class="titleWidget nav-tab nav-tab-active">All Games</a>').prependTo($(liveScoreLocation)); 59 // Construct the Calendar Tab click 60 $('<div id="liveScoreCalendarContainer"></div>').prependTo($(liveScoreLocation)); 61 62 // If window size is less then 769px we add loading screen 63 var windowWidthSize = $(window).width(); 64 if (windowWidthSize < 769) { 65 $('<div class="loading">Loading…</div>').prependTo($(liveScoreLocation)); 66 } 67 68 // Add hook in HTML for All Games Tab content infos and make it active 69 $(liveScoreLocation).append('<div id="allGame" class="allGame-nav-tab-wrapper tab-content active"></div>'); 70 71 // Adding the "widgetLiveScore" class for styling and easyer targeting 72 liveScoreLocation.addClass('widgetLiveScore'); 73 74 // If backgroundColor setting is set, here we activate the color 75 if (this.options.backgroundColor) { 76 liveScoreLocation.css('background-color', this.options.backgroundColor); 77 } 78 79 // If widgetWidth setting is set, here we set the width of the list 80 if (this.options.widgetWidth) { 81 liveScoreLocation.css('width', this.options.widgetWidth); 82 } 83 84 // Adding callendar with All Games for 3 days before and after current day 85 var getTimeZoneForSlowConn = setInterval(function () { 86 if (timeForFixtures.length > 0) { 87 getDateCalendar('liveScoreCalendarContainer', timeForFixtures, 'threeDayAfter', 3, 'addDateCalendar'); 88 getDateCalendar('liveScoreCalendarContainer', timeForFixtures, 'twoDayAfter', 2, 'addDateCalendar'); 89 getDateCalendar('liveScoreCalendarContainer', timeForFixtures, 'oneDayAfter', 1, 'addDateCalendar'); 90 $('<a href="#" onclick="windowPreventOpening()" id="currentDayCalendar" class="thisDateForSelect callendarDays callendarDaysActive" data-dateclicked="' + timeForFixtures + '">Current Day</a>').prependTo($('#liveScoreCalendarContainer')); 91 getDateCalendar('liveScoreCalendarContainer', timeForFixtures, 'oneDayBefore', 1, 'substractDateCalendar'); 92 getDateCalendar('liveScoreCalendarContainer', timeForFixtures, 'twoDayBefore', 2, 'substractDateCalendar'); 93 getDateCalendar('liveScoreCalendarContainer', timeForFixtures, 'threeDayBefore', 3, 'substractDateCalendar'); 94 95 // When a day is clicked we make it active and populate All Games tab 96 $('#liveScoreCalendarContainer').find('.thisDateForSelect').unbind('click').on('click', function() { 97 $(this).addClass('callendarDaysActive'); 98 $(this).siblings().removeClass('callendarDaysActive'); 99 $('#allGame').html('<div class="loading">Loading…</div>').addClass('active').siblings().removeClass('active'); 100 $('.widgetLiveScore .titleWidget').removeClass('nav-tab-active').first().addClass('nav-tab-active'); 101 // Aditionally we send a request to server for infos 102 $.ajax({
103 url: liveScoreDetailsAjaxURL, 104 cache: false, 105 data: { 106 action: 'get_events', 107 Widgetkey: Widgetkey, 108 from: $(this).attr("data-dateclicked"), 109 to: $(this).attr("data-dateclicked"), 110 timezone: getTimeZone(), 111 withOutDetails: true 112 }, 113 dataType: 'json' 114 }).done(function(res) { 115 // Hide loading screen 116 $('.loading').hide(); 117 // Construct the section for All Games in that specific day 118 $('#allGame').append('<section id="allGameContentTable"></section>'); 119 // If server send results we populate HTML with sended information 120 if (!res.error) { 121 // Order information by Event Time and then group them by Country Name 122 var windowWidthSize = $(window).width(); 123 var sorted = sortByKey(res, 'key'); 124 var sorted_array = sortByKeyAsc(sorted, "match_time"); 125 var groubedByTeam = groupBy(sorted_array, 'country_name'); 126 const orderedLeagues = {}; 127 Object.keys(groubedByTeam).sort().forEach(function(key) { 128 orderedLeagues[key] = groubedByTeam[key]; 129 }); 130 var htmlConstructor = '<div class="tablele-container">'; 131 $.each(orderedLeagues, function(keyes, valuees) { 132 var sortedValuess = groupBy(valuees, 'league_name'); 133 $.each(sortedValuess, function(key, value) { 134 htmlConstructor += '<div class="flex-table header" role="rowgroup">'; 135 htmlConstructor += '<div class="countryListDisplays"><div class="countryLogo" style="background-image: url(\'' + ((value[0].country_logo == '' || value[0].country_logo == null) ? noImgLocation.noImgUrl : value[0].country_logo) + '\');"></div>'; 136 htmlConstructor += '<div title="' + ((key) ? key : 'Team') + '" class="flex-row keyOfTeam" onclick="windowOpenLeagueInfo(\'' + value[0].league_id + '\',\'' + value[0].league_name +'\', \'' + value[0].league_logo + '\')" role="columnheader">' + ((value[0].country_name) ? '<span class="countryOfTeams">' + value[0].country_name + ':</span>' : '') + ' ' + ((key) ? key : 'Team') + '</div>'; 137 htmlConstructor += '</div>'; 138 htmlConstructor += '</div>'; 139 htmlConstructor += '<div class="table__body_fixtures">'; 140 $.each(value, function(keys, values) { 141 if (values.match_hometeam_score == null || values.match_awayteam_score == null) { 142 var event_final_result_class_away = ''; 143 var event_final_result_class_home = ''; 144 } else { 145 var event_final_result_class_away = values.match_awayteam_score; 146 var event_final_result_class_home = values.match_hometeam_score; 147 } 148 if (values.match_status) { 149 var removeNumericAdd = values.match_status.replace('+', ''); 150 } else { 151 var removeNumericAdd = values.match_status; 152 } 153 var generatedLink = values.country_name+'/'+values.league_name+'/'+values.match_hometeam_name+'-vs-'+values.match_awayteam_name+'/'+values.match_date+'/'+values.match_id; 154 var newGeneratedLink = generatedLink.replace(/\s/g,'-'); 155 htmlConstructor += '<a href="widgetMatchResults.html?'+newGeneratedLink+'" class="' + ((windowWidthSize < 769) ? 'container-mobile-grid' : '') + ' flex-table row ' + values.match_id + '" role="rowgroup" onclick="event.preventDefault(); windowOpenMatch(' + values.match_id + ', false, \'' + values.match_date + '\', \'' + values.country_name + '\', \'' + values.league_name + '\', \'' + values.match_hometeam_name + '\', \'' + values.match_awayteam_name + '\')" title="Click for match detail!" style="transition: none;">'; 156 htmlConstructor += '<div class="' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell"> ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? values.match_status + ((removeNumericAdd == 'Half Time') ? '' : '\'') : values.match_time) + '</div>'; 157 htmlConstructor += '<div class="' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? 'd-none-mobile-div' : (((values.match_status == null) || values.match_status == '') ? 'd-none-mobile-div' : '')) + ' ' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails secondMatchDetails" role="cell">' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? '' : ((values.match_status == null) ? '' : values.match_status)) + '</div>'; 158 htmlConstructor += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 159 if (event_final_result_class_home > event_final_result_class_away) { 160 htmlConstructor += '<div class="flex-row matchHomeTeam winningMatchStyle" role="cell">' + values.match_hometeam_name + '</div>'; 161 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 162 htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 163 } else if (event_final_result_class_home < event_final_result_class_away) { 164 htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 165 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 166 htmlConstructor += '<div class="flex-row matchAwayTeam winningMatchStyle" role="cell">' + values.match_awayteam_name + '</div>'; 167 } else if (event_final_result_class_home == event_final_result_class_away) { 168 htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 169 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 170 htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 171 } 172 htmlConstructor += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 173 htmlConstructor += '<div class="' + ((((windowWidthSize < 769) && (values.match_hometeam_score == '') && (values.match_awayteam_score == '')) || ((windowWidthSize < 769) && (values.match_hometeam_score == null) && (values.match_awayteam_score == null))) ? 'd-none-mobile-div' : '') + ' flex-row matchAwayTeam firstHalfStyle ' + ((windowWidthSize < 769) ? 'mobile-firstHalfStyle d-none-mobile-div' : '') + '" role="cell">' + (((values.match_hometeam_score) && (values.match_awayteam_score)) ? '(' + (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) + ')' : '') + '</div>'; 174 htmlConstructor += '</a>'; 175 }); 176 htmlConstructor += '</div>'; 177 }); 178 }); 179 htmlConstructor += '</div>'; 180 $('#allGameContentTable').append(htmlConstructor); 181 182 } else { 183 184 // If server dont send results we populate HTML with "Sorry, no data!" 185 var htmlConstructor = '<div class="tablele-container">'; 186 htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>'; 187 htmlConstructor += '</div>'; 188 $('#allGameContentTable').append(htmlConstructor); 189 } 190 191 }).fail(function(error) { 192 193 }); 194 195 }); 196 197 // We send a request to server for All Games infos 198 $.ajax({
199 url: liveScoreDetailsAjaxURL, 200 cache: false, 201 data: { 202 action: 'get_events', 203 Widgetkey: Widgetkey, 204 from: timeForFixtures, 205 to: timeForFixtures, 206 timezone: getTimeZone(), 207 withOutDetails: true 208 }, 209 dataType: 'json' 210 }).done(function(res) { 211 212 // Hide loading screen 213 $('.loading').hide(); 214 // Construct the section for today Games 215 $('#allGame').append('<section id="allGameContentTable"></section>'); 216 // If server send results we populate HTML with sended information 217 if (!res.error) { 218 // Order information by Event Time and then group them by Country Name 219 var windowWidthSize = $(window).width(); 220 var sorted = sortByKey(res, 'key'); 221 var sorted_array = sortByKeyAsc(sorted, "match_time"); 222 var groubedByTeam = groupBy(sorted_array, 'country_name'); 223 const orderedLeagues = {}; 224 Object.keys(groubedByTeam).sort().forEach(function(key) { 225 orderedLeagues[key] = groubedByTeam[key]; 226 }); 227 var htmlConstructor = '<div class="tablele-container">'; 228 $.each(orderedLeagues, function(keyes, valuees) { 229 var sortedValuess = groupBy(valuees, 'league_name'); 230 $.each(sortedValuess, function(key, value) { 231 htmlConstructor += '<div class="flex-table header" role="rowgroup">'; 232 htmlConstructor += '<div class="countryListDisplays"><div class="countryLogo" style="background-image: url(\'' + ((value[0].country_logo == '' || value[0].country_logo == null) ? noImgLocation.noImgUrl : value[0].country_logo) + '\');"></div>'; 233 htmlConstructor += '<div title="' + ((key) ? key : 'Team') + '" class="flex-row keyOfTeam" onclick="windowOpenLeagueInfo(\'' + value[0].league_id + '\',\'' + value[0].league_name +'\', \'' + value[0].league_logo + '\')" role="columnheader">' + ((value[0].country_name) ? '<span class="countryOfTeams">' + value[0].country_name + ':</span>' : '') + ' ' + ((key) ? key : 'Team') + '</div>'; 234 htmlConstructor += '</div>'; 235 htmlConstructor += '</div>'; 236 htmlConstructor += '<div class="table__body_fixtures">'; 237 $.each(value, function(keys, values) { 238 if (values.match_hometeam_score == null || values.match_awayteam_score == null) { 239 var event_final_result_class_away = ''; 240 var event_final_result_class_home = ''; 241 } else { 242 var event_final_result_class_away = values.match_awayteam_score; 243 var event_final_result_class_home = values.match_hometeam_score; 244 } 245 if (values.match_status) { 246 var removeNumericAdd = values.match_status.replace('+', ''); 247 } else { 248 var removeNumericAdd = values.match_status; 249 } 250 var generatedLink = values.country_name+'/'+values.league_name+'/'+values.match_hometeam_name+'-vs-'+values.match_awayteam_name+'/'+values.match_date+'/'+values.match_id; 251 var newGeneratedLink = generatedLink.replace(/\s/g,'-'); 252 htmlConstructor += '<a href="widgetMatchResults.php?'+newGeneratedLink+'" class="' + ((windowWidthSize < 769) ? 'container-mobile-grid' : '') + ' flex-table row ' + values.match_id + '" role="rowgroup" onclick="event.preventDefault(); windowOpenMatch(' + values.match_id + ', false, \'' + values.match_date + '\', \'' + values.country_name + '\', \'' + values.league_name + '\', \'' + values.match_hometeam_name + '\', \'' + values.match_awayteam_name + '\')" title="Click for match detail!" style="transition: none;">'; 253 htmlConstructor += '<div class="' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell"> ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? values.match_status + ((removeNumericAdd == 'Half Time') ? '' : '\'') : values.match_time) + '</div>'; 254 htmlConstructor += '<div class="' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? 'd-none-mobile-div' : (((values.match_status == null) || values.match_status == '') ? 'd-none-mobile-div' : '')) + ' ' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails secondMatchDetails" role="cell">' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? '' : ((values.match_status == null) ? '' : values.match_status)) + '</div>'; 255 htmlConstructor += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 256 if (event_final_result_class_home > event_final_result_class_away) { 257 htmlConstructor += '<div class="flex-row matchHomeTeam winningMatchStyle" role="cell">' + values.match_hometeam_name + '</div>'; 258 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 259 htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 260 } else if (event_final_result_class_home < event_final_result_class_away) { 261 htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 262 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 263 htmlConstructor += '<div class="flex-row matchAwayTeam winningMatchStyle" role="cell">' + values.match_awayteam_name + '</div>'; 264 } else if (event_final_result_class_home == event_final_result_class_away) { 265 htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 266 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 267 htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 268 } 269 htmlConstructor += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 270 htmlConstructor += '<div class="' + ((((windowWidthSize < 769) && (values.match_hometeam_score == '') && (values.match_awayteam_score == '')) || ((windowWidthSize < 769) && (values.match_hometeam_score == null) && (values.match_awayteam_score == null))) ? 'd-none-mobile-div' : '') + ' flex-row matchAwayTeam firstHalfStyle ' + ((windowWidthSize < 769) ? 'mobile-firstHalfStyle d-none-mobile-div' : '') + '" role="cell">' + (((values.match_hometeam_score) && (values.match_awayteam_score)) ? '(' + (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) + ')' : '') + '</div>'; 271 htmlConstructor += '</a>'; 272 }); 273 htmlConstructor += '</div>'; 274 }); 275 }); 276 htmlConstructor += '</div>'; 277 $('#allGameContentTable').append(htmlConstructor); 278 279 } else { 280 281 // If server dont send results we populate HTML with "Sorry, no data!" 282 var htmlConstructor = '<div class="tablele-container">'; 283 htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>'; 284 htmlConstructor += '</div>'; 285 $('#allGameContentTable').append(htmlConstructor); 286 } 287 }).fail(function(error) { 288 289 }); 290 291 292 // Add hook in HTML for Live Games Tab content infos 293 var htmlConstructorResults = '<div id="liveGame" class="liveGame-nav-tab-wrapper tab-content">'; 294 function loadLivescore(){ 295 // Get previous day for live score 296 var getPreviousDay = new Date(timeForFixtures + "T00:00"); 297 getPreviousDay.setDate(getPreviousDay.getDate() - 1); 298 var d = getPreviousDay.getDate(); 299 var m = getPreviousDay.getMonth() + 1; 300 var y = getPreviousDay.getFullYear(); 301 var previousDay = y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d); 302 303 // Call Livescore Data from server 304 $.ajax({
305 url: liveScoreDetailsAjaxURL, 306 cache: false, 307 data: { 308 action: 'get_events', 309 match_live : '1', 310 from: previousDay, 311 to: timeForFixtures, 312 Widgetkey: Widgetkey, 313 timezone: getTimeZone(), 314 withOutDetails: true 315 }, 316 dataType: 'json' 317 }).done(function(res) { 318 // Clear the Live Games HTML 319 $('#liveGame').html(''); 320 // Construct the section for Live Games 321 $('#liveGame').append('<section id="liveGameContentTable"></section>'); 322 // If server send results we populate HTML with sended information 323 if (!res.error) { 324 // Order information by Event Time and then group them by Country Name 325 var windowWidthSize = $(window).width(); 326 var sorted = sortByKey(res, 'key'); 327 var sorted_array = sortByKeyAsc(sorted, "match_time"); 328 var groubedByTeam = groupBy(sorted_array, 'country_name'); 329 const orderedLeagues = {}; 330 Object.keys(groubedByTeam).sort().forEach(function(key) { 331 orderedLeagues[key] = groubedByTeam[key]; 332 }); 333 var htmlConstructor = '<div class="tablele-container">'; 334 $.each(orderedLeagues, function(keyes, valuees) { 335 var sortedValuess = groupBy(valuees, 'league_name'); 336 $.each(sortedValuess, function(key, value) { 337 htmlConstructor += '<div class="flex-table header" role="rowgroup">'; 338 htmlConstructor += '<div class="countryListDisplays"><div class="countryLogo" style="background-image: url(\'' + ((value[0].country_logo == '' || value[0].country_logo == null) ? noImgLocation.noImgUrl : value[0].country_logo) + '\');"></div>'; 339 htmlConstructor += '<div title="' + ((key) ? key : 'Team') + '" class="flex-row keyOfTeam" onclick="windowOpenLeagueInfo(\'' + value[0].league_id + '\',\'' + value[0].league_name +'\', \'' + value[0].league_logo + '\')" role="columnheader">' + ((value[0].country_name) ? '<span class="countryOfTeams">' + value[0].country_name + ':</span>' : '') + ' ' + ((key) ? key : 'Team') + '</div>'; 340 htmlConstructor += '</div>'; 341 htmlConstructor += '</div>'; 342 htmlConstructor += '<div class="table__body_fixtures">'; 343 $.each(value, function(keys, values) { 344 if (values.match_hometeam_score == null || values.match_awayteam_score == null) { 345 var event_final_result_class_away = ''; 346 var event_final_result_class_home = ''; 347 } else { 348 var event_final_result_class_away = values.match_awayteam_score; 349 var event_final_result_class_home = values.match_hometeam_score; 350 } 351 if (values.match_status) { 352 var removeNumericAdd = values.match_status.replace('+', ''); 353 } else { 354 var removeNumericAdd = values.match_status; 355 } 356 var generatedLink = values.country_name+'/'+values.league_name+'/'+values.match_hometeam_name+'-vs-'+values.match_awayteam_name+'/'+values.match_date+'/'+values.match_id; 357 var newGeneratedLink = generatedLink.replace(/\s/g,'-'); 358 htmlConstructor += '<a href="widgetMatchResults.php?'+newGeneratedLink+'" class="' + ((windowWidthSize < 769) ? 'container-mobile-grid' : '') + ' flex-table row ' + values.match_id + '" role="rowgroup" onclick="event.preventDefault(); windowOpenMatch(' + values.match_id + ', false, \'' + values.match_date + '\', \'' + values.country_name + '\', \'' + values.league_name + '\', \'' + values.match_hometeam_name + '\', \'' + values.match_awayteam_name + '\')" title="Click for match detail!" style="transition: none;">'; 359 htmlConstructor += '<div class="' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell"> ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? values.match_status + ((removeNumericAdd == 'Half Time') ? '' : '\'') : values.match_time) + '</div>'; 360 htmlConstructor += '<div class="' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? 'd-none-mobile-div' : ((values.match_status == null) ? 'd-none-mobile-div' : '')) + ' ' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails secondMatchDetails" role="cell">' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? '' : ((values.match_status == null) ? '' : values.match_status)) + '</div>'; 361 htmlConstructor += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 362 if (event_final_result_class_home > event_final_result_class_away) { 363 htmlConstructor += '<div class="flex-row matchHomeTeam winningMatchStyle" role="cell">' + values.match_hometeam_name + '</div>'; 364 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 365 htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 366 } else if (event_final_result_class_home < event_final_result_class_away) { 367 htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 368 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 369 htmlConstructor += '<div class="flex-row matchAwayTeam winningMatchStyle" role="cell">' + values.match_awayteam_name + '</div>'; 370 } else if (event_final_result_class_home == event_final_result_class_away) { 371 htmlConstructor += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 372 htmlConstructor += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 373 htmlConstructor += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 374 } 375 htmlConstructor += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 376 htmlConstructor += '<div class="' + ((((windowWidthSize < 769) && (values.match_hometeam_score == '') && (values.match_awayteam_score == '')) || ((windowWidthSize < 769) && (values.match_hometeam_score == null) && (values.match_awayteam_score == null))) ? 'd-none-mobile-div' : '') + ' flex-row matchAwayTeam firstHalfStyle ' + ((windowWidthSize < 769) ? 'mobile-firstHalfStyle d-none-mobile-div' : '') + '" role="cell">' + (((values.match_hometeam_score) && (values.match_awayteam_score)) ? '(' + (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) + ')' : '') + '</div>'; 377 htmlConstructor += '</a>'; 378 }); 379 htmlConstructor += '</div>'; 380 }); 381 }); 382 htmlConstructor += '</div>'; 383 $('#liveGameContentTable').append(htmlConstructor); 384 385 } else { 386 387 // If server dont send results we populate HTML with "Sorry, no data!" 388 var htmlConstructor = '<div class="tablele-container">'; 389 htmlConstructor += '<p class="" style="border-left: solid 0px transparent; margin-left:auto; margin-right:auto; margin-top: 5px;">Sorry, no data!</p>'; 390 htmlConstructor += '</div>'; 391 $('#liveGameContentTable').append(htmlConstructor); 392 } 393 }).fail(function(error) { 394 395 }); 396 setTimeout(function(){ 397 loadLivescore(); 398 }, 300000); 399 } 400 401 loadLivescore(); 402 403 htmlConstructorResults += '</div>'; 404 $(liveScoreLocation).append(htmlConstructorResults); 405 // Switching tabs on click 406 $('.widgetLiveScore .nav-tab').unbind('click').on('click', function(e) { 407 e.preventDefault(); 408 //Toggle tab link 409 $(this).addClass('nav-tab-active').siblings().removeClass('nav-tab-active'); 410 //Toggle target tab 411 $($(this).attr('href')).addClass('active').siblings().removeClass('active'); 412 }); 413 414 clearInterval(getTimeZoneForSlowConn);
415 } 416 }, 10); 417 }, 418 419 callback: function() { 420 421 } 422 423 }); 424 425 $.fn.widgetLiveScore = function(options) { 426 this.each(function() { 427 if (!$.data(this, "plugin_" + widgetLiveScore)) { 428 $.data(this, "plugin_" + widgetLiveScore, new Plugin(this, options)); 429 } 430 }); 431 return this; 432 }; 433 434 $.fn.widgetLiveScore.defaults = { 435 // Widgetkey will be set in jqueryGlobals.js and can be obtained from your account 436 Widgetkey: Widgetkey, 437 // Action for this widget 438 action: 'get_events', 439 // Link to server data 440 liveScoreDetailsAjaxURL: 'https://apiv3.apifootball.com/?', 441 // Background color for your Leagues Widget 442 backgroundColor: null, 443 // Width for your widget 444 widgetWidth: '81%', 445 // Get the time zone of your location 446 timezone: getTimeZone() 447 }; 448 449 socketsLive(); 450 451 function socketsLive(){ 452 var socket = new WebSocket('wss://wss.apifootball.com/livescore?Widgetkey='+Widgetkey+'&timezone='+getTimeZone()); 453 // Define the 454 socket.onmessage = function(e) { 455// alert( e.data ); 456 457 if (e.data) { 458 var data = JSON.parse(e.data); 459 460 var windowWidthSize = $(window).width(); 461 $.each(data, function(keys, values) { 462 if (values.match_hometeam_score == null || values.match_awayteam_score == null) { 463 var event_final_result_class_away = ''; 464 var event_final_result_class_home = ''; 465 } else { 466 var event_final_result_class_away = values.match_awayteam_score; 467 var event_final_result_class_home = values.match_hometeam_score; 468 } 469 if (values.match_status) { 470 var removeNumericAdd = values.match_status.replace('+', ''); 471 } else { 472 var removeNumericAdd = values.match_status; 473 } 474 var newDataForMatch = '<div class="' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell"> ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? values.match_status + ((removeNumericAdd == 'Half Time') ? '' : '\'') : values.match_time) + '</div>'; 475 newDataForMatch += '<div class="' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? 'd-none-mobile-div' : ((values.match_status == null) ? 'd-none-mobile-div' : '')) + ' ' + ((windowWidthSize < 769) ? 'item-mobile-grid' : '') + ' flex-row matchDetails secondMatchDetails" role="cell">' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? '' : ((values.match_status == null) ? '' : values.match_status)) + '</div>'; 476 newDataForMatch += ((windowWidthSize < 769) ? '<div class="break-mobile-grid"></div>' : ''); 477 if (event_final_result_class_home > event_final_result_class_away) { 478 newDataForMatch += '<div class="flex-row matchHomeTeam winningMatchStyle" role="cell">' + values.match_hometeam_name + '</div>'; 479 newDataForMatch += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 480 newDataForMatch += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 481 } else if (event_final_result_class_home < event_final_result_class_away) { 482 newDataForMatch += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 483 newDataForMatch += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 484 newDataForMatch += '<div class="flex-row matchAwayTeam winningMatchStyle" role="cell">' + values.match_awayteam_name + '</div>'; 485 } else if (event_final_result_class_home == event_final_result_class_away) { 486 newDataForMatch += '<div class="flex-row matchHomeTeam" role="cell">' + values.match_hometeam_name + '</div>'; 487 newDataForMatch += '<div class="flex-row matchDelimiter ' + (($.isNumeric(removeNumericAdd) || (removeNumericAdd == 'Half Time')) ? ' matchIsLive' : '') + '" role="cell">' + ((values.match_hometeam_score && values.match_awayteam_score ) ? (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) : '-') + '</div>'; 488 newDataForMatch += '<div class="flex-row matchAwayTeam" role="cell">' + values.match_awayteam_name + '</div>'; 489 } 490 newDataForMatch += '<div class="' + ((((windowWidthSize < 769) && (values.match_hometeam_score == '') && (values.match_awayteam_score == '')) || ((windowWidthSize < 769) && (values.match_hometeam_score == null) && (values.match_awayteam_score == null))) ? 'd-none-mobile-div' : '') + ' flex-row matchAwayTeam firstHalfStyle ' + ((windowWidthSize < 769) ? 'mobile-firstHalfStyle d-none-mobile-div' : '') + '" role="cell">' + (((values.match_hometeam_score) && (values.match_awayteam_score)) ? '(' + (values.match_hometeam_score + ' - ' + values.match_awayteam_score ) + ')' : '') + '</div>'; 491 $('.' + values.match_id).html('').html(newDataForMatch); 492 }); 493 } else { 494 // If server dont send new data we populate console.log with "No new data!" 495 console.log('No new data!'); 496 } 497 } 498 socket.onclose = function(){ 499 // connection closed, discard old websocket and create a new one in 5s 500 socket = null; 501 setTimeout(socketsLive, 5000); 502 } 503 504 } 505 506})(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.