From 1fd970a5c18265968d21586dd33e7702fcc7a763 Mon Sep 17 00:00:00 2001 From: David Huss <dh@atoav.com> Date: Wed, 6 Nov 2024 15:26:51 +0100 Subject: [PATCH] Reload when long pressed on extended library header text --- static/ws.js | 21 ++++++++++++++++++++- templates/index.html | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/static/ws.js b/static/ws.js index 2084716..fead127 100644 --- a/static/ws.js +++ b/static/ws.js @@ -470,4 +470,23 @@ function updateClocks() { let time = now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0') + ":" + now.getSeconds().toString().padStart(2, '0'); Array.from(document.getElementsByClassName('time-display')).forEach(t => t.innerHTML = time); } -setInterval(updateClocks, 1000); \ No newline at end of file +setInterval(updateClocks, 1000); + + +// Reload when Extended-Library title section is clicked +let header_title = document.getElementById("header-title"); +header_title.addEventListener("mousedown", longClickHandler, true); +header_title.addEventListener("mouseup", longClickHandler, true); + +let startClick = 0; +function longClickHandler(e){ + if(e.type == "mousedown"){ + startClick = e.timeStamp; + } + else if(e.type == "mouseup" && startClick > 0){ + if(e.timeStamp - startClick > 1000){ // 0.5 secound + console.log("Long click !!!"); + location.reload(true); + } + } +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 7c295cc..0cb1c8a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -28,7 +28,7 @@ <p class="status_text">{{ status['ahm']['power'] }}</p> </div> - <div class="title"> + <div class="title" id="header-title"> <h1>Extended Library</h1> <p class="time-display"></p> <p id="uptime-display"></p> -- GitLab