update 1. GTP-6 Astra, оптимизация кода и фикс
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
(() => {
|
||||
"use strict";
|
||||
const runtimeStorage = window.HockeyMatchAccess?.storage || localStorage;
|
||||
|
||||
const boot = window.UI_BUILDER_BOOT || {};
|
||||
if (boot.mode !== "runtime") return;
|
||||
@@ -58,7 +59,7 @@
|
||||
const game = data.hockey?.selected_game || null;
|
||||
const tournament = data.hockey?.selected_tournament || null;
|
||||
const language = data.hockey?.language?.display
|
||||
|| localStorage.getItem("hockey.language")
|
||||
|| runtimeStorage.getItem("hockey.language")
|
||||
|| "ru";
|
||||
const timer = window.UIBuilderRuntime?.getTimer?.(state.timerId) || null;
|
||||
const board = window.UIBuilderRuntime?.getHockeyPenaltyBoard?.(state.dashboardId) || {};
|
||||
@@ -120,7 +121,11 @@
|
||||
state.control = await controlRequest(`/games/${encodeURIComponent(gameId)}/control?language=${language}`);
|
||||
state.controlFetchedAt = Date.now();
|
||||
const nextPeriod = String(state.control?.current_period || "");
|
||||
if (previousPeriod && nextPeriod && previousPeriod !== nextPeriod) {
|
||||
if (!window.HockeyMatchAccess?.canControl?.(gameId)) {
|
||||
window.dispatchEvent(new CustomEvent("hockey:control-snapshot", {
|
||||
detail: { game_id: gameId, control: state.control },
|
||||
}));
|
||||
} else if (previousPeriod && nextPeriod && previousPeriod !== nextPeriod) {
|
||||
window.UIBuilderRuntime?.patchData?.({ hockey: { game_control: state.control } });
|
||||
window.dispatchEvent(new CustomEvent("hockey:game-control-updated", {
|
||||
detail: { game_id: gameId, control: state.control, apply_timers: true },
|
||||
@@ -135,6 +140,7 @@
|
||||
}
|
||||
|
||||
async function updatePeriod(gameId, value, language) {
|
||||
if (!window.HockeyMatchAccess?.canControl?.(gameId)) return;
|
||||
try {
|
||||
state.control = await controlRequest(`/games/${encodeURIComponent(gameId)}/control/period`, {
|
||||
method: "PUT",
|
||||
@@ -237,6 +243,7 @@
|
||||
const strengthStateLabel = String(strength.state_label || "");
|
||||
const signature = JSON.stringify({
|
||||
game: game?.external_id || "",
|
||||
canControl: window.HockeyMatchAccess?.canControl?.(String(game?.external_id || game?.id || "")) === true,
|
||||
homeName,
|
||||
awayName,
|
||||
scoreHome,
|
||||
@@ -304,7 +311,7 @@
|
||||
</div>
|
||||
<label class="hockey-status-period">
|
||||
<span>${language === "en" ? "CURRENT PERIOD" : "ТЕКУЩИЙ ПЕРИОД"}</span>
|
||||
<select data-hockey-current-period ${game ? "" : "disabled"}>${periodOptions.map((item) => `<option value="${escapeHtml(item.value)}" ${String(item.value) === currentPeriod ? "selected" : ""}>${escapeHtml(item.label)}</option>`).join("")}</select>
|
||||
<select data-hockey-current-period ${game && window.HockeyMatchAccess?.canControl?.(String(game.external_id || game.id || "")) ? "" : "disabled"}>${periodOptions.map((item) => `<option value="${escapeHtml(item.value)}" ${String(item.value) === currentPeriod ? "selected" : ""}>${escapeHtml(item.label)}</option>`).join("")}</select>
|
||||
</label>
|
||||
<div class="hockey-status-clock ${value.timer?.running ? "is-running" : "is-paused"}">
|
||||
<span>${language === "en" ? "MAIN TIMER" : "ОСНОВНОЙ ТАЙМЕР"}</span>
|
||||
|
||||
Reference in New Issue
Block a user