Files
uconsole_asw_game/data/commander/js/audio/alerts.js
T
db9979andClaude Opus 5.5 4dd23bc242 Web client: CIC redesign with ES modules and bundled fonts
- Remote Crew browser client rebuilt as a dark combat-information-centre layout
  for large desktop monitors: slim status bar (stations, mission, clocks, UTC,
  link state), pulsing alert band, the instrument as centrepiece and
  collapsible docks (contacts, station, contact detail, log drawer; keys , . L).
  Four columns from 2400 px, fluid type up to 4K; guide, lookout and contact
  library open as overlays (Esc closes).
- app.js split into native ES modules under data/commander/js; the transport
  (net/*) no longer touches the DOM and talks to the views through synchronous
  topics (core/events.js, app/bindings.js); redraws share one frame scheduler.
- style.css replaced by a token-based design system in data/commander/css.
- Inter 4.1 and JetBrains Mono 2.304 bundled unmodified (OFL-1.1) with
  provenance in THIRD_PARTY_NOTICES.md; CSP allows font-src 'self'.
- Server serves the css/js/fonts trees from one asset manifest
  (src/commander/assets.py); packaging, capture tool, help, manual and docs
  updated; tests share tests/commander_web.py and import modules directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 12:02:01 +02:00

29 lines
1.1 KiB
JavaScript

import { S } from "../state/store.js";
import { $ } from "../core/base.js";
import { t } from "../core/format.js";
export function renderSound() {
$("sound").textContent = t(S.soundEnabled ? "sound_on" : "sound_off");
$("sound").setAttribute("aria-pressed", String(S.soundEnabled));
}
export function playAlert() {
if (!S.soundEnabled || !S.audio || S.audio.state !== "running" || document.hidden) return;
const volume = Number($("volume").value) / 100;
if (!volume) return;
const oscillator = S.audio.createOscillator();
const gain = S.audio.createGain();
const now = S.audio.currentTime;
oscillator.type = "sine";
oscillator.frequency.setValueAtTime(660, now);
oscillator.frequency.setValueAtTime(880, now + .12);
gain.gain.setValueAtTime(0, now);
gain.gain.linearRampToValueAtTime(volume * .12, now + .015);
gain.gain.setValueAtTime(volume * .12, now + .18);
gain.gain.linearRampToValueAtTime(0, now + .26);
oscillator.connect(gain);
gain.connect(S.audio.destination);
oscillator.start(now);
oscillator.stop(now + .28);
oscillator.onended = () => { oscillator.disconnect(); gain.disconnect(); };
}