(elements = null)
| 1091 | } |
| 1092 | |
| 1093 | function highlightInvalidTab1Inputs(elements = null) { |
| 1094 | const elementsToCheck = Array.isArray(elements) |
| 1095 | ? elements |
| 1096 | : elements |
| 1097 | ? [elements] |
| 1098 | : [UI.targetTab1, UI.listTab1, UI.searchengineSelect]; |
| 1099 | hideErrorTab1(elementsToCheck); |
| 1100 | elementsToCheck.forEach((el) => { |
| 1101 | if (el) { |
| 1102 | let isProblematic = false; |
| 1103 | if (el === UI.targetTab1 && !el.value.trim()) isProblematic = true; |
| 1104 | else if ( |
| 1105 | (el === UI.listTab1 || el === UI.searchengineSelect) && |
| 1106 | el.value === "0" |
| 1107 | ) |
| 1108 | isProblematic = true; |
| 1109 | else if ( |
| 1110 | el === UI.targetTab1 && |
| 1111 | UI.selectModTab1?.value === "1" && |
| 1112 | !el.value.includes("$target") && |
| 1113 | !el.value.includes("$t") |
| 1114 | ) |
| 1115 | isProblematic = true; |
| 1116 | else if ( |
| 1117 | el === UI.listTab1 && |
| 1118 | parseInt(UI.nbrCounter?.textContent || "0") <= 0 |
| 1119 | ) |
| 1120 | isProblematic = true; |
| 1121 | else if ( |
| 1122 | el === UI.listTab1 && |
| 1123 | parseInt(UI.nbrCounter?.textContent || "0") > CONSTANTS.TAB_LIMIT |
| 1124 | ) |
| 1125 | isProblematic = true; |
| 1126 | if (isProblematic) { |
| 1127 | setFieldError(el, true); |
| 1128 | const clearBorder = () => hideErrorTab1(el); |
| 1129 | el.addEventListener("input", clearBorder, { once: true }); |
| 1130 | el.addEventListener("change", clearBorder, { once: true }); |
| 1131 | el.addEventListener("focus", clearBorder, { once: true }); |
| 1132 | } |
| 1133 | } |
| 1134 | }); |
| 1135 | } |
| 1136 | function hideErrorTab1(element = null) { |
| 1137 | const elementsToReset = element |
| 1138 | ? Array.isArray(element) |
no test coverage detected