diff --git a/dashboard/app.js b/dashboard/app.js index 485f4ae9..71ff6c29 100644 --- a/dashboard/app.js +++ b/dashboard/app.js @@ -781,6 +781,45 @@ function dataBranchUrl(i) { return `https://github.com/nullhack/src-disaster-awareness/tree/data/incidents/${treeId}`; } +function _logEntryHtml(log) { + return ` +
  • +
    + + + + ${log.news.length} article(s) + +
    ${esc(log.summary)}
    +
    + ${log.news.length ? `` : `

    No linked news.

    `} +
    +
  • `; +} + +function _timelineHtml(logs, logsTotal) { + if (!logs || !logs.length) return ""; + const total = logsTotal || logs.length; + const trimmed = total > logs.length; + const reversed = logs.slice().reverse(); + let entries; + if (trimmed && reversed.length > 1) { + const recent = reversed.slice(0, -1); + const genesis = reversed[reversed.length - 1]; + entries = recent.map(_logEntryHtml).join("") + + `
  • ` + + _logEntryHtml(genesis); + } else { + entries = reversed.map(_logEntryHtml).join(""); + } + const header = trimmed + ? `Timeline · ${logs.length} of ${total} log(s)` + : `Timeline · ${logs.length} log(s)`; + return `

    ${header}

    `; +} + function openDrawer(id) { const i = STATE.digest.incidents.find((x) => x.incident_id === id); if (!i) return; $("#drawerTitle").textContent = i.canonical_name; @@ -841,22 +880,7 @@ function openDrawer(id) { const i = STATE.digest.incidents.find((x) => x.incide ${L.url ? `` : ``}`).join("")} ` : `

    No deep links available for this incident.

    `} - ${(i.logs && i.logs.length) ? `

    Timeline · ${i.logs.length} log(s)

    -
    ` : ""} + ${_timelineHtml(i.logs, i.logs_total)} ${(i.news && i.news.length && !(i.logs && i.logs.length)) ? `

    News · ${i.news_total} linked (${i.news.length} shown)