2 Commits

Author SHA1 Message Date
36202e1a3a Merge pull request 'fix: show 'not available on mobile' message instead of broken layout' (#3) from fix/mobile-not-available into main
All checks were successful
check / check (push) Successful in 32s
Reviewed-on: #3
2026-02-27 11:07:11 +01:00
user
38bbd13c7f fix: show 'not available on mobile' message instead of broken layout
All checks were successful
check / check (push) Successful in 28s
Detect mobile devices via user agent and viewport width (<=768px).
On mobile, skip all checker initialization and render only the
header, description, and a styled 'Not yet available on mobile' box.

Desktop behavior is completely unchanged — the mobile check returns
early before any existing code runs.
2026-02-27 02:00:01 -08:00

View File

@@ -1128,25 +1128,39 @@ function handleResize(state) {
// --- Bootstrap --------------------------------------------------------------- // --- Bootstrap ---------------------------------------------------------------
async function init() { // --- Mobile Detection --------------------------------------------------------
log.info("NetWatch starting");
// Mobile detection — show a friendly message and bail out early function isMobile() {
if (window.innerWidth < 768) { // Check both user agent and viewport width for robust detection
const uaMatch =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
);
const narrowViewport = window.innerWidth <= 768;
return uaMatch || narrowViewport;
}
function buildMobileUI() {
const app = document.getElementById("app"); const app = document.getElementById("app");
app.innerHTML = ` app.innerHTML = `
<div class="mx-auto px-[5%] py-8"> <div class="mx-auto px-[5%] py-8">
<header class="mb-8"> <header class="mb-8">
<h1 class="text-3xl font-bold text-white"><a href="https://git.eeqj.de/sneak/netwatch" target="_blank" rel="noopener" class="underline decoration-dashed decoration-gray-500 underline-offset-4">NetWatch</a> by <a href="https://sneak.berlin" target="_blank" rel="noopener" class="text-blue-400 underline hover:text-blue-300">@sneak</a></h1> <h1 class="text-3xl font-bold text-white"><a href="https://git.eeqj.de/sneak/netwatch" target="_blank" rel="noopener" class="underline decoration-dashed decoration-gray-500 underline-offset-4">NetWatch</a> by <a href="https://sneak.berlin" target="_blank" rel="noopener" class="text-blue-400 underline hover:text-blue-300">@sneak</a></h1>
<p class="text-gray-400 mt-2">Real-time network connectivity monitor</p> <p class="text-gray-400 text-sm mt-2">Real-time network latency monitor</p>
</header> </header>
<div style="display:flex;align-items:center;justify-content:center;min-height:50vh;"> <div style="margin: 2rem auto; max-width: 500px; padding: 3rem 2rem; background: rgba(31, 41, 55, 0.7); border: 1px solid rgba(75, 85, 99, 0.5); border-radius: 1rem; text-align: center;">
<div style="background:#1f2937;border:1px solid #374151;border-radius:12px;padding:2rem 1.5rem;text-align:center;max-width:90vw;"> <p style="font-size: 1.5rem; font-weight: 600; color: #d1d5db;">Not yet available on mobile.</p>
<p style="font-size:1.25rem;color:#e5e7eb;margin:0;">Not yet available on mobile.</p> <p style="font-size: 0.875rem; color: #6b7280; margin-top: 1rem;">Please visit on a desktop browser for the full experience.</p>
</div>
</div> </div>
</div>`; </div>`;
log.info("Mobile viewport detected — skipping monitor startup"); }
async function init() {
log.info("NetWatch starting");
if (isMobile()) {
log.info("Mobile device detected — showing placeholder");
buildMobileUI();
return; return;
} }