Compare commits
1 Commits
main
...
0a633258a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a633258a8 |
41
src/main.js
41
src/main.js
@@ -551,9 +551,9 @@ function hostRowHTML(host, index, showPin = true) {
|
|||||||
: `<div class="flex-shrink-0 w-4 h-4"></div>`;
|
: `<div class="flex-shrink-0 w-4 h-4"></div>`;
|
||||||
return `
|
return `
|
||||||
<div class="host-row bg-gray-800/50 rounded-lg p-2 border border-gray-700/50" data-index="${index}">
|
<div class="host-row bg-gray-800/50 rounded-lg p-2 border border-gray-700/50" data-index="${index}">
|
||||||
<div class="flex items-center gap-4 min-w-0">
|
<div class="host-row-inner flex items-center gap-4 min-w-0">
|
||||||
${pinBtn}
|
${pinBtn}
|
||||||
<div class="w-[420px] flex-shrink-0 grid grid-cols-[minmax(0,1fr)_auto] items-center">
|
<div class="host-info-panel w-[420px] flex-shrink-0 grid grid-cols-[minmax(0,1fr)_auto] items-center">
|
||||||
<div class="flex items-center gap-2 min-w-[200px]">
|
<div class="flex items-center gap-2 min-w-[200px]">
|
||||||
<div class="w-3 h-3 rounded-full flex-shrink-0" style="background-color: ${latencyHex(null)}"></div>
|
<div class="w-3 h-3 rounded-full flex-shrink-0" style="background-color: ${latencyHex(null)}"></div>
|
||||||
<span class="font-medium text-white truncate">${host.name}</span>
|
<span class="font-medium text-white truncate">${host.name}</span>
|
||||||
@@ -589,9 +589,9 @@ function buildUI(state) {
|
|||||||
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">
|
||||||
<div class="flex items-center justify-between mb-4">
|
<div class="header-top flex items-center justify-between mb-4">
|
||||||
<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>
|
||||||
<div class="flex flex-col items-end gap-2">
|
<div class="header-controls flex flex-col items-end gap-2">
|
||||||
<button id="pause-btn"
|
<button id="pause-btn"
|
||||||
class="flex items-center gap-3 px-6 py-3 bg-gray-800 hover:bg-gray-700 border border-gray-600 rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500">
|
class="flex items-center gap-3 px-6 py-3 bg-gray-800 hover:bg-gray-700 border border-gray-600 rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||||
<svg id="pause-icon" class="w-8 h-8 text-yellow-400" fill="currentColor" viewBox="0 0 24 24">
|
<svg id="pause-icon" class="w-8 h-8 text-yellow-400" fill="currentColor" viewBox="0 0 24 24">
|
||||||
@@ -1128,9 +1128,42 @@ function handleResize(state) {
|
|||||||
|
|
||||||
// --- Bootstrap ---------------------------------------------------------------
|
// --- Bootstrap ---------------------------------------------------------------
|
||||||
|
|
||||||
|
// --- Mobile Detection --------------------------------------------------------
|
||||||
|
|
||||||
|
function isMobile() {
|
||||||
|
// 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");
|
||||||
|
app.innerHTML = `
|
||||||
|
<div class="mx-auto px-[5%] py-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>
|
||||||
|
<p class="text-gray-400 text-sm mt-2">Real-time network latency monitor</p>
|
||||||
|
</header>
|
||||||
|
<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;">
|
||||||
|
<p style="font-size: 1.5rem; font-weight: 600; color: #d1d5db;">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>`;
|
||||||
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
log.info("NetWatch starting");
|
log.info("NetWatch starting");
|
||||||
|
|
||||||
|
if (isMobile()) {
|
||||||
|
log.info("Mobile device detected — showing placeholder");
|
||||||
|
buildMobileUI();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Probe common gateway IPs to find the local router
|
// Probe common gateway IPs to find the local router
|
||||||
const gateway = await detectGateway();
|
const gateway = await detectGateway();
|
||||||
const localHosts = [LOCAL_CPE];
|
const localHosts = [LOCAL_CPE];
|
||||||
|
|||||||
@@ -22,95 +22,53 @@ body {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---- Mobile responsive layout (portrait / narrow viewports) ---- */
|
/* Mobile-responsive host rows */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
/* Header: stack title and controls vertically */
|
.host-row-inner {
|
||||||
header .flex.items-center.justify-between {
|
flex-direction: column !important;
|
||||||
flex-direction: column;
|
align-items: stretch !important;
|
||||||
align-items: flex-start !important;
|
gap: 0.5rem !important;
|
||||||
gap: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header .flex.flex-col.items-end {
|
.host-row-inner .pin-btn {
|
||||||
align-items: flex-start !important;
|
align-self: flex-end;
|
||||||
flex-direction: row;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 0.75rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pause button: smaller on mobile */
|
.host-info-panel {
|
||||||
#pause-btn {
|
width: 100% !important;
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pause-btn svg {
|
.host-row .sparkline-container {
|
||||||
width: 1.25rem;
|
width: 100% !important;
|
||||||
height: 1.25rem;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pause-text {
|
/* Summary line: allow wrapping */
|
||||||
font-size: 0.875rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Summary box: wrap into a grid for readability */
|
|
||||||
#summary {
|
#summary {
|
||||||
display: flex;
|
display: flex !important;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap !important;
|
||||||
gap: 0.25rem 0.5rem;
|
gap: 0.25rem 0.5rem !important;
|
||||||
justify-content: center;
|
justify-content: center !important;
|
||||||
line-height: 1.6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide the pipe separators on mobile */
|
|
||||||
#summary .text-gray-600.mx-3 {
|
#summary .text-gray-600.mx-3 {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Host row: stack vertically */
|
/* Header: stack controls below title */
|
||||||
.host-row .flex.items-center.gap-4 {
|
.header-top {
|
||||||
flex-direction: column;
|
flex-direction: column !important;
|
||||||
align-items: stretch !important;
|
align-items: flex-start !important;
|
||||||
gap: 0.5rem;
|
gap: 1rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Info section: full width, remove fixed width */
|
.header-controls {
|
||||||
.host-row .w-\[420px\] {
|
align-items: flex-start !important;
|
||||||
width: 100% !important;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr auto;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Host name row with dot */
|
|
||||||
.host-row .flex.items-center.gap-2.min-w-\[200px\] {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Latency value: slightly smaller on mobile */
|
|
||||||
.host-row .latency-value {
|
|
||||||
font-size: 1.875rem;
|
|
||||||
line-height: 2.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sparkline: full width below the info */
|
|
||||||
.host-row .sparkline-container {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pin button: inline with the host info */
|
#pause-btn {
|
||||||
.host-row .pin-btn {
|
width: 100%;
|
||||||
position: absolute;
|
justify-content: center;
|
||||||
right: 0.5rem;
|
|
||||||
top: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.host-row {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Footer legend: wrap nicely */
|
|
||||||
footer p {
|
|
||||||
line-height: 1.8;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user