From 7441baadb2918010f3dfb7148179b80ccfe571b8 Mon Sep 17 00:00:00 2001 From: HENRY ARTHUR Date: Thu, 14 Dec 2023 17:40:45 -0600 Subject: [PATCH 1/3] live view bug fix, keyword flag feature --- WebGUI/html/FEMacroTest.html | 245 +++++++++++++++++++++++++++++------ 1 file changed, 202 insertions(+), 43 deletions(-) diff --git a/WebGUI/html/FEMacroTest.html b/WebGUI/html/FEMacroTest.html index f94ccc4c..efd72b11 100755 --- a/WebGUI/html/FEMacroTest.html +++ b/WebGUI/html/FEMacroTest.html @@ -285,6 +285,16 @@ var stopSequenceFlag = false; var currentIndex = 0; + + var currentHistoryRecord = null; + + var lastRunMacro = { row: null, col: null }; + + var flagKeyword = ""; + + var flagIfPresent = true; + + var isFlagActive = false; ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// @@ -582,6 +592,7 @@ el.style.width = (verticalOutputDivSize_[0] + 30) + "px"; } + lastRunMacro = { row: r, col: c }; Debug.log("runMacro(" + r + "," + c + ")"); @@ -686,17 +697,6 @@ true /*callHandlerOnErr*/ ); } - - if (currentLiveViewTimeout !== null) - { - clearTimeout(currentLiveViewTimeout); - currentLiveViewTimeout = null; - } - - if (liveViewActive) - { - currentLiveViewTimeout = setTimeout(function() { runMacro(r, c); }, intervalTime); - } var command = { "feClass": feClassSelected, @@ -903,7 +903,72 @@ Debug.log("Returning scroll position", DesktopContent.getWindowScrollTop(),"to",scrollTop); - DesktopContent.setWindowScrollTop(scrollTop); + DesktopContent.setWindowScrollTop(scrollTop); + + if (isFlagActive) + { + var outputContainsKeyword = el.innerHTML.includes(flagKeyword); + var shouldFlag = (flagIfPresent && outputContainsKeyword) || (!flagIfPresent && !outputContainsKeyword); + + if (flagKeyword && shouldFlag) + { + var message; + if (flagIfPresent) + { + message = "ALERT: String '" + flagKeyword + "' found!\n\nThe macro has been halted."; + } + else + { + message = "ALERT: String '" + flagKeyword + "' not found!\n\nThe macro has been halted."; + } + document.getElementById('matchMessage').innerText = message; + + // Show the keyword match popup + document.getElementById('popupKeywordMatch').style.display = 'block'; + + if (liveViewActive) + { + liveViewActive = false; + if (currentLiveViewTimeout) + { + clearTimeout(currentLiveViewTimeout); + currentLiveViewTimeout = null; + } + var liveViewBtn = document.getElementById('liveViewBtn'); + liveViewBtn.textContent = 'Live View'; + liveViewBtn.style.backgroundColor = ''; + liveViewBtn.style.color = ''; + } + var flagTriggerButton = document.getElementById('flagTriggerButton'); + if (flagTriggerButton) + { + flagTriggerButton.style.border = "1px solid black"; + } + isFlagActive = false; + return; + } + } + + if (liveViewActive) + { + if (currentLiveViewTimeout !== null) + { + clearTimeout(currentLiveViewTimeout); + } + + currentLiveViewTimeout = setTimeout(function() + { + if (currentHistoryRecord !== null) + { + onClickHistoryRecord(currentHistoryRecord); + } + else if (lastRunMacroDetails.row !== null && lastRunMacroDetails.col !== null) + { + runMacro(lastRunMacroDetails.row, lastRunMacroDetails.col); + } + }, intervalTime); + } + } //===================================================================================== @@ -984,15 +1049,26 @@ "td", { "id": "macroModule-history", - "class":"macroModule", + "class": "macroModule", "rowspan": maxRow, - "width":"400px", + "width": "400px", }, - "
" + + "
" + "

Command history

" + - "", - true); - + "
" + + "" + + "" + + "
" + + "
" + + "
" + + "
" + + "
Delay: 2 seconds
" + + "
Alert For: [None]
" + + "
" + + "
", + true + ); + // add sequence builder str += DesktopContent.htmlOpen( "td", @@ -2013,6 +2089,8 @@ function onClickHistoryRecord(recordObj) { + currentHistoryRecord = recordObj; + // in bulding sequence mode add the macro to the sequence if (sequenceBuilding_) { @@ -2054,19 +2132,8 @@ } } - if (currentLiveViewTimeout !== null) - { - clearTimeout(currentLiveViewTimeout); - currentLiveViewTimeout = null; - } - // show the command in the interface appendHistoryRecord(JSON.stringify(recordObj)); - - if (liveViewActive) - { - currentLiveViewTimeout = setTimeout(function() { onClickHistoryRecord(recordObj); }, intervalTime); - } } // ask confirm before clearing the history @@ -2097,7 +2164,19 @@ wholeDiv.style.display = "none"; liveViewActive = false; document.getElementById('intervalTime').value = '2'; + document.getElementById('noDelayCheckbox').checked = false; + } + // hide the popup for keyword flag + function hideSmallPopupFlag() + { + var flagKeywordInput = document.getElementById("flagKeyword"); + flagKeywordInput.value = ""; + var popupFlagAlert = document.getElementById('popupFlagAlert'); + if (popupFlagAlert) + { + popupFlagAlert.style.display = 'none'; + } } // clear the history @@ -2112,7 +2191,7 @@ // live view function toggleLiveView() { - + document.getElementById('delayValue').textContent = '2 seconds'; liveViewActive = !liveViewActive; if (liveViewActive) @@ -2143,15 +2222,28 @@ } - function setIntervalAndStart() + function setIntervalAndStart() { - var intervalTimeInput = document.getElementById('intervalTime').value*1000; - intervalTime = parseInt(intervalTimeInput); + var intervalTimeInput = document.getElementById('intervalTime').value; + var noDelayCheckbox = document.getElementById('noDelayCheckbox'); - if (isNaN(intervalTime) || intervalTime <= 0) + if (noDelayCheckbox.checked) { - alert("Please enter a valid number greater than 0"); - return; + intervalTime = 0; + document.getElementById('delayValue').textContent = 'None'; + } + else + { + intervalTime = parseInt(intervalTimeInput, 10) * 1000; + if (isNaN(intervalTime) || intervalTime < 0) + { + alert("Please enter a valid number greater than or equal to 0"); + return; + } + else + { + document.getElementById('delayValue').textContent = (intervalTime / 1000) + ' seconds'; + } } document.getElementById('popupSetInterval').style.display = 'none'; @@ -2160,8 +2252,9 @@ liveViewBtn.textContent = 'Stop Live View'; liveViewBtn.style.backgroundColor = 'red'; liveViewBtn.style.color = 'white'; - + document.getElementById('noDelayCheckbox').checked = false; + // Enable live view only if it's not already active if (!liveViewActive) { liveViewActive = true; @@ -2181,6 +2274,45 @@ return true; } + function PopupMacroFlagAlert() + { + var flagTriggerButton = document.getElementById('flagTriggerButton'); + + if (isFlagActive) + { + flagKeyword = ""; + flagIfPresent = true; + flagTriggerButton.style.border = "1px solid black"; + isFlagActive = false; + document.getElementById('keywordValue').textContent = '[None]'; + } + else + { + document.getElementById('popupFlagAlert').style.display = 'block'; + } + } + + function setFlagKeyword(isPresent) + { + flagKeyword = document.getElementById('flagKeyword').value; + flagIfPresent = isPresent; + document.getElementById('keywordValue').textContent = flagKeyword || '[None]'; + + var flagTriggerButton = document.getElementById('flagTriggerButton'); + if (flagKeyword) + { + flagTriggerButton.style.border = "3px solid green"; + isFlagActive = true; + } + else + { + flagTriggerButton.style.border = "1px solid black"; + isFlagActive = false; + } + + document.getElementById('popupFlagAlert').style.display = 'none'; + } + //===================================================================================== //loadSequence @@ -3140,15 +3272,42 @@

Set Delay Between Macros (sec):

-
-

Please enter the interval time (sec):

- -
+
+

Please enter the interval time (sec):

+ +
+ + +
+
-
-
+
+
+ + + +
From 334fdb2a679c56239350c38b8942f22d43188017 Mon Sep 17 00:00:00 2001 From: HENRY ARTHUR Date: Thu, 11 Jan 2024 13:08:13 -0600 Subject: [PATCH 2/3] Updated Flag Feature with Operators --- WebGUI/html/FEMacroTest.html | 164 ++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 39 deletions(-) diff --git a/WebGUI/html/FEMacroTest.html b/WebGUI/html/FEMacroTest.html index efd72b11..4aa96097 100755 --- a/WebGUI/html/FEMacroTest.html +++ b/WebGUI/html/FEMacroTest.html @@ -902,50 +902,117 @@ el.innerHTML = str; Debug.log("Returning scroll position", - DesktopContent.getWindowScrollTop(),"to",scrollTop); + DesktopContent.getWindowScrollTop(),"to",scrollTop); DesktopContent.setWindowScrollTop(scrollTop); - if (isFlagActive) - { - var outputContainsKeyword = el.innerHTML.includes(flagKeyword); - var shouldFlag = (flagIfPresent && outputContainsKeyword) || (!flagIfPresent && !outputContainsKeyword); - - if (flagKeyword && shouldFlag) - { - var message; - if (flagIfPresent) - { - message = "ALERT: String '" + flagKeyword + "' found!\n\nThe macro has been halted."; - } - else - { - message = "ALERT: String '" + flagKeyword + "' not found!\n\nThe macro has been halted."; + if (isFlagActive) { + var comparisonOperator = document.getElementById('comparisonOperator').value; + var triggeredNumber = null; + + if (comparisonOperator === 'none') { + var outputContainsKeyword = el.innerHTML.includes(flagKeyword); + var shouldFlag = (flagIfPresent && outputContainsKeyword) || (!flagIfPresent && !outputContainsKeyword); + + if (shouldFlag) { + var message = flagIfPresent ? + "ALERT: String '" + flagKeyword + "' found!\n\nThe macro has been halted." : + "ALERT: String '" + flagKeyword + "' not found!\n\nThe macro has been halted."; + document.getElementById('matchMessage').innerText = message; + document.getElementById('popupKeywordMatch').style.display = 'block'; + + if (liveViewActive) { + liveViewActive = false; + if (currentLiveViewTimeout) { + clearTimeout(currentLiveViewTimeout); + currentLiveViewTimeout = null; + } + var liveViewBtn = document.getElementById('liveViewBtn'); + liveViewBtn.textContent = 'Live View'; + liveViewBtn.style.backgroundColor = ''; + liveViewBtn.style.color = ''; + } + var flagTriggerButton = document.getElementById('flagTriggerButton'); + if (flagTriggerButton) { + flagTriggerButton.style.border = "1px solid black"; + } + isFlagActive = false; } - document.getElementById('matchMessage').innerText = message; + } else { + // Numerical comparison logic for other operators + var keywordParts = flagKeyword.match(/(.*?)\s*<([\d.]+)>/); + if (keywordParts && keywordParts.length === 3) { + var searchText = keywordParts[1].trim(); + var numberToCompare = parseFloat(keywordParts[2]); + var regex = new RegExp(searchText + '\\s*\\|\\s*\\d+(\\.\\d+)?\\b', 'g'); + var conditionMet = false; + + var match; + while ((match = regex.exec(el.innerHTML)) !== null) { + var foundNumber = parseFloat(match[0].match(/\d+(\.\d+)?/)[0]); + if (!conditionMet) { + switch (comparisonOperator) { + case "gt": + if (foundNumber > numberToCompare) { + conditionMet = true; + triggeredNumber = foundNumber; + } + break; + case "gte": + if (foundNumber >= numberToCompare) { + conditionMet = true; + triggeredNumber = foundNumber; + } + break; + case "lt": + if (foundNumber < numberToCompare) { + conditionMet = true; + triggeredNumber = foundNumber; + } + break; + case "lte": + if (foundNumber <= numberToCompare) { + conditionMet = true; + triggeredNumber = foundNumber; + } + break; + } + } + } - // Show the keyword match popup - document.getElementById('popupKeywordMatch').style.display = 'block'; + if (conditionMet) { + var message; + var operatorSymbol = getOperatorSymbol(comparisonOperator); + if (flagIfPresent) { + var message = "ALERT: Condition met for: " + operatorSymbol + " " + numberToCompare + ".\n\nTarget was stopped at " + triggeredNumber + "\n\nThe macro has been halted."; + } else { + var message = "ALERT: Condition not met for '" + operatorSymbol + " " + numberToCompare + "'.\n\nTarget was stopped at " + triggeredNumber + "\n\nThe macro has been halted."; + } + document.getElementById('matchMessage').innerText = message; + document.getElementById('popupKeywordMatch').style.display = 'block'; - if (liveViewActive) - { - liveViewActive = false; - if (currentLiveViewTimeout) - { - clearTimeout(currentLiveViewTimeout); - currentLiveViewTimeout = null; + if (isSequenceRunning) { + onClickStopSequence(); + } + + // Repeating the logic for stopping the live view and updating UI elements + if (liveViewActive) { + liveViewActive = false; + if (currentLiveViewTimeout) { + clearTimeout(currentLiveViewTimeout); + currentLiveViewTimeout = null; + } + var liveViewBtn = document.getElementById('liveViewBtn'); + liveViewBtn.textContent = 'Live View'; + liveViewBtn.style.backgroundColor = ''; + liveViewBtn.style.color = ''; + } + var flagTriggerButton = document.getElementById('flagTriggerButton'); + if (flagTriggerButton) { + flagTriggerButton.style.border = "1px solid black"; + } + isFlagActive = false; } - var liveViewBtn = document.getElementById('liveViewBtn'); - liveViewBtn.textContent = 'Live View'; - liveViewBtn.style.backgroundColor = ''; - liveViewBtn.style.color = ''; - } - var flagTriggerButton = document.getElementById('flagTriggerButton'); - if (flagTriggerButton) - { - flagTriggerButton.style.border = "1px solid black"; } - isFlagActive = false; - return; } } @@ -3231,6 +3298,16 @@ return true; } + function getOperatorSymbol(operator) { + switch (operator) { + case "gt": return ">"; + case "gte": return ">="; + case "lt": return "<"; + case "lte": return "<="; + default: return ""; + } + } + // END SEQUENCE CONTROL //===================================================================================== @@ -3289,7 +3366,16 @@

Please enter the interval time (sec):

-
+