изменение текущего времени, тест 1
This commit is contained in:
@@ -3762,3 +3762,48 @@ function buildChannelValue(matchId) {
|
|||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setClockSeconds(newSeconds) {
|
||||||
|
const wasRunning = !!timerId;
|
||||||
|
|
||||||
|
if (timerId) {
|
||||||
|
clearInterval(timerId);
|
||||||
|
timerId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pausedAccumulatedSeconds = Math.max(0, Number(newSeconds) || 0);
|
||||||
|
matchClockSeconds = pausedAccumulatedSeconds;
|
||||||
|
|
||||||
|
if (wasRunning) {
|
||||||
|
periodStartedAt = Date.now();
|
||||||
|
timerId = setInterval(() => {
|
||||||
|
updateTimerUI();
|
||||||
|
saveMatchState();
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
periodStartedAt = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTimerUI();
|
||||||
|
saveMatchState();
|
||||||
|
syncClockToVmix(matchClockSeconds, wasRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function syncClockToVmix(seconds, shouldRun) {
|
||||||
|
const h = String(Math.floor(seconds / 3600)).padStart(2, "0");
|
||||||
|
const m = String(Math.floor((seconds % 3600) / 60)).padStart(2, "0");
|
||||||
|
const s = String(seconds % 60).padStart(2, "0");
|
||||||
|
const value = `${h}:${m}:${s}`;
|
||||||
|
|
||||||
|
const commands = [
|
||||||
|
vmixCmd("Function=SetCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text&Value=02:00:00"),
|
||||||
|
vmixCmd(`Function=ChangeCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text&Value=${value}`),
|
||||||
|
vmixCmd(
|
||||||
|
shouldRun
|
||||||
|
? "Function=StartCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text"
|
||||||
|
: "Function=PauseCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text"
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
await sendDirectVmixCommands(commands);
|
||||||
|
}
|
||||||
@@ -289,7 +289,7 @@
|
|||||||
<span class="period-badge" id="periodBadge"
|
<span class="period-badge" id="periodBadge"
|
||||||
>Матч не начат</span
|
>Матч не начат</span
|
||||||
>
|
>
|
||||||
<div class="timer-box" id="matchTimer">00:00</div>
|
<div class="timer-box" id="matchTimer" onclick="openClockEditor()">00:00</div>
|
||||||
<div class="score-box" id="matchScore">0 : 0</div>
|
<div class="score-box" id="matchScore">0 : 0</div>
|
||||||
|
|
||||||
<div class="extra-time-wrap">
|
<div class="extra-time-wrap">
|
||||||
|
|||||||
Reference in New Issue
Block a user