Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 0 additions & 81 deletions web/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,87 +326,6 @@ function detach() {
$('connect').hidden = view !== 'live';
$('live').hidden = true;
renderConnection('disconnected');
showKnownRower();
setupGauge($('spm-gauge'));
$('app-version').textContent = APP_VERSION;

// ---------- full screen (on Android it also rotates to landscape) ----------

$('btn-fullscreen').hidden = !document.fullscreenEnabled;

async function enterFullscreen() {
try {
await document.documentElement.requestFullscreen({ navigationUI: 'hide' });
} catch (e) {
showNotice(`Full screen isn't available here: ${e.message}`);
return;
}
try {
// Android Chrome honours this even when the phone's rotation is locked to portrait.
// Desktop browsers refuse it, and full screen alone is fine there.
await screen.orientation?.lock?.('landscape');
} catch {
// orientation lock unsupported
}
}

function exitFullscreen() {
if (document.fullscreenElement) document.exitFullscreen().catch(() => {});
}

document.addEventListener('fullscreenchange', () => {
const on = !!document.fullscreenElement;
document.body.classList.toggle('immersive', on);
$('fs-exit').hidden = !on;
requestAnimationFrame(() => fitValues(true));
if (!on) {
try {
screen.orientation?.unlock?.();
} catch {
// nothing locked
}
}
});
$('btn-fullscreen').addEventListener('click', enterFullscreen);
window.addEventListener('resize', () => fitValues(true));
$('fs-exit').addEventListener('click', exitFullscreen);

// PWA (install + offline) is postponed until development is done; see PLAN.md "Later: PWA".
// A development build briefly registered a service worker; remove it so it can't serve stale files.
navigator.serviceWorker?.getRegistrations().then((regs) => regs.forEach((r) => r.unregister())).catch(() => {});
globalThis.caches?.keys().then((keys) => keys.filter((k) => k.startsWith('rower-')).forEach((k) => caches.delete(k))).catch(() => {});

navigator.bluetooth?.addEventListener?.('availabilitychanged', (e) => {
if (!e.value) showNotice('Bluetooth is turned off. Turn it on to connect to the rower.');
});

// two-step erase, no confirm() dialog
let eraseArmedUntil = 0;
$('btn-erase').addEventListener('click', async (e) => {
const btn = e.currentTarget;
if (performance.now() > eraseArmedUntil) {
eraseArmedUntil = performance.now() + 4000;
btn.textContent = 'Tap again to erase everything';
setTimeout(() => { if (performance.now() > eraseArmedUntil) btn.textContent = 'Erase all data'; }, 4100);
return;
}
await eraseAllData();
location.reload();
});

finalizeInterrupted().catch((e) => console.warn('Could not tidy interrupted sessions:', e.message));
try {
$('save-non-ble').checked = localStorage.getItem('rower.saveNonBle') === '1';
} catch {
// storage unavailable: default off
}
$('save-non-ble').addEventListener('change', (e) => {
try {
localStorage.setItem('rower.saveNonBle', e.target.checked ? '1' : '0');
} catch {
// not fatal
}
});
updateWakeLock();
}

Expand Down
Loading