()
| 225 | |
| 226 | // Returns true if there are errors, false otherwise. |
| 227 | function showValidationErrors() { |
| 228 | // Remove all previous validation errors. |
| 229 | let els = document.querySelectorAll(".validation-error"); |
| 230 | for (const el of els) { |
| 231 | el.classList.remove("validation-error"); |
| 232 | } |
| 233 | els = document.querySelectorAll(".validation-message"); |
| 234 | for (const el of els) { |
| 235 | el.remove(); |
| 236 | } |
| 237 | |
| 238 | const errors = getValidationErrors(); |
| 239 | for (const [optionName, message] of Object.entries(errors)) { |
| 240 | const el = getOptionEl(optionName); |
| 241 | addValidationMessage(el, message); |
| 242 | } |
| 243 | // Some options can be hidden in the UI. If they have validation errors, force them to be shown. |
| 244 | if (errors["linkHintCharacters"]) { |
| 245 | showElement(document.querySelector("#link-hint-characters-container"), true); |
| 246 | } |
| 247 | if (errors["linkHintNumbers"]) { |
| 248 | showElement(document.querySelector("#link-hint-numbers-container"), true); |
| 249 | } |
| 250 | const hasErrors = Object.keys(errors).length > 0; |
| 251 | return hasErrors; |
| 252 | } |
| 253 | |
| 254 | function removeDuplicateChars(str) { |
| 255 | const seen = new Set(); |
no test coverage detected