Rimuovi replay da app, fix live web e sync punteggi broadcast.
La pagina live mostra solo l'overlay nel video (niente tabellone HTML); l'app nativa non espone più l'archivio replay, il toggle regole punteggio parte spento e i controlli in diretta seguono il punteggio dalla regia. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -61,57 +61,8 @@ module Public
|
||||
"#{match.team.name} #{score_state.home_points} - #{score_state.away_points} #{match.opponent_name}"
|
||||
end
|
||||
|
||||
def live_scorebug_columns(score_state)
|
||||
unless score_state
|
||||
return {
|
||||
labels: ["1"],
|
||||
home: ["0"],
|
||||
away: ["0"],
|
||||
live_index: 0
|
||||
}
|
||||
end
|
||||
|
||||
partials = Array(score_state.set_partials)
|
||||
labels = partials.map { |p| (p["set"] || p[:set]).to_s }
|
||||
home = partials.map { |p| (p["home"] || p[:home]).to_s }
|
||||
away = partials.map { |p| (p["away"] || p[:away]).to_s }
|
||||
labels << score_state.current_set.to_s
|
||||
home << score_state.home_points.to_s
|
||||
away << score_state.away_points.to_s
|
||||
{
|
||||
labels: labels,
|
||||
home: home,
|
||||
away: away,
|
||||
live_index: labels.length - 1
|
||||
}
|
||||
end
|
||||
|
||||
def live_scorebug_team_label(name, max: 16)
|
||||
n = name.to_s
|
||||
n.length <= max ? n : "#{n[0, max - 1]}…"
|
||||
end
|
||||
|
||||
# Colore ospite sul tabellone: secondario società se leggibile su bianco, altrimenti blu visitatore.
|
||||
def live_scorebug_away_color(team)
|
||||
club = team.club
|
||||
candidate = club&.effective_secondary_color.presence || "#1565c0"
|
||||
return candidate unless light_hex_color?(candidate)
|
||||
|
||||
"#1565c0"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def light_hex_color?(hex)
|
||||
h = hex.to_s.delete_prefix("#")
|
||||
return false unless h.match?(/\A\h{6}\z/i)
|
||||
|
||||
r = h[0..1].to_i(16)
|
||||
g = h[2..3].to_i(16)
|
||||
b = h[4..5].to_i(16)
|
||||
(0.299 * r + 0.587 * g + 0.114 * b) > 200
|
||||
end
|
||||
|
||||
def format_set_partial_entry(partial)
|
||||
data = partial.respond_to?(:with_indifferent_access) ? partial.with_indifferent_access : partial
|
||||
set_no = data[:set] || data["set"]
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<%= render "shared/meta_tags" %>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer">
|
||||
<link rel="stylesheet" href="/marketing.css?v=36">
|
||||
<link rel="stylesheet" href="/live.css?v=23">
|
||||
<link rel="stylesheet" href="/live.css?v=24">
|
||||
<%= yield :head %>
|
||||
</head>
|
||||
<body<% if MatchLiveTv.google_analytics_configured? %> data-ga-id="<%= MatchLiveTv.google_analytics_measurement_id %>"<% end %>>
|
||||
|
||||
6
backend/app/views/public/live/_player_overlays.html.erb
Normal file
6
backend/app/views/public/live/_player_overlays.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="live-player-overlays" id="live-overlays">
|
||||
<span
|
||||
id="live-stream-badge"
|
||||
class="live-ovl-badge live-ovl-badge--right <%= @stream_closed ? "badge-ended" : (@session.paused? ? "badge-wait" : (@on_air ? "badge-live" : "badge-wait")) %>"
|
||||
><%= @stream_closed ? "Terminata" : (@session.paused? ? "In pausa" : (@on_air ? "LIVE" : "In attesa")) %></span>
|
||||
</div>
|
||||
@@ -1,47 +0,0 @@
|
||||
<% score = @session.score_state %>
|
||||
<% team = @match.team %>
|
||||
<% cols = live_scorebug_columns(score) %>
|
||||
<% home_color = team.effective_primary_color %>
|
||||
<% away_color = live_scorebug_away_color(team) %>
|
||||
<div class="live-player-overlays" id="live-overlays">
|
||||
<div
|
||||
id="live-scorebug"
|
||||
class="live-scorebug"
|
||||
style="--sb-home-primary: <%= home_color %>; --sb-away-primary: <%= away_color %>;"
|
||||
data-home-name="<%= j live_scorebug_team_label(team.name) %>"
|
||||
data-away-name="<%= j live_scorebug_team_label(@match.opponent_name) %>"
|
||||
>
|
||||
<table class="live-scorebug__table" aria-label="Tabellone">
|
||||
<caption class="visually-hidden">Punteggio live</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="live-scorebug__corner" scope="col">Squadra</th>
|
||||
<% cols[:labels].each do |label| %>
|
||||
<th class="live-scorebug__col-set live-scorebug__col-h" scope="col"><%= label %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="live-scorebug__row--home">
|
||||
<th class="live-scorebug__team" scope="row"><%= live_scorebug_team_label(team.name) %></th>
|
||||
<% cols[:home].each_with_index do |val, i| %>
|
||||
<td class="live-scorebug__pts<%= " live-scorebug__pts--live-home" if i == cols[:live_index] %>"><%= val %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr class="live-scorebug__row--away">
|
||||
<th class="live-scorebug__team" scope="row"><%= live_scorebug_team_label(@match.opponent_name) %></th>
|
||||
<% cols[:away].each_with_index do |val, i| %>
|
||||
<td class="live-scorebug__pts<%= " live-scorebug__pts--live-away" if i == cols[:live_index] %>"><%= val %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="live-scorebug__brand" aria-hidden="true">
|
||||
<span class="live-scorebug__brand-text">MATCH <span class="live-scorebug__brand-accent">LIVE TV</span></span>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
id="live-stream-badge"
|
||||
class="live-ovl-badge live-ovl-badge--right <%= @stream_closed ? "badge-ended" : (@session.paused? ? "badge-wait" : (@on_air ? "badge-live" : "badge-wait")) %>"
|
||||
><%= @stream_closed ? "Terminata" : (@session.paused? ? "In pausa" : (@on_air ? "LIVE" : "In attesa")) %></span>
|
||||
</div>
|
||||
@@ -22,7 +22,7 @@
|
||||
<% if @session.ended_at %>
|
||||
<p class="stream-ended-meta">Chiusa il <%= l_local(@session.ended_at) %></p>
|
||||
<% end %>
|
||||
<p class="stream-ended-hint">Il punteggio finale resta visibile sopra.</p>
|
||||
<p class="stream-ended-hint">Il punteggio è visibile nel video se la diretta era ancora in corso.</p>
|
||||
<%= link_to "Tutte le dirette", public_live_index_path, class: "btn btn-secondary stream-ended-btn" %>
|
||||
</div>
|
||||
<% elsif @session.platform == "youtube" %>
|
||||
@@ -41,7 +41,7 @@
|
||||
<% else %>
|
||||
<div class="live-player-wrap">
|
||||
<video id="player" controls playsinline muted autoplay poster="/images/copertina-canale.png"></video>
|
||||
<%= render "public/live/scorebug", match: @match, session: @session %>
|
||||
<%= render "public/live/player_overlays", match: @match, session: @session %>
|
||||
<button type="button" id="play-hint" class="live-play-hint" hidden>
|
||||
▶ Avvia la diretta
|
||||
</button>
|
||||
@@ -58,68 +58,7 @@
|
||||
const pausedMsg = document.getElementById("paused-msg");
|
||||
const awaitingMsg = document.getElementById("awaiting-msg");
|
||||
const playHint = document.getElementById("play-hint");
|
||||
const scorebug = document.getElementById("live-scorebug");
|
||||
const streamBadge = document.getElementById("live-stream-badge");
|
||||
const homeName = "<%= j @match.team.name %>";
|
||||
const awayName = "<%= j @match.opponent_name %>";
|
||||
|
||||
function abbrevName(name, max = 16) {
|
||||
const n = String(name || "");
|
||||
return n.length <= max ? n : `${n.slice(0, max - 1)}…`;
|
||||
}
|
||||
|
||||
function scoreColumnsFromPayload(score) {
|
||||
if (!score) return { labels: ["1"], home: ["0"], away: ["0"], liveIndex: 0 };
|
||||
const partials = score.set_partials || score.setPartials || [];
|
||||
const labels = partials.map((p) => String(p.set ?? p["set"] ?? ""));
|
||||
const home = partials.map((p) => String(p.home ?? p["home"] ?? "0"));
|
||||
const away = partials.map((p) => String(p.away ?? p["away"] ?? "0"));
|
||||
const currentSet = score.current_set ?? score.currentSet ?? 1;
|
||||
labels.push(String(currentSet));
|
||||
home.push(String(score.home_points ?? score.homePoints ?? 0));
|
||||
away.push(String(score.away_points ?? score.awayPoints ?? 0));
|
||||
return { labels, home, away, liveIndex: labels.length - 1 };
|
||||
}
|
||||
|
||||
function renderLiveScorebug(score) {
|
||||
if (!scorebug) return;
|
||||
const cols = scoreColumnsFromPayload(score);
|
||||
const homeLabel = abbrevName(scorebug.dataset.homeName || homeName);
|
||||
const awayLabel = abbrevName(scorebug.dataset.awayName || awayName);
|
||||
const headCells = cols.labels
|
||||
.map((label) => `<th class="live-scorebug__col-set live-scorebug__col-h" scope="col">${label}</th>`)
|
||||
.join("");
|
||||
const homeCells = cols.home
|
||||
.map((val, i) => {
|
||||
const live = i === cols.liveIndex ? " live-scorebug__pts--live-home" : "";
|
||||
return `<td class="live-scorebug__pts${live}">${val}</td>`;
|
||||
})
|
||||
.join("");
|
||||
const awayCells = cols.away
|
||||
.map((val, i) => {
|
||||
const live = i === cols.liveIndex ? " live-scorebug__pts--live-away" : "";
|
||||
return `<td class="live-scorebug__pts${live}">${val}</td>`;
|
||||
})
|
||||
.join("");
|
||||
scorebug.innerHTML = `
|
||||
<table class="live-scorebug__table" aria-label="Tabellone">
|
||||
<caption class="visually-hidden">Punteggio live</caption>
|
||||
<thead><tr>
|
||||
<th class="live-scorebug__corner" scope="col">Squadra</th>${headCells}
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="live-scorebug__row--home">
|
||||
<th class="live-scorebug__team" scope="row">${homeLabel}</th>${homeCells}
|
||||
</tr>
|
||||
<tr class="live-scorebug__row--away">
|
||||
<th class="live-scorebug__team" scope="row">${awayLabel}</th>${awayCells}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="live-scorebug__brand" aria-hidden="true">
|
||||
<span class="live-scorebug__brand-text">MATCH <span class="live-scorebug__brand-accent">LIVE TV</span></span>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function syncStreamBadge(data) {
|
||||
if (!streamBadge) return;
|
||||
@@ -329,7 +268,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
renderLiveScorebug(data.score);
|
||||
syncStreamBadge(data);
|
||||
|
||||
const onAir = !!data.on_air;
|
||||
|
||||
Reference in New Issue
Block a user