From 50a707e88ecc2d668a2e2f5776e0425d1e69cd03 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Fri, 31 Jul 2026 13:42:42 +0200 Subject: [PATCH] setting to active no longer reloads the page else we have a conflict with the tunneled option --- templates/common.html | 16 +++++++++------- templates/secop.js | 27 +++++++++++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/templates/common.html b/templates/common.html index a45a160..2a7156d 100644 --- a/templates/common.html +++ b/templates/common.html @@ -13,8 +13,8 @@ {% include svg %}
- view only - ACTIVE + view only + ACTIVE

Status messages

@@ -25,12 +25,14 @@ diff --git a/templates/secop.js b/templates/secop.js index 38d347d..ad3df46 100644 --- a/templates/secop.js +++ b/templates/secop.js @@ -29,9 +29,8 @@ function handle_describing(action, modpar, data) { // console.log(mod, param, func); if (func.includes("click")) { clickElement = elem; - if (writable) { - addClickListener(elem, mod, toggleTarget); - } + console.log(mod, param, func, elem); + addClickListener(elem, mod, toggleTarget); } if (func.includes("fault")) { changeFuncs[mod + ":status"] = function (value) { @@ -59,9 +58,7 @@ function handle_describing(action, modpar, data) { } if (func.includes("command")) { console.log(func, mod, param); - if (writable) { - addClickListener(elem, mod + ":" + param, sendCommand); - } + addClickListener(elem, mod + ":" + param, sendCommand); } }) if (stateElement && clickElement) { @@ -70,7 +67,7 @@ function handle_describing(action, modpar, data) { } } console.log('ACTIVATE', changeFuncs); - doSend("activate"); + websocket.send("activate"); } function handle_update(action, modpar, data) { @@ -151,7 +148,7 @@ function doConnect() { function onOpen(evt) { writeToScreen("Connected to "+ wsaddr + "\n"); - doSend("describe"); + websocket.send("describe"); /* for (var mod in ctr_state) { readValue(mod); @@ -180,11 +177,24 @@ function onError(evt) { } function doSend(message) { + // send a change or do message + console.log('doSend'); + if (! writable) { + console.log('unprotected doSend') + return; + } console.log('>', message); websocket.send(message); } +function warnViewOnly() { + if (writable) return false; + alert('please set the page ACTIVE to change things'); + return true; +} + function toggleTarget(element, mod) { + if (warnViewOnly()) return; stateElement = element.stateElement || element const newState = stateElement.state === false; console.log('click', element, mod, stateElement.state, newState); @@ -193,6 +203,7 @@ function toggleTarget(element, mod) { } function sendCommand(element, modcmd) { + if (warnViewOnly()) return; console.log('command', modcmd); doSend(`do ${modcmd}`); }