updatePreview function presentation
Last updated: 2026-03-04T23:21:38.396Z
Metrics
LOC: 38
Complexity: 12
Params: 0
Signature
updatePreview(): : void
Architecture violations
- [warning] max-cyclomatic-complexity: 'updatePreview' has cyclomatic complexity 12 (max 10)
Source Code
function updatePreview(): void {
if (!rulePopupElement) return;
const fixedInput =
rulePopupElement.querySelector<HTMLInputElement>("#fa-rp-fixed");
const previewValueEl = rulePopupElement.querySelector<HTMLElement>(
"#fa-rp-preview-value",
);
const refreshBtn = rulePopupElement.querySelector<HTMLElement>(
"#fa-rp-preview-refresh",
);
if (!fixedInput || !previewValueEl) return;
const fixedVal = fixedInput.value.trim();
if (fixedVal) {
previewValueEl.textContent = fixedVal;
previewValueEl.className = "fa-rp-preview-fixed";
if (refreshBtn) refreshBtn.style.display = "none";
} else {
const selectedType = genSearchableSelect?.getValue() ?? "auto";
const typeToGenerate: FieldType =
selectedType === "auto"
? (currentSuggestedType ?? "text")
: (selectedType as FieldType);
try {
const overrideParams = collectParamsFromUI();
previewValueEl.textContent = generate(typeToGenerate, overrideParams);
} catch {
previewValueEl.textContent = "—";
}
previewValueEl.className = "fa-rp-preview-generated";
if (refreshBtn) refreshBtn.style.display = "flex";
}
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| collectParamsFromUI | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| showRulePopup | calls |
| setupPopupListeners | calls |
| updateParamsSection | calls |