тест2
This commit is contained in:
@@ -1249,13 +1249,37 @@
|
||||
(function () {
|
||||
const matchId = window.MATCH_DATA?.matchId;
|
||||
const sessionToken = window.MATCH_DATA?.sessionToken;
|
||||
const teamLogos = window.MATCH_DATA?.teamLogos || {};
|
||||
|
||||
if (!matchId || !sessionToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
async function sendVmixPreviewInput(inputName) {
|
||||
if (!inputName) return;
|
||||
function formatCoachName(rawName) {
|
||||
const parts = String(rawName || "").trim().split(/\s+/).filter(Boolean);
|
||||
if (parts.length >= 2) {
|
||||
return `${parts[1]} ${parts[0]}`;
|
||||
}
|
||||
return String(rawName || "").trim();
|
||||
}
|
||||
|
||||
function formatPlayerName(rawName) {
|
||||
const parts = String(rawName || "").trim().split(/\s+/).filter(Boolean);
|
||||
if (parts.length >= 2) {
|
||||
return `${parts[1]} ${parts[0]}`;
|
||||
}
|
||||
return String(rawName || "").trim();
|
||||
}
|
||||
|
||||
async function sendNeutralPersonTitle(name, role, logoUrl) {
|
||||
const inputName = "ИГРОК - НЕЙТРАЛЬНЫЙ";
|
||||
|
||||
const commands = [
|
||||
`/api/?Function=SetText&Input=${encodeURIComponent(inputName)}&SelectedName=${encodeURIComponent("Тренер.Text")}&Value=${encodeURIComponent(name || "")}`,
|
||||
`/api/?Function=SetText&Input=${encodeURIComponent(inputName)}&SelectedName=${encodeURIComponent("Должность.Text")}&Value=${encodeURIComponent(role || "")}`,
|
||||
`/api/?Function=SetImage&Input=${encodeURIComponent(inputName)}&SelectedName=${encodeURIComponent("Лого.Source")}&Value=${encodeURIComponent(logoUrl || "")}`,
|
||||
`/api/?Function=PreviewInput&Input=${encodeURIComponent(inputName)}`
|
||||
];
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/vmix/publish-command", {
|
||||
@@ -1269,30 +1293,42 @@
|
||||
body: JSON.stringify({
|
||||
match_id: matchId,
|
||||
session_token: sessionToken,
|
||||
commands: [
|
||||
`/api/?Function=PreviewInput&Input=${encodeURIComponent(inputName)}`
|
||||
],
|
||||
commands,
|
||||
meta: {
|
||||
source: "tab_click",
|
||||
input_name: inputName
|
||||
source: "person_click",
|
||||
title_input: inputName,
|
||||
person_name: name,
|
||||
person_role: role,
|
||||
logo_url: logoUrl
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error("Ошибка отправки команды в vMix:", response.status);
|
||||
console.error("Ошибка отправки титра в vMix:", response.status);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Не удалось отправить команду в vMix:", error);
|
||||
console.error("Не удалось отправить титр в vMix:", error);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("click", function (event) {
|
||||
const link = event.target.closest(".tab-link[data-vmix-title]");
|
||||
if (!link) return;
|
||||
const trigger = event.target.closest(".vmix-person-trigger");
|
||||
if (!trigger) return;
|
||||
|
||||
const inputName = link.dataset.vmixTitle;
|
||||
sendVmixPreviewInput(inputName);
|
||||
const personType = (trigger.dataset.vmixPersonType || "").trim();
|
||||
const side = (trigger.dataset.side || "").trim();
|
||||
const rawName = (trigger.dataset.name || "").trim();
|
||||
const role = (trigger.dataset.role || "").trim();
|
||||
const logoUrl = side === "away" ? teamLogos.away : teamLogos.home;
|
||||
|
||||
if (!rawName) return;
|
||||
|
||||
const formattedName = personType === "coach"
|
||||
? formatCoachName(rawName)
|
||||
: formatPlayerName(rawName);
|
||||
|
||||
sendNeutralPersonTitle(formattedName, role, logoUrl);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user