From 7f07f982d83dd270dad47e9ebd80dc60ac2a9171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE?= Date: Fri, 15 May 2026 12:58:19 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=20=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8?= =?UTF-8?q?=D1=8F.=20=D1=82=D0=B5=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/script.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++- static/styles.css | 13 ++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/static/script.js b/static/script.js index 8a40ac7..edd12d1 100644 --- a/static/script.js +++ b/static/script.js @@ -1353,7 +1353,17 @@ function renderEvents() { return `
${event.side === "home" ? cardHtml : ""}
-
${escapeHtml(event.minute)}
+
+ ${escapeHtml(event.minute)} + ${ + event.id !== null && event.id !== undefined && event.id !== "" + ? `` + : "" + } +
${event.side === "away" ? cardHtml : ""}
`; @@ -2454,6 +2464,76 @@ function getRowArcOffsets(count, arcStrength = 0, direction = "up") { }); } + +function parseEventTimeInput(value) { + const raw = String(value || "").trim().replace("’", "'"); + + // варианты: 12, 12', 45+2, 45'+2, 90+4 + const match = raw.match(/^(\d{1,3})'?(?:\+(\d{1,2}))?$/); + if (!match) return null; + + const baseMinute = Number(match[1]); + const extraMinute = Number(match[2] || 0); + + if (!Number.isFinite(baseMinute) || baseMinute < 1) return null; + + const totalMinute = baseMinute + extraMinute; + const seconds = Math.max(0, (totalMinute - 1) * 60); + + const label = extraMinute > 0 + ? `${baseMinute}'+${extraMinute}` + : `${baseMinute}'`; + + return { + label, + minute: totalMinute, + seconds + }; +} + +async function editEventTime(eventId) { + const event = matchEvents.find((e) => String(e.id) === String(eventId)); + if (!event) return; + + const value = prompt("Новое время события. Например: 23, 45+2, 90+4", event.minute || ""); + if (value === null) return; + + const parsed = parseEventTimeInput(value); + if (!parsed) { + alert("Неверный формат времени. Пример: 23 или 45+2"); + return; + } + + const updated = { + side: event.side, + type: event.type, + player_name: event.player_name || "", + minute: parsed.minute, + seconds: parsed.seconds, + meta: event.meta || "", + player_id: event.player_id ?? null, + player_out_id: event.player_out_id ?? null, + player_in_id: event.player_in_id ?? null + }; + + const ok = await updateEventOnServer(event.id, updated); + if (!ok) { + alert("Не удалось обновить время события"); + return; + } + + event.minute = parsed.label; + event.seconds = parsed.seconds; + + matchEvents = sortEventsForStorage(matchEvents); + + renderEvents(); + rebuildLineupsFromEvents(); + saveMatchState(); +} + + + function getRowTopLift(profile, count) { const arc = Number(profile?.arc || 0); const yOffset = Number(profile?.yOffset || 0); diff --git a/static/styles.css b/static/styles.css index 83f7349..22a4bc2 100644 --- a/static/styles.css +++ b/static/styles.css @@ -2293,3 +2293,16 @@ body:not(.edit-mode-on) .referee-search { border-radius: 6px; } +.event-time-edit-btn { + margin-left: 4px; + border: none; + background: transparent; + color: inherit; + cursor: pointer; + opacity: 0.55; + font-size: 11px; +} + +.event-time-edit-btn:hover { + opacity: 1; +} \ No newline at end of file