OXYGENHUB
# 0a3b244b748f oxygenhub / templates / backdrop.html
1.2 KiB · HTML · last changed feat(web): the hub's sky on Explore and the signed-out home (closes #165) 22 days ago source blame history raw
1
{# A backdrop (docs/backgrounds.md, #157): the page's `backdrop` data drawn
2
   by the engine, Rust compiled to WebAssembly. The viewer's choice (Settings › Appearance) is a cookie;
3
   unset, a touch-only device or Save-Data gets a still sky. Any failure
4
   leaves no backdrop and nothing else changed. #}
5
<canvas id="backdrop" aria-hidden="true"></canvas>
6
<script type="application/json" id="backdrop-data">{{ backdrop|safe }}</script>
7
<script type="module">
8
const canvas = document.getElementById("backdrop");
9
const chosen = document.cookie.match(/(?:^|; )backdrop=(moving|still|off)/);
10
const touch = matchMedia("(pointer: coarse)").matches && !matchMedia("(pointer: fine)").matches;
11
const pick = chosen ? chosen[1] : (touch || (navigator.connection && navigator.connection.saveData) ? "still" : "moving");
12
if (pick === "off") {
13
  canvas.remove();
14
} else {
15
  try {
16
    const bd = await import("/static/backdrop/backdrop.js?v={{ shell.assets() }}");
17
    await bd.default({ module_or_path: "/static/backdrop/backdrop_bg.wasm?v={{ shell.assets() }}" });
18
    bd.start(canvas, JSON.parse(document.getElementById("backdrop-data").textContent), pick === "still");
19
  } catch (e) {
20
    canvas.remove();
21
  }
22
}
23
</script>