MCPcopy
hub / github.com/philc/vimium / showValidationErrors

Function showValidationErrors

pages/options.js:227–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

225
226// Returns true if there are errors, false otherwise.
227function 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
254function removeDuplicateChars(str) {
255 const seen = new Set();

Callers 2

initFunction · 0.70
saveOptionsFunction · 0.70

Calls 5

getValidationErrorsFunction · 0.85
getOptionElFunction · 0.85
addValidationMessageFunction · 0.85
showElementFunction · 0.85
removeMethod · 0.80

Tested by

no test coverage detected