Retain live ticker controls during independent detail navigation (by Codex)
This commit is contained in:
1 parent
d3ea650c07
commit
1fb6499b15
5 files changed
+116
-18
No files matched your search
@@ -136,6 +136,24 @@ std::string App::live_dialog_markup(const Json &owner) {
|
||||
btn("live-dialog-apply", "Demovorschau anzeigen", "", "id=\"live-dialog-apply\" " + std::string(live_dialog_ == "lineup" && (live_out_.empty() || live_in_.empty()) ? "disabled" : "")) + "</div>";
|
||||
return "<div class=\"live-dialog-layer\"><div id=\"live-dialog\" class=\"live-dialog\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"live-dialog-heading\">" + body + "</div></div>";
|
||||
}
|
||||
std::string App::live_ticker_events(const Json &frame, size_t &shown) {
|
||||
const auto &fixture = live_.fixture();
|
||||
shown = 0;
|
||||
std::string out;
|
||||
for (auto i = frame.at("events").rbegin(); i != frame.at("events").rend(); ++i) {
|
||||
const auto &event = *i; const auto kind = event.value("kind", "");
|
||||
if (live_coverage_ == "single" && event.at("match_id") != live_selected_match_) continue;
|
||||
if (live_filter_ == "goal" && kind != "goal") continue;
|
||||
if (live_filter_ == "yellow" && kind != "yellow" && kind != "red") continue;
|
||||
if (live_filter_ == "highlights" && kind != "goal" && kind != "chance" && kind != "red") continue;
|
||||
const auto &match = live_match_by_id(fixture.at("matches"), event.at("match_id"));
|
||||
out += "<article class=\"live-event " + std::string(kind == "goal" ? "is-goal" : "") + "\" data-live-event=\"" + esc(event.at("id").get<std::string>()) + "\">" + live_text(std::to_string(event.at("minute").get<int>()) + "′", "live-event-time") + live_badge(match.at(event.at("side").get<std::string>()), 54) +
|
||||
"<div class=\"live-event-copy\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>(), "live-event-owners") + "<h3>" + live_text(event.at("headline")) + "</h3><p>" + live_text(event.at("body")) + "</p></div>" + live_text(live_score_text(event.at("score")), "live-event-score") + "</article>";
|
||||
++shown;
|
||||
}
|
||||
if (!shown) out += "<p class=\"live-note\">" + live_text("Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
|
||||
return out;
|
||||
}
|
||||
std::string App::render_live() {
|
||||
if(live_review_) return render_postmatch();
|
||||
if (!live_.available()) return "";
|
||||
@@ -168,19 +186,8 @@ std::string App::render_live() {
|
||||
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 4>{{{"all", "Alles"}, {"highlights", "Highlights"}, {"goal", "Tore"}, {"yellow", "Karten"}}}) out += btn("live-filter", label, live_filter_ == id ? "selected" : "", "id=\"live-filter-" + std::string(id) + "\" data-id=\"" + id + "\"");
|
||||
out += "</nav><div id=\"live-ticker\" class=\"live-event-list\" tabindex=\"0\" aria-label=\"Gemeinsamer Ereignisverlauf\">";
|
||||
size_t shown = 0;
|
||||
for (auto i = frame.at("events").rbegin(); i != frame.at("events").rend(); ++i) {
|
||||
const auto &event = *i; const auto kind = event.value("kind", "");
|
||||
if (live_coverage_ == "single" && event.at("match_id") != live_selected_match_) continue;
|
||||
if (live_filter_ == "goal" && kind != "goal") continue;
|
||||
if (live_filter_ == "yellow" && kind != "yellow" && kind != "red") continue;
|
||||
if (live_filter_ == "highlights" && kind != "goal" && kind != "chance" && kind != "red") continue;
|
||||
const auto &match = live_match_by_id(fixture.at("matches"), event.at("match_id"));
|
||||
out += "<article class=\"live-event " + std::string(kind == "goal" ? "is-goal" : "") + "\" data-live-event=\"" + esc(event.at("id").get<std::string>()) + "\">" + live_text(std::to_string(event.at("minute").get<int>()) + "′", "live-event-time") + live_badge(match.at(event.at("side").get<std::string>()), 54) +
|
||||
"<div class=\"live-event-copy\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>(), "live-event-owners") + "<h3>" + live_text(event.at("headline")) + "</h3><p>" + live_text(event.at("body")) + "</p></div>" + live_text(live_score_text(event.at("score")), "live-event-score") + "</article>";
|
||||
++shown;
|
||||
}
|
||||
if (!shown) out += "<p class=\"live-note\">" + live_text("Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
|
||||
out += "</div><footer class=\"live-ticker-footer\">" + live_text(std::to_string(shown) + " Meldungen · feste Aufzeichnung", "live-small") + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + live_text(owner.at("team").at("name")) + "</h2><p>" + live_text(owner.at("name")) + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
|
||||
out += live_ticker_events(frame, shown);
|
||||
out += "</div><footer class=\"live-ticker-footer\">" "<span id=\"live-event-count\" class=\"live-small\">" + esc(std::to_string(shown) + " Meldungen · feste Aufzeichnung") + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + "<span id=\"live-owner-team\">" + esc(owner.at("team").at("name").get<std::string>()) + "</span></h2><p><span id=\"live-owner-name\">" + esc(owner.at("name").get<std::string>()) + "</span>" + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
|
||||
btn("live-owner-prev", arrow(false), "", "id=\"live-owner-prev\" aria-label=\"Vorheriger Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + btn("live-owner-next", arrow(true), "", "id=\"live-owner-next\" aria-label=\"Nächster Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + "</nav></header><nav class=\"live-tabs\">";
|
||||
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 5>{{{"team", "Team"}, {"tactics", "Taktik"}, {"opponent", "Gegner"}, {"table", "Live-Tabelle"}, {"stats", "Statistik"}}}) out += btn("live-tab", label, live_tab_ == id ? "selected" : "", "id=\"live-tab-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (live_tab_ == id ? "true" : "false") + "\"");
|
||||
out += "</nav><div id=\"live-detail-body\" class=\"live-detail-body\" tabindex=\"0\">" + live_detail(owner, frame) + "</div><footer class=\"live-detail-footer\">" + btn("live-intervene-lineup", "Aufstellung & Wechsel", "", "id=\"live-lineup-edit\" " + std::string(live_.finished() ? "disabled" : "")) + "</footer></aside></div>";
|
||||
@@ -200,3 +207,49 @@ void App::live_after_render() {
|
||||
for (auto *node : controls) { node->SetProperty("pointer-events", "none"); node->SetAttribute("tabindex", "-1"); }
|
||||
}
|
||||
}
|
||||
|
||||
// Apply local navigation only after event dispatch. The untouched match cards,
|
||||
// ticker and speed input retain their DOM identity, focus and pointer capture.
|
||||
void App::live_update_parts() {
|
||||
if (!live_detail_pending_ && !live_ticker_pending_ && focus_after_render_.empty()) return;
|
||||
if (scene_ != "live" || live_review_ || !live_.available() ||
|
||||
!live_dialog_.empty() || !popup_.empty()) {
|
||||
live_detail_pending_ = live_ticker_pending_ = false;
|
||||
return;
|
||||
}
|
||||
const auto frame = live_.frame();
|
||||
if (live_detail_pending_) {
|
||||
const auto owner = live_owner();
|
||||
auto *body = element("live-detail-body");
|
||||
auto *team = element("live-owner-team");
|
||||
auto *name = element("live-owner-name");
|
||||
if (!body || !team || !name) { refresh(); return; }
|
||||
team->SetInnerRML(esc(owner.at("team").at("name").get<std::string>()));
|
||||
name->SetInnerRML(esc(owner.at("name").get<std::string>()));
|
||||
body->SetInnerRML(live_detail(owner, frame));
|
||||
body->SetScrollTop(0); live_detail_scroll_ = 0; live_reset_detail_ = false;
|
||||
Rml::ElementList tabs; doc_->QuerySelectorAll(tabs, "#live-detail .live-tabs button");
|
||||
for (auto *tab : tabs) {
|
||||
const bool selected = tab->GetAttribute<Rml::String>("data-id", "") == live_tab_;
|
||||
tab->SetClass("selected", selected); tab->SetAttribute("aria-pressed", selected ? "true" : "false");
|
||||
}
|
||||
++live_detail_updates_;
|
||||
}
|
||||
if (live_ticker_pending_) {
|
||||
auto *list = element("live-ticker"); auto *count = element("live-event-count");
|
||||
if (!list || !count) { refresh(); return; }
|
||||
size_t shown = 0; list->SetInnerRML(live_ticker_events(frame, shown));
|
||||
count->SetInnerRML(esc(std::to_string(shown) + " Meldungen · feste Aufzeichnung"));
|
||||
list->SetScrollTop(0); live_ticker_scroll_ = 0; live_reset_ticker_ = false;
|
||||
Rml::ElementList filters; doc_->QuerySelectorAll(filters, ".live-filters button");
|
||||
for (auto *filter : filters)
|
||||
filter->SetClass("selected", filter->GetAttribute<Rml::String>("data-id", "") == live_filter_);
|
||||
++live_ticker_updates_;
|
||||
}
|
||||
live_detail_pending_ = live_ticker_pending_ = false;
|
||||
if (!focus_after_render_.empty()) {
|
||||
if (auto *node = element(focus_after_render_)) node->Focus(keyboard_navigation_);
|
||||
focus_after_render_.clear();
|
||||
}
|
||||
dirty_ = true;
|
||||
}
|
||||
Reference in new issue
Block a user