Module:Countdown/doc: Difference between revisions
More actions
starcitizen>Alistar Bot Sync from Git (7721bcf) (via create-page on MediaWiki MCP Server) |
Bonsaibauer (talk | contribs) m 1 revision imported: Import Star Citizen Modules |
(No difference)
| |
Latest revision as of 22:22, 4 November 2026
- formatDateL26
- assertReadableL42
- fallbackTextL55
- p.renderL82
- p.mainL119
|type = website |description = Module:Countdown/doc is a template page used on the Star Citizen Wiki. Templates are pages that are embedded (transcluded) into other pages to allow for the repetition of information. |site_name = Star Citizen Wiki |locale = en-gb }}
A live countdown display, split by responsibility: the module renders the markup, the data attributes, and a no-JS fallback date; a mainpage gadget computes the actual remaining time and animates the digit stack client-side.
Required by Module:Mainpage/Event and Module:Mainpage/Event/Legacy; not invoked from templates.
For module editors
API
p.render(props) returns <templatestyles> + markup, or raises a Lua error when ends is missing or either date is not readable by the content language's date formatter (mw.language:formatDate); both current callers wrap the call in pcall.
| Field | Type | Description |
|---|---|---|
starts
|
ISO 8601 string | Optional. Omit for something already under way; with it the gadget can also render a "starts in" tense. |
ends
|
ISO 8601 string | Required. |
label
|
string
|
Overrides the gadget's tense-derived label. Rarely wanted; the point is that the label follows the dates. |
class
|
string
|
Extra class on the root. |
p.main(frame) is the #invoke entry point (reads starts/ends/label/class via Module:Arguments).
Gotchas
- The module deliberately does not compute remaining time: a value worked out at parse time freezes into the parser cache and can go arbitrarily stale. It emits the dates as
data-gadget-mainpage-countdown-start/-end(+-label) attributes for the gadget, and renders a no-JS fallback: the end date alone, or astarts – endsrange with the start year dropped when both dates share one. - An unreadable date is a hard Lua error, not a silent empty render, because a typo here has to be loud.
Styles
class = 't-countdown--flat' is the module's own modifier for lying the clock down into a horizontal strip regardless of viewport (it also does this automatically below 639px). The gadget replaces the fallback with a live digit stack, adding t-countdown--live and, for colour, one of --upcoming or --running; --ended carries no colour rule at all, deliberately falling back to the root's --color-subtle.