1/*! Copyright (c) 2015 Art-Up LTD (https://art-up.co.il) 2 * Licensed under the MIT License (LICENSE.txt). 3 * Requires: 1.4.2+ 4 */ 5 6/*Global VARS*/ 7//var PATH_TO_STATS = "https://3.132.82.4:10282/api/SegevStats"; 8//var PATH_TO_STATS = "https://18.223.24.119:10282/api/SegevStats"; 9//var PATH_TO_STATS = "https://basket.co.il/pbp/json_live/"; 10//var PATH_TO_STATS = "https://stats.segevstats.com/api/"; 11 12 13var PATH_TO_STATS = "https://stats.segevstats.com/realtimestat_heb/api/"; 14var PBP_URL = "https://stats.segevstats.com/realtimestat_heb/"; 15var SITE_URL = "https://basket.co.il/"; 16var LIVESTATS_URL = SITE_URL + "livestats/"; // new live-stats system 17 18var path_to_json = "/"; 19var PATH_TO_LOCAL_DATA = ""; 20 21var timer = 10000; 22var jj = 0; 23var kk = 0; 24var ActiveGame = 0; 25var ActiveGameEx = 0; 26var Team1Id = 0; 27var Team2Id = 0; 28 29var TEAM_1_ID = 0; 30var TEAM_2_ID = 0; 31 32var arrGames = []; 33var arrViewGames = []; 34var arrTeams = []; 35var arrPlayers = []; 36var arrActivePlayers = []; 37 38var arrCurrentGames = []; 39var arrViewCurrentGames = []; 40var active_comp = 0; 41var next_round = 0; 42var comp_cat = 1; 43var token = ""; 44var isOK = false; 45var bPlayers = false; 46var min_p_id = 1000000; 47var max_p_id = 0; 48var score_1 = 0; 49var score_2 = 0; 50var CURRENT_QUARTER = 0; 51var events_num = 0; 52var events_id = 0; 53var last_event_id = 0; 54var bGames = false; 55var bTeams = false; 56var bPbp = false; 57var interval1 = null; 58var interval2 = null; 59var interval3 = null; 60var interval4 = null; 61var interval5 = null; 62var interval6 = null; 63var interval7 = null; 64var interval8 = null; 65 66var TeamId1 = 0; 67var TeamId2 = 0; 68 69function ShowResult(arr, ex_game_id, my_game_id) { 70 var q = 0; 71 var ot = 0; 72 var str_time = ""; 73 var game_link = ""; 74 75 if (arr.result.success == true) { 76 77 // Games bar, live game â LIVESTATS (new system); ex_game_id is Segev's id 78 game_link = LIVESTATS_URL + "game.html?game_id=" + ex_game_id; 79 //game_link = PBP_URL + "gameStats.php?game_id=" + ex_game_id + "&lang=he"; 80 81 if (!$("#game_" + my_game_id).hasClass("live")) { 82 $("#game_" + my_game_id).addClass("live"); 83 } 84 if (!$("#game_live_" + my_game_id).hasClass("live")) { 85 $("#game_live_" + my_game_id).addClass("live"); 86 } 87 88 clock_m = arr.result.boxscore.gameInfo.currentQuarterTime.m; 89 clock_s = arr.result.boxscore.gameInfo.currentQuarterTime.s; 90 if (clock_s < 10) { 91 clock_s = "0" + clock_s; 92 } 93 clock = clock_m + ":" + clock_s; 94 q = arr.result.boxscore.gameInfo.currentQuarter; 95 q = q * 1; 96 if (q > 4) { 97 ot = q - 4; 98 str_time = "××ר×× " + ot + " - " + clock; 99 } 100 else { 101 str_time = "ר××¢ " + q + " - " + clock; 102 } 103 104 home_pts = arr.result.boxscore.gameInfo.homeScore; 105 away_pts = arr.result.boxscore.gameInfo.awayScore; 106 107 if (q == 1 && clock == "0:00") { str_time = "×סת××× ×¨××¢ 1"; } 108 if (q == 2 && clock == "0:00") { str_time = "××צ×ת"; } 109 if (q == 3 && clock == "0:00") { str_time = "×סת××× ×¨××¢ 3"; } 110 if (q == 4 && clock == "0:00" && home_pts != away_pts) { str_time = "×סת×××"; } 111 if (q == 4 && clock == "0:00" && home_pts == away_pts) { str_time = "×סת××× ×¨××¢ 4"; } 112 if (q > 4 && clock == "0:00" && home_pts == away_pts) { str_time = "×סת×××× ××ר××"; } 113 if (q > 4 && clock == "0:00" && home_pts != away_pts) { str_time = "×סת×××"; } 114 115 if ((document.getElementById("online_q_desc_" + my_game_id) != null) && (document.getElementById("online_q_desc_" + my_game_id) != undefined)) { 116 document.getElementById("online_q_desc_" + my_game_id).innerHTML = "<a href='" + game_link + "' target='_blank'>" + str_time + "</a>"; 117 document.getElementById("online_result_h_" + my_game_id).innerHTML = "<a href='" + game_link + "' target='_blank'>" + home_pts + "</a>"; 118 document.getElementById("online_result_a_" + my_game_id).innerHTML = "<a href='" + game_link + "' target='_blank'>" + away_pts + "</a>"; 119 } 120 121 if ((my_game_id == ActiveGame) && (bPbp==false)) { 122 if ((document.getElementById("online_result") != null) && (document.getElementById("online_result") != undefined)) { 123 document.getElementById("online_result").innerHTML = home_pts + ":" + away_pts;
124 } 125 if ((document.getElementById("game_clock") != null) && (document.getElementById("game_clock") != undefined)) { 126 document.getElementById("game_clock").innerHTML = home_pts + ":" + away_pts; 127 } 128 129 } 130 131 } 132} 133 134 135 136function ShowResultPbp(arr, ex_game_id, my_game_id) { 137 var q = 0; 138 var ot = 0; 139 var str_time = ""; 140 var game_link = ""; 141 142 if (arr.result.success == true) { 143 144 game_link = "index.html?id=" + my_game_id + "&lang=he"; 145 146 /* 147 if (!$("#game_" + my_game_id).hasClass("live")) { 148 $("#game_" + my_game_id).addClass("live"); 149 } 150 if (!$("#game_live_" + my_game_id).hasClass("live")) { 151 $("#game_live_" + my_game_id).addClass("live"); 152 } 153 */ 154 155 clock_m = arr.result.boxscore.gameInfo.currentQuarterTime.m; 156 clock_s = arr.result.boxscore.gameInfo.currentQuarterTime.s; 157 if (clock_s < 10) { 158 clock_s = "0" + clock_s; 159 } 160 clock = clock_m + ":" + clock_s; 161 q = arr.result.boxscore.gameInfo.currentQuarter; 162 q = q * 1; 163 if (q > 4) { 164 ot = q - 4; 165 str_time = "××ר×× " + ot + " - " + clock; 166 } 167 else { 168 str_time = "ר××¢ " + q + " - " + clock; 169 } 170 171 home_pts = arr.result.boxscore.gameInfo.homeScore; 172 //home_pts = Math.round((Math.random() * 100) * 100/100); 173 away_pts = arr.result.boxscore.gameInfo.awayScore; 174 175 if (q == 1 && clock == "0:00") { str_time = "×סת××× ×¨××¢ 1"; } 176 if (q == 2 && clock == "0:00") { str_time = "××צ×ת"; } 177 if (q == 3 && clock == "0:00") { str_time = "×סת××× ×¨××¢ 3"; } 178 if (q == 4 && clock == "0:00" && home_pts != away_pts) { str_time = "×סת×××"; } 179 if (q == 4 && clock == "0:00" && home_pts == away_pts) { str_time = "×סת××× ×¨××¢ 4"; } 180 if (q > 4 && clock == "0:00" && home_pts == away_pts) { str_time = "×סת×××× ××ר××"; } 181 if (q > 4 && clock == "0:00" && home_pts != away_pts) { str_time = "×סת×××"; } 182 183 if ((document.getElementById("online_q_desc_" + my_game_id) != null) && (document.getElementById("online_q_desc_" + my_game_id) != undefined)) { 184 document.getElementById("online_q_desc_" + my_game_id).innerHTML = "<a href='" + game_link + "'>" + str_time + "</a>"; 185 } 186 if ((document.getElementById("online_result_h_" + my_game_id) != null) && (document.getElementById("online_result_h_" + my_game_id) != undefined)) { 187 document.getElementById("online_result_h_" + my_game_id).innerHTML = "<a href='" + game_link + "'>" + home_pts + "</a>"; 188 } 189 if ((document.getElementById("online_result_a_" + my_game_id) != null) && (document.getElementById("online_result_a_" + my_game_id) != undefined)) { 190 document.getElementById("online_result_a_" + my_game_id).innerHTML = "<a href='" + game_link + "'>" + away_pts + "</a>"; 191 } 192 193 if (my_game_id == ActiveGame) { 194 if ((document.getElementById("online_result") != null) && (document.getElementById("online_result") != undefined)) { 195 document.getElementById("online_result").innerHTML = away_pts + ":" + home_pts; 196 } 197 if ((document.getElementById("game_clock") != null) && (document.getElementById("game_clock") != undefined)) { 198 document.getElementById("game_clock").innerHTML = str_time; 199 } 200 201 } 202 203 } 204} 205 206 207/*Get basket.co.il Settings*/ 208function getDetails() { 209 210 var g_data = path_to_json + "json/config.json?" + new Date().getTime(); 211 var xmlhttp = new XMLHttpRequest(); 212 var url = g_data; 213 214 xmlhttp.onreadystatechange = function () { 215 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 216 var myArr = JSON.parse(xmlhttp.responseText); 217 getDetailsData(myArr); 218 } 219 } 220 xmlhttp.open("GET", url, true); 221 xmlhttp.send(); 222} 223 224/*Get basket.co.il Settings*/ 225function settings() { 226
227 var g_data = PATH_TO_LOCAL_DATA + "json/config.json?" + new Date().getTime(); 228 var xmlhttp = new XMLHttpRequest(); 229 var url = g_data; 230 231 xmlhttp.onreadystatechange = function () { 232 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 233 var myArr = JSON.parse(xmlhttp.responseText); 234 getDetailsData(myArr); 235 } 236 } 237 xmlhttp.open("GET", url, true); 238 xmlhttp.send(); 239} 240 241function getDetailsData(arr) { 242 active_comp = arr[0].ActiveComp; 243 next_round = arr[0].nextRound; 244 display_mode = arr[0].display; 245 comp_cat = arr[0].comp_cat; 246 round_desc = arr[0].round_desc; 247} 248 249/*Get basket.co.il GAMES*/ 250function getGames() { 251 252 var g_data = path_to_json + "json/games.json?" + new Date().getTime(); 253 var xmlhttp_games = new XMLHttpRequest(); 254 var url = g_data; 255 256 xmlhttp_games.onreadystatechange = function () { 257 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 258 var myArr = JSON.parse(xmlhttp_games.responseText); 259 getGamesData(myArr); 260 bGames = true; 261 } 262 } 263 xmlhttp_games.open("GET", url, true); 264 xmlhttp_games.send(); 265} 266 267var lastGamesAllPayload = null; 268 269function getAllGames() { 270 271 var g_data = path_to_json + "json/games_all.json?" + new Date().getTime(); 272 var xmlhttp_games = new XMLHttpRequest(); 273 var url = g_data; 274 275 xmlhttp_games.onreadystatechange = function () { 276 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 277 // Rebuilding the games bar costs ~700ms of blocked main thread and throws 278 // away wherever the visitor had scrolled to. When the poll brings back a 279 // byte-identical payload there is by definition nothing to redraw, so skip it. 280 if (xmlhttp_games.responseText === lastGamesAllPayload) { 281 return; 282 } 283 lastGamesAllPayload = xmlhttp_games.responseText; 284 var myArr = JSON.parse(xmlhttp_games.responseText); 285 getGamesData(myArr); 286 } 287 } 288 xmlhttp_games.open("GET", url, true); 289 xmlhttp_games.send(); 290} 291 292function games() { 293 294 var g_data = PATH_TO_LOCAL_DATA + "json/games_all.json?" + new Date().getTime(); 295 var xmlhttp_games = new XMLHttpRequest(); 296 var url = g_data; 297 298 xmlhttp_games.onreadystatechange = function () { 299 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 300 var myArr = JSON.parse(xmlhttp_games.responseText); 301 getGamesData(myArr); 302 } 303 } 304 xmlhttp_games.open("GET", url, true); 305 xmlhttp_games.send(); 306} 307 308function get_current_game() { 309 310 var g_data = PATH_TO_LOCAL_DATA + "json/games_all.json?" + new Date().getTime(); 311 var xmlhttp_games = new XMLHttpRequest(); 312 var url = g_data; 313 314 xmlhttp_games.onreadystatechange = function () { 315 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 316 var myArr = JSON.parse(xmlhttp_games.responseText); 317 getThisGameData(myArr); 318 } 319 } 320 xmlhttp_games.open("GET", url, true); 321 xmlhttp_games.send(); 322} 323 324function getPbpGameResults() { 325 var clock_m = 0; 326 var clock_s = 0; 327 var clock = ""; 328 var home_pts = 0; 329 var away_pts = 0; 330 var iLive = 0; 331 332 for (var gg = 0; gg < arrViewGames.length; gg++) { 333 ex = arrViewGames[gg].ExternalID; 334 gid = arrViewGames[gg].id; 335 336 iLive = arrViewGames[gg].isLive; 337 iLive = iLive * 1; 338 if (iLive == 0) { 339 //getPbpGameResultData(ex, gid); 340 getResultByGame(ex, gid); 341 } 342 343 } 344} 345 346 347function getResultByGame(ex_game_id, my_game_id) { 348 349 if (!isPbpNull(ex_game_id)) { 350 var g_data = PATH_TO_STATS + "?method=getBoxScore&game_id=" + ex_game_id + "&" + new Date().getTime(); 351 var xmlhttp_games = new XMLHttpRequest(); 352 var url = g_data; 353 354 xmlhttp_games.onreadystatechange = function () { 355 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 356 var myArr = JSON.parse(xmlhttp_games.responseText); 357 ShowResult(myArr, ex_game_id, my_game_id); 358 } 359 } 360 xmlhttp_games.open("GET", url, true); 361 //xmlhttp.setRequestHeader("content-type", "application/json"); 362 //xmlhttp.setRequestHeader("cache-control", "no-cache"); 363 xmlhttp_games.send(); 364 } 365} 366 367function results(ex_game_id, my_game_id) { 368 369 if (!isPbpNull(ex_game_id)) { 370 var g_data = PATH_TO_STATS + "?method=getBoxScore&game_id=" + ex_game_id + "&" + new Date().getTime(); 371 var xmlhttp_games = new XMLHttpRequest(); 372 var url = g_data; 373 374 xmlhttp_games.onreadystatechange = function () { 375 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 376 var myArr = JSON.parse(xmlhttp_games.responseText); 377 ShowResultPbp(myArr, ex_game_id, my_game_id); 378 } 379 } 380 xmlhttp_games.open("GET", url, true); 381 //xmlhttp.setRequestHeader("content-type", "application/json"); 382 //xmlhttp.setRequestHeader("cache-control", "no-cache"); 383 xmlhttp_games.send(); 384 } 385} 386 387function getStatsByGame(ex_game_id, my_game_id) { 388 389 if (!isPbpNull(ex_game_id)) { 390 var g_data = PATH_TO_STATS + "?method=getBoxScore&game_id=" + ex_game_id + "&" + new Date().getTime(); 391 var xmlhttp_games = new XMLHttpRequest(); 392 var url = g_data; 393 394 xmlhttp_games.onreadystatechange = function () { 395 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 396 var myArr = JSON.parse(xmlhttp_games.responseText); 397 FillStats(myArr, ex_game_id, my_game_id); 398 } 399 } 400 xmlhttp_games.open("GET", url, true); 401 //xmlhttp.setRequestHeader("content-type", "application/json"); 402 //xmlhttp.setRequestHeader("cache-control", "no-cache"); 403 xmlhttp_games.send(); 404 } 405} 406 407 408/*Get basket.co.il GAMES*/ 409function getCurrentGame(g_id) { 410 411 var g_data = "pbp/json/games_all.json?" + new Date().getTime(); 412 var xmlhttp_games = new XMLHttpRequest(); 413 var url = g_data; 414 415 xmlhttp_games.onreadystatechange = function () { 416 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 417 var myArr = JSON.parse(xmlhttp_games.responseText); 418 getCurentGameData(myArr, g_id); 419 } 420 } 421 xmlhttp_games.open("GET", url, true); 422 xmlhttp_games.send(); 423} 424 425 426function getCurentGameData(arrGamesTmp, g_id) { 427 arrCurrentGames = arrGamesTmp; 428 429 var g_counter = 0; 430 var found = false; 431 432 for (var gg = 0; gg < arrCurrentGames[0].games.length; gg++) { 433 434 if (arrCurrentGames[0].games[gg].id == g_id) { 435 arrViewCurrentGames[g_counter] = arrCurrentGames[0].games[gg]; 436 g_counter++; 437 } 438 439 } 440 441 var iLive = 0; 442 443 for (var gg = 0; gg < arrViewCurrentGames.length; gg++) { 444 445 iLive = arrViewCurrentGames[gg].isLive; 446 iLive = iLive * 1; 447 448 if (iLive == 0) { 449 getResultCurrentGame(arrViewCurrentGames[gg].ExternalID,g_id); 450 } 451 452 } 453 454} 455 456 457/*GAME ZONE!!!!*/ 458 459function getResultCurrentGame(ex_game_id, my_game_id) { 460 461 if (!isPbpNull(ex_game_id)) { 462 //var g_data = PATH_TO_STATS + ex_game_id + "_boxscore.json?" + new Date().getTime(); 463 //var g_data = PATH_TO_STATS + ex_game_id + "_boxscore.json?" + new Date().getTime(); 464 var g_data = PATH_TO_STATS + "?method=getBoxScore&game_id=" + ex_game_id + "&" + new Date().getTime(); 465 466 var xmlhttp = new XMLHttpRequest(); 467 var url = g_data; 468 469 xmlhttp.onreadystatechange = function () { 470 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 471 if (xmlhttp.responseText.lastIndexOf("<!DOCTYPE html>", 0) < 0) { 472 var myGames = JSON.parse(xmlhttp.responseText); 473 ShowCurrentResult(myGames, ex_game_id, my_game_id); 474 } 475 else { 476 xmlhttp.abort(); 477 } 478 } 479 480 } 481 xmlhttp.open("GET", url, true); 482 xmlhttp.send(); 483 484 } 485} 486 487function ShowCurrentResult(arr, ex_game_id, my_game_id) { 488 489 var str_result = ""; 490 var game_link = ""; 491 492 if (arr.result.success == true) { 493 //console.log(arr.result.boxscore.gameInfo.homeScore); 494 //console.log(arr.result.boxscore.gameInfo.awayScore); 495 // Game-zone live result â LIVESTATS (new system); ex_game_id is Segev's id 496 game_link = LIVESTATS_URL + "game.html?game_id=" + ex_game_id; 497 //game_link = PBP_URL + "gameStats.php?game_id=" + ex_game_id + "&lang=he"; 498 499 //NEW: 500 501 str_result = arr.result.boxscore.gameInfo.awayScore + ":" + arr.result.boxscore.gameInfo.homeScore; 502 //game_link = SITE_URL + "pbp/index.html?id=" + ex_game_id; 503 str_result = "<a href='" + game_link + "' target='_blank'>" + str_result + "</a>"; 504 document.getElementById("gz_result").innerHTML = str_result; 505 } 506} 507 508 509function getActionsByGame(ex_game_id, my_game_id) { 510 511 if (!isPbpNull(ex_game_id)) { 512 var g_data = PATH_TO_STATS + "?method=getActions&game_id=" + ex_game_id + "&" + new Date().getTime(); 513 var xmlhttp_games = new XMLHttpRequest(); 514 var url = g_data; 515 516 xmlhttp_games.onreadystatechange = function () { 517 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 518 var myArr = JSON.parse(xmlhttp_games.responseText); 519 FillActions(myArr, ex_game_id, my_game_id); 520 } 521 } 522 xmlhttp_games.open("GET", url, true); 523 xmlhttp_games.send(); 524 } 525} 526 527 528function getPlayers() { 529
530 var p_data = PATH_TO_LOCAL_DATA + "json/players.json?" + new Date().getTime(); 531 var xmlhttp_players = new XMLHttpRequest(); 532 var url = p_data; 533 534 xmlhttp_players.onreadystatechange = function () { 535 if (xmlhttp_players.readyState == 4 && xmlhttp_players.status == 200) { 536 var myArr = JSON.parse(xmlhttp_players.responseText); 537 getPlayersData(myArr); 538 bPlayers = true; 539 } 540 } 541 xmlhttp_players.open("GET", url, true); 542 xmlhttp_players.send(); 543} 544 545function getQoutes(my_game_id) { 546 547 if (!isPbpNull(my_game_id)) { 548 var p_data = PATH_TO_LOCAL_DATA + "json/quotes.json?" + new Date().getTime(); 549 var xmlhttp_games = new XMLHttpRequest(); 550 var url = p_data; 551 552 xmlhttp_games.onreadystatechange = function () { 553 if (xmlhttp_games.readyState == 4 && xmlhttp_games.status == 200) { 554 var myArr = JSON.parse(xmlhttp_games.responseText); 555 FillQuotes(myArr); 556 } 557 } 558 xmlhttp_games.open("GET", url, true); 559 xmlhttp_games.send(); 560 } 561} 562 563function setData(div_id,data) { 564 if ((document.getElementById(div_id) != null) && (document.getElementById(div_id) != undefined)) { 565 document.getElementById(div_id).innerHTML = data; 566 } 567} 568 569 570function getParameterByName(name) { 571 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 572 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 573 results = regex.exec(location.search); 574 return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 575} 576 577function isPbpNull(str_input) { 578 var bNull = true; 579 if (str_input != "" && str_input != null && str_input != undefined) { 580 bNull = false; 581 } 582 return bNull; 583} 584 585function clearjQueryCache() { 586 for (var x in jQuery.cache) { 587 delete jQuery.cache[x]; 588 } 589}
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.