Files
f1-circuits/examples/grand-prix.html
T
jschoubben 49a2ebcf15 Add the photo picker, poster builder and licences pages
A pick is a repository edit, so the picker shows the Commons candidates cropped to the poster's
frame, natural or bw as the service treats them, beside the picks of the circuit's other
layouts, and gives the entry to copy (the picks file's "$comment" kept first). The builder sends
every option of docs/posters.md as a query parameter, renders only on request and shows the
answer's X-Credits and X-License. The licences page shows /licences: each source, its credit and
the licence a picture made from it gets.

Every page now carries the Formula 1 disclaimer at its foot, as F1's guidelines ask of an
unofficial site, and the posters page lists the backgrounds the design keeps (no Esri).

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 15:04:38 +01:00

116 lines
5.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grand prix lookup · F1 Circuits API examples</title>
<meta name="description" content="Look up the track of any F1 race by its name and season: the API finds the circuit and the layout raced that year.">
<link rel="icon" href="data:,">
<link rel="stylesheet" href="site.css">
</head>
<body>
<header class="site">
<a class="brand" href="index.html">F1 <span>Circuits</span> API</a>
<nav aria-label="Examples">
<a href="index.html">Overview</a>
<a href="circuits.html">Circuit browser</a>
<a href="tracks.html">Track images</a>
<a href="map.html">GPS traces</a>
<a href="grand-prix.html" aria-current="page">Grand prix lookup</a>
<a href="posters.html">Posters</a>
<a href="builder.html">Poster builder</a>
<a href="kometa.html">Kometa</a>
<a href="library.html">Library</a>
<a href="picker.html">Photo picker</a>
<a href="licences.html">Licences</a>
</nav>
<div id="api-base"></div>
</header>
<main>
<h1>Grand prix lookup</h1>
<p class="lead">
Name a race and a season, and the API answers the track it was raced on: it reads that season’s schedule from
Jolpica, matches the race by its exact name, finds the circuit in its catalogue and picks the layout of that year.
</p>
<section class="card" id="races">
<h2>1. The season’s races</h2>
<p>
This page lists the races by calling Jolpica itself, from the browser (Jolpica allows any origin). If it cannot
be reached, type the name: the API needs it exactly as Jolpica’s <code>raceName</code>, such as
<code>British Grand Prix</code>.
</p>
<div class="controls" id="race-picker"></div>
<div class="request"></div>
<div class="status"></div>
</section>
<section class="card" id="lookup">
<h2>2. The race’s track</h2>
<p><code>/grand-prix/{race name}/{season}/{format}</code>, the race name percent-encoded (a space is <code>%20</code>).</p>
<div class="controls"><fieldset id="format"><legend>Format</legend></fieldset></div>
<div id="jolpica-says"></div>
<div class="request"></div>
<div class="status idle">Choose a race.</div>
<div class="result"></div>
</section>
<h2>When the lookup finds nothing</h2>
<p>
The API answers <code>404 {"detail": "Circuit not found"}</code> when the name is not in that season’s schedule,
when Jolpica cannot be reached from the server, or when the circuit or that year’s layout is not in the catalogue
yet (browse it in the <a href="circuits.html">circuit browser</a>).
</p>
</main>
<footer class="pager">
<a rel="prev" href="map.html">← GPS traces</a>
<a class="home" href="index.html">All examples</a>
<a rel="next" href="posters.html">Posters →</a>
</footer>
<footer class="disclaimer">
<p>This website is unofficial and is not associated in any way with the Formula 1 companies. F1, FORMULA ONE,
FORMULA 1, FIA FORMULA ONE WORLD CHAMPIONSHIP, GRAND PRIX and related marks are trade marks of Formula One
Licensing B.V.</p>
<p><a href="licences.html">Licences and credits</a>: every source the pictures are made from, the licence each
picture takes from its sources, and the licence of the track files and the GPS traces (MIT).</p>
</footer>
<script src="site.js"></script>
<script>
(function () {
const { h, api, path, call, showImage, showGeoJSON, racePicker } = F1;
const $ = (id) => document.getElementById(id);
const card = $('lookup');
const FORMATS = ['svg', 'png', 'geojson'];
const initial = FORMATS.includes(F1.params.get('format')) ? F1.params.get('format') : 'svg';
for (const f of FORMATS) {
const input = h('input', { type: 'radio', name: 'format', value: f, checked: f === initial });
input.addEventListener('change', lookup);
$('format').append(h('label', { class: 'inline' }, input, f));
}
let chosen = null;
async function lookup() {
if (!chosen || !chosen.name || !(chosen.season >= 1950)) return;
const f = $('format').querySelector('input:checked').value;
const r = chosen.race;
$('jolpica-says').replaceChildren(r
? h('p', {}, `Jolpica: round ${r.round} on ${r.date}, at ${r.Circuit.circuitName} in ${r.Circuit.Location.locality}, ${r.Circuit.Location.country}.`)
: h('p', {}, 'Jolpica’s entry for this name is not known on this page; the API looks it up itself.'));
const answer = await call(card, api(path`/grand-prix/${chosen.name}/${chosen.season}/${f}`), { waiting: 'Looking up the race…' });
const out = card.querySelector('.result');
if (!answer) { out.replaceChildren(); return; }
const status = card.querySelector('.status');
if (f === 'geojson') await showGeoJSON(out, answer, { status });
else await showImage(out, answer, f, { alt: `${chosen.name} ${chosen.season}`, status });
}
racePicker($('race-picker'), { card: $('races'), onChange: (c) => { chosen = c; lookup(); } });
})();
</script>
</body>
</html>