MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / applySettingsFromConfig

Function applySettingsFromConfig

ui/media/js/parameters.js:559–592  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

557}
558
559function applySettingsFromConfig(config) {
560 Array.from(parametersTable.children).forEach((parameterRow) => {
561 if (parameterRow.dataset.settingId in config && parameterRow.dataset.saveInAppConfig === "true") {
562 const configValue = config[parameterRow.dataset.settingId]
563 const parameterElement =
564 document.getElementById(parameterRow.dataset.settingId) ||
565 parameterRow.querySelector("input") ||
566 parameterRow.querySelector("select")
567
568 switch (parameterElement?.tagName) {
569 case "INPUT":
570 if (parameterElement.type === "checkbox") {
571 parameterElement.checked = configValue
572 } else {
573 parameterElement.value = configValue
574 }
575 parameterElement.dispatchEvent(new Event("change"))
576 break
577 case "SELECT":
578 if (Array.isArray(configValue)) {
579 Array.from(parameterElement.options).forEach((option) => {
580 if (configValue.includes(option.value || option.text)) {
581 option.selected = true
582 }
583 })
584 } else {
585 parameterElement.value = configValue
586 }
587 parameterElement.dispatchEvent(new Event("change"))
588 break
589 }
590 }
591 })
592}
593
594saveToDiskField.addEventListener("change", function (e) {
595 diskPathField.disabled = !this.checked

Callers 1

getAppConfigFunction · 0.85

Calls 1

dispatchEventMethod · 0.45

Tested by

no test coverage detected