MCPcopy Create free account
hub / github.com/SKVNDR/FastDork / populateDropdownWithOptions

Function populateDropdownWithOptions

Script/FastDork.js:568–597  ·  view source on GitHub ↗
(
    selectElement,
    defaultText,
    optionsArray
  )

Source from the content-addressed store, hash-verified

566 return option;
567 }
568 function populateDropdownWithOptions(
569 selectElement,
570 defaultText,
571 optionsArray
572 ) {
573 if (!selectElement) return;
574 console.log(
575 `[populateDropdownWithOptions] Populating ${selectElement.id}. Options received: ${optionsArray.length}`
576 );
577 console.log(
578 `[populateDropdownWithOptions] BEFORE clear ${selectElement.id}, options: ${selectElement.options.length}`
579 );
580 selectElement.replaceChildren();
581 selectElement.appendChild(createDefaultOption(defaultText));
582 console.log(
583 `[populateDropdownWithOptions] AFTER default ${selectElement.id}, options: ${selectElement.options.length}`
584 );
585 optionsArray.forEach((optData) => {
586 const option = document.createElement("option");
587 option.value = optData.value;
588 option.textContent = optData.text;
589 if (optData.title) option.title = optData.title;
590 if (optData.className) option.className = optData.className;
591 selectElement.appendChild(option);
592 });
593 console.log(
594 `[populateDropdownWithOptions] AFTER adding ${optionsArray.length} options to ${selectElement.id}, total options: ${selectElement.options.length}`
595 );
596 selectElement.value = "0";
597 }
598 async function loadAndPopulateLists() {
599 console.log(`[${Date.now()}] [loadAndPopulateLists] Fetching list keys...`); // Timestamp
600 let listKeys = [];

Callers 2

loadAndPopulateListsFunction · 0.85
loadAndPopulateEnginesFunction · 0.85

Calls 1

createDefaultOptionFunction · 0.85

Tested by

no test coverage detected