фикс 9
This commit is contained in:
@@ -1303,103 +1303,101 @@ data-role="{{ p.position or '' }}"
|
|||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
const matchId = window.MATCH_DATA?.matchId;
|
const matchId = window.MATCH_DATA?.matchId;
|
||||||
const sessionToken = window.MATCH_DATA?.sessionToken;
|
const sessionToken = window.MATCH_DATA?.sessionToken;
|
||||||
const teamLogos = window.MATCH_DATA?.teamLogos || {};
|
const teamLogos = window.MATCH_DATA?.teamLogos || {};
|
||||||
const vmixTeamLogos = window.MATCH_DATA?.vmixTeamLogos || {};
|
const vmixTeamLogos = window.MATCH_DATA?.vmixTeamLogos || {};
|
||||||
|
const currentUserLogin = window.MATCH_DATA?.currentUser?.username || null;
|
||||||
|
|
||||||
if (!matchId || !sessionToken) {
|
if (!matchId || !sessionToken) {
|
||||||
return;
|
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 formatCoachName(rawName) {
|
function formatPlayerName(firstName, lastName, fallbackName) {
|
||||||
const parts = String(rawName || "").trim().split(/\s+/).filter(Boolean);
|
const result = `${String(firstName || "").trim()} ${String(lastName || "").trim()}`.trim();
|
||||||
if (parts.length >= 2) {
|
return result || String(fallbackName || "").trim();
|
||||||
return `${parts[1]} ${parts[0]}`;
|
}
|
||||||
|
|
||||||
|
async function sendNeutralPersonTitle(name, role, side) {
|
||||||
|
const inputName = "ИГРОК - НЕЙТРАЛЬНЫЙ";
|
||||||
|
|
||||||
|
const teamName = TEAM_NAMES?.[side] || "";
|
||||||
|
const logoPath = getVmixTeamLogo(teamName);
|
||||||
|
|
||||||
|
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(logoPath || "")}`,
|
||||||
|
`/api/?Function=PreviewInput&Input=${encodeURIComponent(inputName)}`
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/vmix/publish-command", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Accept": "application/json",
|
||||||
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
credentials: "same-origin",
|
||||||
|
body: JSON.stringify({
|
||||||
|
match_id: matchId,
|
||||||
|
commands,
|
||||||
|
target_login: currentUserLogin,
|
||||||
|
meta: {
|
||||||
|
source: "person_click",
|
||||||
|
title_input: inputName,
|
||||||
|
person_name: name,
|
||||||
|
person_role: role,
|
||||||
|
side,
|
||||||
|
team_name: teamName,
|
||||||
|
logo_path: logoPath
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error("Ошибка отправки титра в vMix:", response.status);
|
||||||
}
|
}
|
||||||
return String(rawName || "").trim();
|
} catch (error) {
|
||||||
|
console.error("Не удалось отправить титр в vMix:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("click", function (event) {
|
||||||
|
const trigger = event.target.closest(".vmix-person-trigger");
|
||||||
|
if (!trigger) return;
|
||||||
|
|
||||||
|
const personType = String(trigger.dataset.vmixPersonType || "").trim();
|
||||||
|
const side = String(trigger.dataset.side || "").trim();
|
||||||
|
const rawName = String(trigger.dataset.name || "").trim();
|
||||||
|
const firstName = String(trigger.dataset.firstName || "").trim();
|
||||||
|
const lastName = String(trigger.dataset.lastName || "").trim();
|
||||||
|
const role = String(trigger.dataset.role || "").trim();
|
||||||
|
|
||||||
|
let formattedName = "";
|
||||||
|
|
||||||
|
if (personType === "coach") {
|
||||||
|
formattedName = formatCoachName(rawName);
|
||||||
|
} else {
|
||||||
|
formattedName = formatPlayerName(firstName, lastName, rawName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatPlayerName(firstName, lastName, fallbackName) {
|
if (!formattedName) return;
|
||||||
const result = `${String(firstName || "").trim()} ${String(lastName || "").trim()}`.trim();
|
|
||||||
return result || String(fallbackName || "").trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sendNeutralPersonTitle(name, role, side) {
|
sendNeutralPersonTitle(formattedName, role, side);
|
||||||
const inputName = "ИГРОК - НЕЙТРАЛЬНЫЙ";
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
const teamName = TEAM_NAMES?.[side] || "";
|
|
||||||
const logoPath = getVmixTeamLogo(teamName);
|
|
||||||
|
|
||||||
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(logoPath || "")}`,
|
|
||||||
`/api/?Function=PreviewInput&Input=${encodeURIComponent(inputName)}`
|
|
||||||
];
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch("/api/vmix/publish-command", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Accept": "application/json",
|
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
|
||||||
},
|
|
||||||
credentials: "same-origin",
|
|
||||||
body: JSON.stringify({
|
|
||||||
match_id: MATCH_ID,
|
|
||||||
commands,
|
|
||||||
target_login: CURRENT_USER_LOGIN,
|
|
||||||
meta: {
|
|
||||||
source: "person_click",
|
|
||||||
title_input: inputName,
|
|
||||||
person_name: name,
|
|
||||||
person_role: role,
|
|
||||||
side,
|
|
||||||
team_name: teamName,
|
|
||||||
logo_path: logoPath
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
console.error("Ошибка отправки титра в vMix:", response.status);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Не удалось отправить титр в vMix:", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("click", function (event) {
|
|
||||||
const trigger = event.target.closest(".vmix-person-trigger");
|
|
||||||
if (!trigger) return;
|
|
||||||
|
|
||||||
const personType = String(trigger.dataset.vmixPersonType || "").trim();
|
|
||||||
const side = String(trigger.dataset.side || "").trim();
|
|
||||||
const rawName = String(trigger.dataset.name || "").trim();
|
|
||||||
const firstName = String(trigger.dataset.firstName || "").trim();
|
|
||||||
const lastName = String(trigger.dataset.lastName || "").trim();
|
|
||||||
const role = String(trigger.dataset.role || "").trim();
|
|
||||||
const logoUrl = side === "away"
|
|
||||||
? (vmixTeamLogos.away || teamLogos.away)
|
|
||||||
: (vmixTeamLogos.home || teamLogos.home);
|
|
||||||
|
|
||||||
let formattedName = "";
|
|
||||||
|
|
||||||
if (personType === "coach") {
|
|
||||||
formattedName = formatCoachName(rawName);
|
|
||||||
} else {
|
|
||||||
formattedName = formatPlayerName(firstName, lastName, rawName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!formattedName) return;
|
|
||||||
|
|
||||||
sendNeutralPersonTitle(formattedName, role, side);
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user