diff --git a/webapp/path_navigator.html b/webapp/path_navigator.html index 1fb5a03..f5c8d2b 100644 --- a/webapp/path_navigator.html +++ b/webapp/path_navigator.html @@ -352,6 +352,14 @@ 'border-width': 0, } }, + { + selector: 'node[sirenActive = "true"]', + style: { + 'border-width': 4, + 'border-color': '#ffffff', + 'border-opacity': 1, + } + }, { selector: 'edge', style: { @@ -462,6 +470,20 @@ }) }).then(r => r.json()).then(data => { console.log('Playing on', destination + ':', data.frequency.toFixed(2), 'Hz on voice', data.voice); + + // If playing on siren, add white circle around node for this voice + if (isShift) { + const nodeColor = node.data('color'); + // Find any existing node with same color that has sirenActive and remove it + cy.nodes().forEach(n => { + if (n.data('color') === nodeColor && n.data('sirenActive')) { + n.data('sirenActive', ''); + } + }); + // Add sirenActive to clicked node + node.data('sirenActive', 'true'); + console.log('Added sirenActive to', node.id(), 'color:', nodeColor); + } }).catch(err => { console.log('Error playing freq:', err); }); @@ -716,6 +738,7 @@ // Count differences in dims 1, 2, 3 let diffCount = 0; let diffDim = -1; + let broke = false; for (let d = 1; d < hs1.length; d++) { const diff = hs2[d] - hs1[d]; @@ -723,12 +746,13 @@ diffCount++; diffDim = d; } else if (diff !== 0) { + broke = true; break; // diff > 1 in this dimension } } - // Check if exactly one dimension differs - if (diffCount === 1 && diffDim > 0) { + // Check if exactly one dimension differs AND loop didn't break early + if (!broke && diffCount === 1 && diffDim > 0) { // Calculate frequency ratio const diffHs = []; for (let d = 0; d < hs1.length; d++) { @@ -975,6 +999,8 @@ body: JSON.stringify({ soft: true }) }).then(r => r.json()).then(data => { console.log('Soft kill sent (20 Hz)'); + // Clear all siren circles + cy.nodes().forEach(n => n.removeData('sirenActive')); }).catch(err => { console.log('Error sending kill:', err); }); @@ -986,6 +1012,8 @@ body: JSON.stringify({ soft: false }) }).then(r => r.json()).then(data => { console.log('Hard kill sent (0 Hz)'); + // Clear all siren circles + cy.nodes().forEach(n => n.removeData('sirenActive')); }).catch(err => { console.log('Error sending kill:', err); });