From 896163d7961d86b4e023a50ce4f6e19a30006a3f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 13 Nov 2026 20:49:56 +0100 Subject: feat(vm): tablet tiles with screen, trends and a power button Each VM is a tile: its screen from virsh screenshot (JPEG through ffmpeg, every 5s while the tab shows), booting until sshd answers at the ssh -G host and port, CPU and RAM trends, and a big power button, tap for the gentle action and hold to force off. A tap on the tile opens a sheet with every action as an icon and the snapshots as a timeline with their age. hold.js is now the one press and hold, K1C's stop included, and vibrates the tablet when it fires; the Windows long-press buzzes too. Co-Authored-By: Claude Opus 5.5 --- static/hold.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 static/hold.js (limited to 'static/hold.js') diff --git a/static/hold.js b/static/hold.js new file mode 100644 index 0000000..e937a25 --- /dev/null +++ b/static/hold.js @@ -0,0 +1,46 @@ +// deck-it - press and hold, for buttons a stray touch must not fire +// Copyright (C) 2026 Danilo M. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +export const HOLD_MS = 800; + +// The tablet buzzes when a hold fires (or a long press opens a menu), so +// the finger knows it can let go. +export const buzz = () => navigator.vibrate?.(40); + +// fire runs after the button is held ms; releasing early cancels, and runs +// tap instead when one is given. The button gets .holding meanwhile and +// --hold for the CSS fill. +export function hold(btn, fire, { ms = HOLD_MS, tap } = {}) { + let timer = null; + const cancel = () => { + clearTimeout(timer); + timer = null; + btn.classList.remove("holding"); + }; + btn.style.setProperty("--hold", `${ms}ms`); + btn.addEventListener("pointerdown", (e) => { + e.preventDefault(); + e.stopPropagation(); + btn.setPointerCapture(e.pointerId); + btn.classList.add("holding"); + timer = setTimeout(() => { cancel(); buzz(); fire(); }, ms); + }); + btn.addEventListener("pointerup", () => { + if (timer && tap) tap(); + cancel(); + }); + btn.addEventListener("pointercancel", cancel); +} -- cgit v1.2.3