Skip to content

Commit de0b02c

Browse files
committed
Re-formatted JS file.
1 parent 7bf9cb6 commit de0b02c

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed
Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
// Add this to your admin JavaScript file
21
document.addEventListener('DOMContentLoaded', function() {
3-
4-
const sanitizationMethodSelect = document.querySelector("#data_sanitization_method");
5-
if (! sanitizationMethodSelect || sanitizationMethodSelect.length === 0) {
2+
const sanitizationMethodSelect = document.querySelector("#data_sanitization_method");
3+
if (!sanitizationMethodSelect) {
64
return;
75
}
86

97
function toggleCustomFields() {
10-
const isCustom = sanitizationMethodSelect.value === 'custom';
8+
const isCustom = sanitizationMethodSelect.value === 'custom';
9+
const customElements = document.querySelectorAll('.wpgraphql-logging-custom');
1110

12-
if (isCustom) {
13-
document.querySelectorAll('.wpgraphql-logging-custom').forEach((el) => {
11+
customElements.forEach((el) => {
12+
if (isCustom) {
1413
el.classList.add('block');
15-
});
16-
} else {
17-
document.querySelectorAll('.wpgraphql-logging-custom').forEach((el) => {
14+
} else {
1815
el.classList.remove('block');
19-
});
20-
}
21-
}
16+
}
17+
});
18+
}
2219

23-
// Initial check on page load
2420
toggleCustomFields();
25-
26-
// Listen for changes
2721
sanitizationMethodSelect.addEventListener('change', toggleCustomFields);
2822
});

0 commit comments

Comments
 (0)