PageSourceSearch

https://socolivess.co/wp-content/plugins/soco-engine/assets/js/customize.js?ver=1.7.56-card2

js socolivess.co collected 2026-10-09 23:16:20 UTC 34,367 bytes, 1,052 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3  if (typeof get_stream_vars === 'undefined') { return; }
4  let page = 1;
5  if (get_stream_vars.IS_GENERATE_JSON == 0) {
6      $(".match-list-widget").each(function () {
7          var $widget = $(this);
8          var $matchItem = $widget.find(".match-item");
9
10      });
11      loading_time();
12
13      $("#current_url").attr("value", window.location.href);
14      $(".load-more").on("click", function () {
15        var e = this;
16        page = page + 1;
17        $.ajax({
18          url: ajax_address("load_more_match", { page: page }),
19          type: "GET",
20          async: true,
21          success: function (data) {
22            if (data) {
23              $(".match-list-shortcode").append(data);
24            } else {
25              $(".load-more").hide();
26            }
27
28            loading_time();
29          },
30          error: function (xhr, exception) {
31            var msg = "";
32            if (xhr.status === 0) {
33              msg = "Not connect.\n Verify Network." + xhr.responseText;
34            } else if (xhr.status == 404) {
35              msg = "Requested page not found. [404]" + xhr.responseText;
36            } else if (xhr.status == 500) {
37              msg = "Internal Server Error [500]." + xhr.responseText;
38            } else if (exception === "parsererror") {
39              msg = "Requested JSON parse failed.";
40            } else if (exception === "timeout") {
41              msg = "Time out error." + xhr.responseText;
42            } else if (exception === "abort") {
43              msg = "Ajax request aborted.";
44            } else {
45              msg = "Error:" + xhr.status + " " + xhr.responseText;
46            }
47            console.log(msg);
48          },
49        });
50      });
51
52      $(".match_filter li").on("click", function () {
53        page = 1;
54        var value = $(this).attr("data-value");
55        startUpdatingSummary(value);
56        if (value == "all") {
57          $(".load-more").show();
58          $(".load-more").removeAttr("hidden");
59        } else {
60          $(".load-more").hide();
61        }
62        var li = $(".match_filter li");
63        for (var i = 0; i < li.length; i++) {
64          $(li[i]).removeClass("active");
65        }
66        $(this).addClass("active");
67        $.ajax({
68          url: ajax_address("load_filter", { value: value }),
69          type: "GET",
70          async: true,
71          beforeSend: function () {
72            $(".match_filter").css("pointer-events", "none");
73            $(".match-list-shortcode").html(
74              '<div class="loader-container_scl"><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div></div>'
75            );
76          },
77          success: function (data) {
78            $(".match_filter").css("pointer-events", "unset");
79            $(".match-list-shortcode").html(data);
80            loading_time();
81          },
82          error: function (xhr, exception) {
83            $(".match_filter").css("pointer-events", "unset");
84            var msg = "";
85            if (xhr.status === 0) {
86              msg = "Not connect.\n Verify Network." + xhr.responseText;
87            } else if (xhr.status == 404) {
88              msg = "Requested page not found. [404]" + xhr.responseText;
89            } else if (xhr.status == 500) {
90              msg = "Internal Server Error [500]." + xhr.responseText;
91            } else if (exception === "parsererror") {
92              msg = "Requested JSON parse failed.";
93            } else if (exception === "timeout") {
94              msg = "Time out error." + xhr.responseText;
95            } else if (exception === "abort") {
96              msg = "Ajax request aborted.";
97            } else {
98              msg = "Error:" + xhr.status + " " + xhr.responseText;
99            }
100          },
101        });
102      });
103
104      $(".match-list-widget .load-more-wg").on("click", function () {
105        var layout = $(this).attr("data-layout");
106        var numberMatchInit = $(this).attr("data-number-match");
107        var widgetId = $(this).attr("data-widget-id");
108        var matchWidgetId = "#" + widgetId;
109        page = page + 1;
110        $.ajax({
111          url: ajax_address("load_more_match_wg", {
112            layout: layout,
113            page: page,
114            number_match_init: numberMatchInit ? numberMatchInit : 0,
115            widget_id: widgetId,
116          }),
117          type: "GET",
118          async: true,
119          success: function (data) {
120            if (data) {
121              $(matchWidgetId).append(data);
122            } else {
123              $("." + widgetId + " .load-more-wg").addClass("hide");
124            }
125            loading_time();
126          },
127          error: function (xhr, exception) {
128            var msg = "";
129            if (xhr.status === 0) {
130              msg = "Not connect.\n Verify Network." + xhr.responseText;
131            } else if (xhr.status == 404) {
132              msg = "Requested page not found. [404]" + xhr.responseText;
133            } else if (xhr.status == 500) {
134              msg = "Internal Server Error [500]." + xhr.responseText;
135            } else if (exception === "parsererror") {
136              msg = "Requested JSON parse failed.";
137            } else if (exception === "timeout") {
138              msg = "Time out error." + xhr.responseText;
139            } else if (exception === "abort") {
140              msg = "Ajax request aborted.";
141            } else {
142              msg = "Error:" + xhr.status + " " + xhr.responseText;
143            }
144          },
145        });
146      });
147
148      $(".match-list-widget .match_filter_wg li").on("click", function () {
149        page = 1;
150        var value = $(this).attr("data-value");
151        startUpdatingSummary(value);
152        var layout = $(this).attr("data-layout");
153        var numberMatchInit = $(this).attr("data-number-match");
154        var widgetId = $(this).closest(".tab-data").attr("data-widget-id");
155        var matchWidgetId = "#" + widgetId;
156
157        if (value == "all") {
158          $("." + widgetId + " .load-more-wg").removeClass("hide");
159        } else {
160          $("." + widgetId + " .load-more-wg").addClass("hide");
161        }
162
163        $(
164          ".tab-data[data-widget-id='" + widgetId + "'] .match_filter_wg li"
165        ).removeClass("active");
166
167        $(this).addClass("active");
168
169        $.ajax({
170          url: ajax_address("load_filter_wg", {
171            value: value,
172            layout: layout,
173            number_match_init: numberMatchInit ? numberMatchInit : 0,
174          }),
175          type: "GET",
176          async: true,
177          beforeSend: function () {
178            $(matchWidgetId).html(
179              '<div class="loader-container_scl"><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div></div>'
180            );
181          },
182          success: function (data) {
183            $(matchWidgetId).html(data);
184            loading_time();
185          },
186          error: function (xhr, exception) {
187            var msg = "";
188            if (xhr.status === 0) {
189              msg = "Not connect.\n Verify Network." + xhr.responseText;
190            } else if (xhr.status == 404) {
191              msg = "Requested page not found. [404]" + xhr.responseText;
192            } else if (xhr.status == 500) {
193              msg = "Internal Server Error [500]." + xhr.responseText;
194            } else if (exception === "parsererror") {
195              msg = "Requested JSON parse failed.";
196            } else if (exception === "timeout") {
197              msg = "Time out error." + xhr.responseText;
198            } else if (exception === "abort") {
199              msg = "Ajax request aborted.";
200            } else {
201              msg = "Error:" + xhr.status + " " + xhr.responseText;
202            }
203          },
204        });
205      });
206
207      taxonomy_page = 1;
208
209      $("body").on("click", ".loadmore_taxonomy", function (event) {
210        event.preventDefault();
211        var term_id = $(this).attr("data-termid");
212        taxonomy_page = taxonomy_page + 1;
213        $.ajax({
214          url: ajax_address("get_match_by_term", {
215            term_id: term_id,
216            page: taxonomy_page,
217          }),
218          async: true,
219          success: function (data) {
220            if (data) {
221              $(".match-list").append(data);
222            } else {
223              $(".loadmore_taxonomy").remove();
224            }
225          },
226          error: function (xhr, exception) {
227            var msg = "";
228            if (xhr.status === 0) {
229              msg = "Not connect.\n Verify Network." + xhr.responseText;
230            } else if (xhr.status == 404) {
231              msg = "Requested page not found. [404]" + xhr.responseText;
232            } else if (xhr.status == 500) {
233              msg = "Internal Server Error [500]." + xhr.responseText;
234            } else if (exception === "parsererror") {
235              msg = "Requested JSON parse failed.";
236            } else if (exception === "timeout") {
237              msg = "Time out error." + xhr.responseText;
238            } else if (exception === "abort") {
239              msg = "Ajax request aborted.";
240            } else {
241              msg = "Error:" + xhr.status + " " + xhr.responseText;
242            }
243          },
244        });
245      });
246
247      $(".toc_list li").click(function () {
248        $(".toc_list li").removeClass("active");
249        $(this).addClass("active");
250        $(window).scrollTop(200);
251      });
252
253      $(".blv-collapse").click(function (event) {
254        event.stopPropagation();
255      });
256
257      if (elementsExist()) {
258        startUpdatingSummary(null);
259      }
260
261      let updateSummaryInterval;
262
263    function updateSummary() {
264      $.ajax({
265        url: ajax_url,
266        async: true,
267        method: "GET",
268        data: {
269          action: "live_summary",
270        },
271        dataType: "json",
272        success: function (data) {
273          if (!data || !data.live) {
274            return;
275          }
276
277          const summary = data.summary;
278          if (summary) {
279            $('li[data-value="all"] span').attr("amount", summary.total);
280            $('li[data-value="live"] span').attr("amount", summary.live);
281            $('li[data-value="hot"] span').attr("amount", summary.hot);
282            $('li[data-value="tday"] span').attr("amount", summary.today);
283            $('li[data-value="tmr"] span').attr("amount", summary.tomorrow);
284          }
285
286          var existingMatchIds = new Map();
287          $(".match-list .match-item").each(function () {
288            var matchId = $(this).attr("data-match-id") || $(this).attr("match-id");
289            var status = $(this).attr("status-id");
290            if (matchId) {
291              existingMatchIds.set(matchId, status);
292            }
293          });
294
295          data.live.forEach((live) => {
296            var html = $(live.html).hide();
297            var ls_id = live.ls_id.toString();
298            var status_id = live.status_id;
299
300            // The stream bundle owns cards marked as current. Its realtime
301            // state includes score, HT, corners and cards; replacing such a
302            // node with this 30-second server snapshot would roll those
303            // values back to cached HTML. Status transitions are handled by
304            // the bundle's next tick as well.
305            var currentItem = $(
306              `.match-list .match-item[data-match-id="${ls_id}"], .match-list .match-item[match-id="${ls_id}"]`
307            ).first();
308            if (currentItem.attr("data-soco-state") === "current") {
309              existingMatchIds.set(ls_id, status_id);
310              return;
311            }
312
313            if (existingMatchIds.has(ls_id)) {
314              var existingStatusId = existingMatchIds.get(ls_id);
315              if (existingStatusId !== status_id) {
316                $(
317                  `.match-list .match-item[data-match-id="${ls_id}"], .match-list .match-item[match-id="${ls_id}"]`
318                ).fadeOut(300, function () {
319                  $(this).remove();
320                  prependToMatchList(html, existingStatusId, status_id, ls_id);
321                  html.fadeIn(300);
322                  existingMatchIds.set(ls_id, status_id);
323                });
324              }
325            } else {
326              prependToMatchList(html, null, status_id, ls_id);
327              html.fadeIn(300);
328              existingMatchIds.set(ls_id, status_id);
329            }
330          });
331
332          function prependToMatchList(html, existingStatusId, status_id, ls_id) {
333            var matchItem = $(
334              `.match-list .match-item[data-match-id="${ls_id}"], .match-list .match-item[match-id="${ls_id}"]`
335            );
336            if (matchItem.length > 0 && !matchItem.hasClass("live-match")) {
337              matchItem.fadeOut(300, function () {
338                $(this).remove();
339                prependToZeroStatus(html);
340                html.fadeIn(300);
341              });
342            } else {
343              html.addClass("live-match");
344              if (status_id == 8) {
345                prependToZeroStatus(html);
346              } else {
347                $(".match-list").prepend(html);
348              }
349            }
350          }
351
352          function prependToZeroStatus(html) {
353
354            var firstZeroStatusItem = $(".match-list .match-item[status-id='0']")
355              .not(".live-match")
356              .first();
357            if (firstZeroStatusItem.length > 0) {
358              firstZeroStatusItem.before(html);
359            } else {
360              $(".match-list .match-item").each(function () {
361
362                if (
363                  $(this).attr("status-id") == "0" &&
364                  !$(this).hasClass("live-match")
365                ) {
366                  $(this).before(html);
367                  return false;
368                }
369              });
370            }
371          }
372        },
373        error: function (xhr, status, error) {
374          console.log("Error summary:", error);
375        },
376      });
377    }
378
379    function startUpdatingSummary(currenttab) {
380      if (updateSummaryInterval) {
381        clearInterval(updateSummaryInterval);
382      }
383
384      if (
385        currenttab !== "tmr" &&
386        elementsExist() &&
387        currenttab !== "hot" &&
388        elementsExist()
389      ) {
390        updateSummaryInterval = setInterval(updateSummary, 30000);
391
392      }
393    }
394
395    function elementsExist() {
396      return $(".match-list").length > 0 || $(".match-list-widget").length > 0;
397      }
398      }
399});
400
401function randomInt(min, max) {
402  return Math.floor(Math.random() * (max - min + 1)) + min;
403}
404
405function sendErorrStreaming(room_id, blv, current_url) {
406
407}
408
409function ajax_address(action, params = null) {
410  if (params) {
411    var query = "&" + new URLSearchParams(params).toString();
412  }
413  var sdf = ajax_url + "?action=" + action + query;
414  return sdf;
415}
416function openreportmodal() {
417  var asdsad = document.getElementById("report-modal");
418  asdsad.classList.add("active");
419}
420function closereportmodal() {
421  var asdsad = document.getElementById("report-modal");
422  asdsad.classList.remove("active");
423}
424function loading_time() {
425  jQuery("div[data-time-mode='unload']").each(function () {
426    var timestamp = jQuery(this).attr("data-time");
427    jQuery(this).attr("data-time-mode", "loaded");
428    var date = new Date(parseInt(timestamp, 10));
429    jQuery(this)
430      .find(".match-time")
431      .html(
432        load_2digit(date.getHours()) + ":" + load_2digit(date.getMinutes())
433      );
434    jQuery(this)
435      .find(".match-date")
436      .html(
437        load_2digit(date.getDate()) + "/" + load_2digit(date.getMonth() + 1)
438      );
439  });
440}
441function load_2digit($no = 0) {
442  if ($no < 10) return "0" + $no;
443  return $no;
444}
445function create_ads_btn() {
446  try {
447    if (!buttonList) return;
448    if (buttonList) {
449      var html = '<div class="button-area">';
450      buttonList.forEach((value, index) => {
451        html +=
452          '<a href="' +
453          value.link +
454          '" style="background:' +
455          value.background +
456          ";color:" +
457          value.color +
458          '" id="' +
459          value.id +
460          '" target="_blank">' +
461          value.textfull +
462          "</a>";
463      });
464      html += "</div>";
465    }
466    return html;
467  } catch (err) {
468  }
469}
470function append_btn() {
471  jQuery("#player-stream").append(create_ads_btn());
472}
473function load_realtime(result) {
474  if (result.stats) {
475    for (var i = 0; i < result.stats.length; i++) {
476      var cur = result.stats[i];
477      var total = cur["home"] + cur["away"];
478      var home_per = (cur["home"] * 100) / total;
479      var away_per = (cur["away"] * 100) / total;
480      var selector = jQuery(".group-bar[data-type='" + cur["type"] + "']");
481      jQuery(selector.find(".home-bar .bar-label")).html(cur["home"]);
482      jQuery(selector.find(".away-bar .bar-label")).html(cur["away"]);
483      var home_side = selector.find(".home-bar .stat-bar");
484      if (home_side) jQuery(home_side).attr("style", "width:" + home_per + "%");
485      var away_side = selector.find(".away-bar .stat-bar");
486      if (away_side) jQuery(away_side).attr("style", "width:" + away_per + "%");
487    }
488  }
489}
490const form = document.querySelector("#feedback-form");
491feedbacksubmitted = false;
492if (form) {
493  form.addEventListener("submit", (e) => {
494    e.preventDefault();
495    const formData = new FormData(form);
496    const obj = Object.fromEntries(formData);
497    var e_msg = document.getElementById("form-message");
498    if (obj.problem_op != 0) {
499      if (feedbacksubmitted == false) {
500        $.ajax({
501          url: ajax_address("report_form", {}),
502          type: "POST",
503          async: true,
504          data: obj,
505          success: function (data) {
506            feedbacksubmitted = true;
507            e_msg.classList.remove("success");
508            e_msg.classList.remove("error");
509            e_msg.classList.add("success");
510
511            e_msg.innerHTML = theme_lang.submitted_feedback;
512          },
513          error: function (xhr, exception) {
514            e_msg.classList.remove("success");
515            e_msg.classList.remove("error");
516            e_msg.classList.add("error");
517            e_msg.innerHTML = theme_lang.unknown_feebackerror;
518          },
519        });
520      } else {
521        e_msg.classList.remove("success");
522        e_msg.classList.remove("error");
523        e_msg.classList.add("error");
524        e_msg.innerHTML = theme_lang.already_submitted;
525      }
526    } else {
527      e_msg.classList.remove("success");
528      e_msg.classList.remove("error");
529      e_msg.classList.add("error");
530
531      e_msg.innerHTML = theme_lang.feedback_option_require;
532    }
533  });
534}
535function show_blv(e) {
536  document.querySelectorAll(".blv-collapse").forEach(function (element) {
537    element.classList.remove("active");
538  });
539  e.target.parentElement.classList.add("active");
540}
541
542function close_blv(e) {
543  e.target.parentElement.classList.remove("active");
544}
545
546document.addEventListener("click", function (event) {
547  var blvElements = document.querySelectorAll(".blv-collapse.active");
548  blvElements.forEach(function (blvElement) {
549    if (!blvElement.contains(event.target)) {
550      blvElement.classList.remove("active");
551    }
552  });
553});
554
555document.querySelectorAll(".blv-toggle").forEach(function (toggle) {
556  toggle.addEventListener("click", function (e) {
557    e.stopPropagation();
558    show_blv(e);
559  });
560});
561
562document.querySelectorAll(".close-blv").forEach(function (close) {
563  close.addEventListener("click", function (e) {
564    e.stopPropagation();
565    close_blv(e);
566  });
567});
568
569document.addEventListener("DOMContentLoaded", function () {
570  initializePlayerPadding();
571});
572function replace_url_scl(newURL) {
573  window.history.replaceState(null, "", newURL);
574}
575function checkAndLoadDecSpdbCreateFrame() {
576  // Legacy entry point retained for theme compatibility. Soco Engine now
577  // obtains an opaque Sportbo ticket before it creates the Tracker iframe.
578  initializePlayerPadding();
579}
580
581function createIframe() {
582  // Deliberately disabled: the ticket bootstrap in includes/helpers.php is
583  // the only code allowed to create a Tracker iframe.
584  return;
585}
586
587function initializePlayerPadding() {
588  const playerPaddingElements = document.querySelectorAll('.player-padding');
589
590  playerPaddingElements.forEach(playerPadding => {
591    if (playerPadding.querySelector('#live-tracker-container')) {
592      const setPadding = () => {
593        if (window.innerWidth >= 1200 && window.innerWidth <= 1400) {
594          playerPadding.style.paddingBottom = '68%';
595        } else if (window.innerWidth < 1200) {
596          playerPadding.style.paddingBottom = '82%';
597        } else {
598          playerPadding.style.paddingBottom = '66%';
599        }
600      };
601
602      setPadding();
603      window.addEventListener('resize', setPadding);
604    }
605  });
606}
607
608const checkURLStatus = (file) => {
609  return new Promise((resolve, reject) => {
610      jQuery.ajax({
611          url: file,
612          type: 'GET',
613          success: function () {
614              resolve({ isAccessible: true, status: 200 });
615          },
616          error: function (xhr) {
617              if (xhr.status === 403 || xhr.status === 503) {
618                  resolve({ isAccessible: false, status: xhr.status });
619              } else {
620                  reject(xhr);
621              }
622          }
623      });
624  });
625};
626
627const RemoveContentLivetracker = () => {
628  const trackerContainer = jQuery("#live-tracker-container");
629  const detailWidget = jQuery(".widget_container_inner");
630
631  if (trackerContainer.length > 0) {
632
633    initializePlayerPadding();
634
635    const recentContainer = detailWidget.find(".recent-container");
636    if (recentContainer.length > 0) {
637      classChanges.push({
638        element: recentContainer,
639        remove: "recent-container",
640        add: "matches-list-recent"
641      });
642      recentContainer.removeClass("recent-container").addClass("matches-list-recent");
643    }
644
645    const colDiv8 = detailWidget.find(".live-tracker-match-recent .col-12.col-lg-8").first();
646    if (colDiv8.length > 0) {
647      removedElements.push({
648        element: colDiv8,
649        parent: colDiv8.parent(),
650        index: colDiv8.index()
651      });
652      colDiv8.remove();
653    }
654
655    const matchH2H = detailWidget.find(".live-tracker-match-recent .match-history-h2h").first();
656    if (matchH2H.length > 0) {
657      removedElements.push({
658        element: matchH2H,
659        parent: matchH2H.parent(),
660        index: matchH2H.index()
661      });
662      matchH2H.remove();
663    }
664
665    const colDiv4 = detailWidget.find(".live-tracker-match-recent .col-12.col-lg-4").first();
666    if (colDiv4.length > 0) {
667      classChanges.push({
668        element: colDiv4,
669        remove: "col-12 col-lg-4",
670        add: ""
671      });
672      colDiv4.removeClass("col-12 col-lg-4");
673    }
674
675    const rowWrap = detailWidget.find(".live-tracker-match-recent").closest(".row");
676    if (rowWrap.length > 0) {
677      classChanges.push({
678        element: rowWrap,
679        remove: "row",
680        add: ""
681      });
682      rowWrap.removeClass("row");
683    }
684  }
685};
686
687let removedElements = [];
688let classChanges = [];
689
690const moveContentToPlayer = () => {
691  const trackerContainer = jQuery("#live-tracker-container");
692  const detailWidget = jQuery(".widget_container_inner");
693
694  if (trackerContainer.length > 0) {
695    jQuery(".player-padding").append(trackerContainer);
696    initializePlayerPadding();
697    jQuery(".player-box iframe").addClass("show");
698
699    const recentContainer = detailWidget.find(".recent-container");
700    if (recentContainer.length > 0) {
701      classChanges.push({
702        element: recentContainer,
703        remove: "recent-container",
704        add: "matches-list-recent"
705      });
706      recentContainer.removeClass("recent-container").addClass("matches-list-recent");
707    }
708
709    const colDiv8 = detailWidget.find(".live-tracker-match-recent .col-12.col-lg-8").first();
710    if (colDiv8.length > 0) {
711      removedElements.push({
712        element: colDiv8,
713        parent: colDiv8.parent(),
714        index: colDiv8.index()
715      });
716      colDiv8.remove();
717    }
718
719    const matchH2H = detailWidget.find(".live-tracker-match-recent .match-history-h2h").first();
720    if (matchH2H.length > 0) {
721      removedElements.push({
722        element: matchH2H,
723        parent: matchH2H.parent(),
724        index: matchH2H.index()
725      });
726      matchH2H.remove();
727    }
728
729    const colDiv4 = detailWidget.find(".live-tracker-match-recent .col-12.col-lg-4").first();
730    if (colDiv4.length > 0) {
731      classChanges.push({
732        element: colDiv4,
733        remove: "col-12 col-lg-4",
734        add: ""
735      });
736      colDiv4.removeClass("col-12 col-lg-4");
737    }
738
739    const rowWrap = detailWidget.find(".live-tracker-match-recent").closest(".row");
740    if (rowWrap.length > 0) {
741      classChanges.push({
742        element: rowWrap,
743        remove: "row",
744        add: ""
745      });
746      rowWrap.removeClass("row");
747    }
748  }
749};
750
751const restoreLiveTracker = () => {
752  const trackerContainer = jQuery("#live-tracker-container");
753  const liveTrackerMatchRecent = jQuery(".live-tracker-match-recent");
754  const playerPadding = jQuery(".player-padding");
755  if (trackerContainer.length && playerPadding.has(trackerContainer).length) {
756    trackerContainer.detach();
757  }
758
759  const normalElements = removedElements.filter(
760    ({ element }) => !element.hasClass("match-history-h2h")
761  );
762  const h2hElements = removedElements.filter(
763    ({ element }) => element.hasClass("match-history-h2h")
764  );
765
766  normalElements
767    .sort((a, b) => b.index - a.index)
768    .forEach(({ element, parent, index }) => {
769      if (parent && element) {
770        const children = parent.children();
771        if (index >= children.length) {
772          parent.append(element);
773        } else {
774          element.insertBefore(children.eq(index));
775        }
776      }
777    });
778
779  h2hElements.forEach(({ element, parent }) => {
780    if (parent && element) {
781      parent.append(element);
782    }
783  });
784
785  removedElements = [];
786
787  classChanges.forEach(({ element, remove, add }) => {
788    if (element && remove) {
789      element.addClass(remove);
790    }
791    if (element && add) {
792      element.removeClass(add);
793    }
794  });
795
796  const divsWithEmbedClass = liveTrackerMatchRecent.find(".embed-responsive-item-widget");
797  if (divsWithEmbedClass.length && divsWithEmbedClass.length) {
798    divsWithEmbedClass.append(trackerContainer);
799  }
800  classChanges = [];
801};
802
803const backToTopButton = document.getElementById("backToTop");
804
805if (backToTopButton) {
806    backToTopButton.addEventListener("click", function () {
807        window.scrollTo({ top: 0, behavior: "smooth" });
808    });
809}
810
811jQuery(document).ready(function () {
812    const data = window.streamData;
813    const searchParams = new URLSearchParams(window.location.search);
814    const hasBlvParam = searchParams.has('blv');
815
816    if (window.socoPlayerEngine === 'hlsjs') {
817        return;
818    }
819
820    if (
821        !window.location.href.includes("truc-tiep") ||
822        !data || typeof data !== 'object' ||
823        !Array.isArray(data.anchors) || !data.anchors.length ||
824        !data.scheduleId ||
825        hasBlvParam
826    ) {
827        return;
828    }
829
830    const anchors = data.anchors;
831    const playerHost = data.playerHost || '';
832    const thumbnail = data.thumbnail || '';
833    const matchTime = data.matchTime || 0;
834    const timeEnd = data.timeEnd || 0;
835    const matchId = data.matchId || '';
836    const scheduleId = data.scheduleId;
837    const isAllStreamBroadcast = data.isAllStreamBroadcast;
838    const sportId = parseInt(data.sportId || 0, 10);
839
840    const isAllStreamBroadcast_check = (typeof get_api_livescore_ajax_vars !== 'undefined')
841    ? get_api_livescore_ajax_vars.is_all_stream_broadcast
842    : false;
843
844    if (isAllStreamBroadcast_check == 1 || isAllStreamBroadcast_check == true || isAllStreamBroadcast_check == "true") {
845        console.log("Broadcast");
846    } else {
847        if (anchors && anchors.length > 0) {
848            const randomBLV = anchors[Math.floor(Math.random() * anchors.length)];
849            uid = randomBLV.uid;
850            roomID = randomBLV.roomID || '';
851            streamer_name = randomBLV.streamer_name || '';
852            uid_s = uid;
853        }
854    }
855
856    jQuery(".author-list ul li a").each(function () {
857        const href = jQuery(this).attr("href");
858        if (href.includes("blv=" + uid)) {
859            jQuery(this).addClass("active");
860        }
861    });
862
863    const now = Date.now();
864    const matchTimeMs = matchTime * 1000;
865    const timeEndMs = timeEnd * 1000;
866
867    const showPlayer = now > (matchTimeMs - 600000);
868    const isTimeEndValid = !timeEnd || (now - timeEndMs) <= 5 * 60 * 1000;
869    let overlay = document.getElementById("custom-play-overlay");
870
871    const stream_HDlink = (isAllStreamBroadcast || !scheduleId)
872    ? `${playerHost}/default/${matchId}.m3u8`
873    : `${playerHost}/room/${uid}.m3u8`;
874
875    let retryInterval = null;
876
877    const setupPlayer = (file) => {
878        const playerInstance = jwplayer("player-stream").setup({
879            file: file,
880            autostart: true,
881            mute: true,
882            image: thumbnail,
883        });
884
885        playerInstance.on('ready', () => {
886            jQuery('.countdown_scl_wrap').remove();
887            append_btn();
888        });
889
890        playerInstance.on("firstFrame", () => {
891            playerInstance.pause(true);
892            if (overlay) overlay.style.display = "flex";
893        });
894
895        playerInstance.on("play", () => {
896            if (overlay) overlay.style.display = "none";
897            playerInstance.setMute(false);
898        });
899
900        playerInstance.on("pause", () => {
901            if (overlay) overlay.style.display = "flex";
902        });
903        overlay.addEventListener("click", () => {
904            if (getComputedStyle(overlay).display !== 'none') {
905                overlay.style.display = "none";
906                $(".player-box").click();
907            }
908        });
909
910        const handleError = () => {
911            jQuery('.jw-error-text').html(
912                'BLV hiện tại không có mặt. Tự động đổi qua bình luận viên khác trong 3 giây'
913            );
914            jQuery('.jw-error-msg .jw-icon').hide();
915
916            setTimeout(() => {
917                const availableBlvs = jQuery('.author-list a:not(.active)');
918                if (availableBlvs.length > 0) {
919                    const randomIndex = randomInt(0, availableBlvs.length - 1);
920                    window.location.href =
921                        jQuery(availableBlvs[randomIndex]).attr("href");
922                }
923            }, 3000);
924        };
925
926        playerInstance.on('error', () => {
927            if (file === stream_HDlink) {
928                setTimeout(() => {
929                    moveContentToPlayer();
930
931                    if (!retryInterval) {
932                        retryInterval = setInterval(() => {
933                            const newPlayer = jwplayer("player-stream").setup({
934                                file: stream_HDlink,
935                                autostart: true,
936                                image: thumbnail,
937                            });
938
939                            newPlayer.on('play', () => {
940                                clearInterval(retryInterval);
941                                retryInterval = null;
942                                restoreLiveTracker();
943                                jQuery('.countdown_scl_wrap').remove();
944                                append_btn();
945                            });
946
947                            newPlayer.on('error', () => {
948                                const playerStream = jQuery(".player-padding");
949                                if (
950                                    playerStream.length &&
951                                    !playerStream.find("#live-tracker-container").length
952                                ) {
953                                    moveContentToPlayer();
954                                }
955                            });
956                        }, 10000);
957                    }
958                }, 1000);
959            } else {
960                handleError();
961            }
962        });
963    };
964
965    if (showPlayer && isTimeEndValid) {
966        setupPlayer(stream_HDlink);
967        return;
968    }
969
970    if (timeEnd && sportId === 1) {
971        if (window.shouldPlayStream) {
972            setupPlayer(stream_HDlink);
973        } else {
974            showEnded();
975        }
976        return;
977    }
978
979    if (timeEnd) {
980        showEnded();
981    } else {
982        showNotStarted();
983    }
984
985    function showEnded() {
986        jQuery(".loading-player").html("Trận đấu đã kết thúc");
987    }
988
989    function showNotStarted() {
990        jQuery(".loading-player").html("Trận đấu chưa bắt đầu");
991    }
992
993    $("#custom-play-overlay").on("click", function() {
994                if (jwplayer("player-stream").getState() === 'playing') {
995                    jwplayer("player-stream").pause();
996                } else {
997                    jwplayer("player-stream").play();
998                }
999            });
1000           setTimeout(function() {
1001                $(".jw-video").on("click", function() {
1002
1003                        if (jwplayer("player-stream").getState() === 'playing' && $(".jw-controlbar").css('visibility') !== 'hidden') {
1004                            jwplayer("player-stream").pause();
1005                        } else {
1006                            jwplayer("player-stream").play();
1007                        }
1008                });
1009            }, 1000);
1010});
1011
1012document.addEventListener("DOMContentLoaded", function() {
1013    const urlParams = new URLSearchParams(window.location.search);
1014    const sportId = urlParams.get('sport-id');
1015
1016    if (!sportId) return;
1017
1018    const sportMap = {
1019        '1': 'football-tab',
1020        '2': 'basketball-tab',
1021        '3': 'volleyball-tab',
1022        '4': 'badminton-tab',
1023        '5': 'tennis-tab',
1024        '6': 'table-tennis-tab'
1025    };
1026
1027    const tabId = sportMap[sportId];
1028    if (!tabId) return;
1029
1030    const targetTab = document.getElementById(tabId);
1031    if (targetTab) {
1032        targetTab.click();
1033    }
1034});
1035
1036document.addEventListener('DOMContentLoaded', function() {
1037    const trigger = document.querySelector('.sports-expand-trigger');
1038    const btn = document.querySelector('.sports-expand-btn');
1039
1040    if (btn && trigger) {
1041      btn.addEventListener('click', function(e) {
1042        e.stopPropagation();
1043        trigger.classList.toggle('is-open');
1044      });
1045
1046      document.addEventListener('click', function(e) {
1047        if (!trigger.contains(e.target)) {
1048          trigger.classList.remove('is-open');
1049        }
1050      });
1051    }
1052  });

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.