180 build - свои плюсы

This commit is contained in:
2026-10-02 12:24:21 +03:00
parent 5a72c73977
commit 48fd0a03b5
8 changed files with 174 additions and 4 deletions

View File

@@ -172,6 +172,7 @@
preparedTitleSnapshotLoading: false,
customPluses: { home: [], away: [] },
customPlusesTeams: { home: {}, away: {} },
customPlusesLinkUrl: "",
customPlusesLoading: false,
customPlusesSaving: false,
customPlusesLoadedKey: "",
@@ -6048,6 +6049,9 @@ function applyExternalDataPatch(patch, { render = true } = {}) {
getTimer: (actionId) => { const component = componentByActionId(actionId); const timerState = isTimerComponent(component) ? ensureTimerState(component) : null; return timerState ? clone({ ...timerState, formatted: formatTimerValue(component, timerState) }) : null; },
openTimersEditor: (actionId = "") => openTimerQuickEditor(actionId),
getHockeyPenaltyBoard: (actionId) => clone(state.hockeyPenaltyBoards[actionId] || {}),
getHockeyPenaltyPresets: () => clone((state.config.components || [])
.filter((component) => component.type === "hockey_penalty_dashboard")
.flatMap((component) => parseHockeyPenaltyPresets(component.props?.presets))),
assignHockeyPenalty: (actionId, player, preset = "2") => { const component = componentByActionId(actionId); return component?.type === "hockey_penalty_dashboard" ? assignHockeyPenalty(component, player, preset) : false; },
controlHockeyPenalty: (actionId, penaltyId, command, value = "") => { const component = componentByActionId(actionId); return component?.type === "hockey_penalty_dashboard" ? controlHockeyPenalty(component, penaltyId, command, value) : false; },
getConfig: () => clone(state.config),
@@ -11028,10 +11032,22 @@ function hockeyCustomPlusesPayloadRows() {
})));
}
function hockeyCustomPlusesLinkHref(value) {
const raw = String(value || "").trim();
if (!raw) return "";
try {
const url = new URL(raw.startsWith("//") ? `https:${raw}`
: /^[a-z][a-z\d+.-]*:/i.test(raw) ? raw : `https://${raw}`);
return ["http:", "https:"].includes(url.protocol) && url.hostname ? url.href : "";
} catch (_) {
return "";
}
}
async function hockeySaveCustomPluses({ immediate = false } = {}) {
if (!hockeyCanControl()) return false;
const gameId = hockeyCustomPlusesWorkspaceKey();
if (!gameId) return false;
if (!gameId || state.customPlusesLoadedKey !== gameId) return false;
if (state.customPlusesSaveTimer) {
clearTimeout(state.customPlusesSaveTimer);
state.customPlusesSaveTimer = null;
@@ -11051,7 +11067,7 @@ async function hockeySaveCustomPluses({ immediate = false } = {}) {
try {
await hockeyGameControlRequest(`/games/${encodeURIComponent(gameId)}/custom-pluses`, {
method: "PUT",
body: JSON.stringify({ rows, language: hockeyGameControlLanguage() }),
body: JSON.stringify({ rows, link_url: state.customPlusesLinkUrl, language: hockeyGameControlLanguage() }),
});
if (gameId === hockeyCustomPlusesWorkspaceKey() && state.customPlusesRevision === revision) {
state.customPlusesDirty = false;
@@ -11085,6 +11101,7 @@ async function hockeyLoadCustomPlusesWorkspace({ force = false } = {}) {
state.customPlusesLoadedKey = "";
state.customPluses = { home: [], away: [] };
state.customPlusesTeams = { home: {}, away: {} };
state.customPlusesLinkUrl = "";
if (state.activeTab === "custom_pluses") renderRuntime();
return false;
}
@@ -11098,6 +11115,7 @@ async function hockeyLoadCustomPlusesWorkspace({ force = false } = {}) {
hockeySeedCustomPlusRows("home", payload?.home);
hockeySeedCustomPlusRows("away", payload?.away);
state.customPlusesTeams = payload?.teams || { home: {}, away: {} };
state.customPlusesLinkUrl = String(payload?.link_url || "");
state.customPlusesLoadedKey = gameId;
state.customPlusesDirty = false;
state.customPlusesLastSavedAt = "";
@@ -11143,6 +11161,13 @@ function renderHockeyCustomPlusesWorkspace() {
node.innerHTML = `
<header class="hcp-header">
<div><span>MATCH NOTES</span><strong>Свои плюсы</strong><small>Матч ${escapeHtml(gameId)} · каждая строка сохраняется в базе</small></div>
<label class="hcp-header-link">
<span>Общая ссылка</span>
<span class="hcp-link-control">
<input type="url" maxlength="2000" autocomplete="off" spellcheck="false" data-custom-pluses-link value="${escapeHtml(state.customPlusesLinkUrl)}" placeholder="https://…" aria-label="Общая ссылка для своих плюсов" ${hockeyCanControl() ? "" : "disabled"}>
<a class="hcp-link-open" data-custom-pluses-link-open target="_blank" rel="noopener noreferrer">Открыть ↗</a>
</span>
</label>
<span class="hcp-save-state" data-custom-pluses-save-state>${escapeHtml(hockeyCustomPlusesSaveStateText())}</span>
</header>
<div class="hcp-columns">
@@ -11154,6 +11179,30 @@ function renderHockeyCustomPlusesWorkspace() {
</section>`).join("")}
</div>`;
const linkInput = node.querySelector("[data-custom-pluses-link]");
const linkOpen = node.querySelector("[data-custom-pluses-link-open]");
const updateLink = () => {
const href = hockeyCustomPlusesLinkHref(state.customPlusesLinkUrl);
if (href) linkOpen.setAttribute("href", href);
else linkOpen.removeAttribute("href");
linkOpen.classList.toggle("is-disabled", !href);
linkOpen.setAttribute("aria-disabled", href ? "false" : "true");
linkOpen.tabIndex = href ? 0 : -1;
};
updateLink();
linkOpen.addEventListener("click", (event) => {
if (!linkOpen.hasAttribute("href")) event.preventDefault();
});
linkInput.addEventListener("input", () => {
if (!hockeyCanControl()) return;
state.customPlusesLinkUrl = linkInput.value;
updateLink();
hockeyScheduleCustomPlusesSave();
});
linkInput.addEventListener("blur", () => {
if (state.customPlusesDirty) hockeyScheduleCustomPlusesSave(120);
});
const rowRef = (raw) => {
const [side, indexRaw] = String(raw || "").split(":");
const index = Number(indexRaw);

View File

@@ -8064,6 +8064,58 @@ body.hockey-navigation-open .runtime-viewport.has-hockey-pbp { gap: 14px !import
color: #8fa1b5;
font-size: 12px;
}
.hcp-header-link {
min-width: 0;
max-width: 580px;
flex: 1;
display: grid;
gap: 6px;
color: #8fa1b5;
font-size: 12px;
}
.hcp-link-control {
min-width: 0;
display: flex;
align-items: center;
gap: 8px;
}
.hcp-link-control input {
min-width: 0;
width: 100%;
flex: 1;
height: 36px;
padding: 0 11px;
border: 1px solid #30445d;
border-radius: 8px;
background: #0b1523;
color: #edf4fc;
font: inherit;
}
.hcp-link-control input:focus {
outline: 2px solid #4d9cff;
outline-offset: 1px;
}
.hcp-link-open {
flex: 0 0 auto;
display: inline-flex;
align-items: center;
justify-content: center;
height: 36px;
padding: 0 12px;
border: 1px solid #365b81;
border-radius: 8px;
background: #17324e;
color: #d7eaff;
font-weight: 700;
text-decoration: none;
white-space: nowrap;
}
.hcp-link-open:hover { background: #204565; }
.hcp-link-open.is-disabled {
opacity: .45;
cursor: default;
pointer-events: none;
}
.hcp-save-state {
flex: 0 0 auto;
min-width: 172px;