aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / public / js / alpha.js
| 1 | /* Generated by om/alpha-page/client.om. Do not edit. */ |
| 2 | (() => { |
| 3 | 'use strict'; |
| 4 | const command = document.getElementById('alpha-command'); |
| 5 | const copy = document.getElementById('alpha-copy'); |
| 6 | const status = document.getElementById('alpha-copy-status'); |
| 7 | if (!command || !copy || !status) return; |
| 8 | copy.addEventListener('click', async () => { |
| 9 | try { |
| 10 | await navigator.clipboard.writeText(command.textContent); |
| 11 | status.textContent = 'Copied. Read the script before running it.'; |
| 12 | } catch (_) { |
| 13 | const selection = window.getSelection(); |
| 14 | const range = document.createRange(); |
| 15 | range.selectNodeContents(command); |
| 16 | selection.removeAllRanges(); |
| 17 | selection.addRange(range); |
| 18 | status.textContent = 'Clipboard unavailable. The command is selected; copy it manually.'; |
| 19 | } |
| 20 | }); |
| 21 | const button = document.getElementById('alpha-motion'); |
| 22 | const scene = document.querySelector('.alpha-scene'); |
| 23 | const reduced = matchMedia('(prefers-reduced-motion: reduce)'); |
| 24 | let running = false; |
| 25 | const sync = () => { |
| 26 | const play = running && !reduced.matches && !document.hidden; |
| 27 | scene.dataset.motion = play ? 'on' : 'off'; |
| 28 | button.setAttribute('aria-pressed', String(running && !reduced.matches)); |
| 29 | button.textContent = reduced.matches ? 'Motion off: reduced motion preference' : running ? 'Pause the event horizon' : 'Play the event horizon'; |
| 30 | button.disabled = reduced.matches; |
| 31 | }; |
| 32 | button.addEventListener('click', () => { running = !running; sync(); }); |
| 33 | reduced.addEventListener('change', () => { if (reduced.matches) running = false; sync(); }); |
| 34 | document.addEventListener('visibilitychange', sync); |
| 35 | sync(); |
| 36 | })(); |