This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/main by this push:
new 02d058c Fix lint errors in the script to display the vote email
preview
02d058c is described below
commit 02d058c1c5c77942269e4907cc76ffc458e93d7c
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Dec 12 17:08:08 2025 +0000
Fix lint errors in the script to display the vote email preview
---
atr/static/js/src/vote-preview.js | 56 +++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 14 deletions(-)
diff --git a/atr/static/js/src/vote-preview.js
b/atr/static/js/src/vote-preview.js
index 1c96362..c8176c4 100644
--- a/atr/static/js/src/vote-preview.js
+++ b/atr/static/js/src/vote-preview.js
@@ -17,10 +17,7 @@
* under the License.
*/
-document.addEventListener("DOMContentLoaded", () => {
- let debounceTimeout;
- const debounceDelay = 500;
-
+function getVotePreviewElements() {
const bodyTextarea = document.getElementById("body");
const voteDurationInput = document.getElementById("vote_duration");
const textPreviewContent = document.getElementById(
@@ -31,7 +28,7 @@ document.addEventListener("DOMContentLoaded", () => {
if (!bodyTextarea || !voteDurationInput || !textPreviewContent ||
!voteForm) {
console.error("Required elements for vote preview not found.
Exiting.");
- return;
+ return null;
}
const previewUrl = configElement ? configElement.dataset.previewUrl :
null;
@@ -42,11 +39,30 @@ document.addEventListener("DOMContentLoaded", () => {
console.error(
"Required data attributes or CSRF token not found for
vote preview.",
);
- return;
+ return null;
}
- const csrfToken = csrfTokenInput.value;
- function fetchAndUpdateVotePreview() {
+ return {
+ bodyTextarea,
+ voteDurationInput,
+ textPreviewContent,
+ previewUrl,
+ minHours,
+ csrfToken: csrfTokenInput.value,
+ };
+}
+
+function createPreviewFetcher(elements) {
+ const {
+ bodyTextarea,
+ voteDurationInput,
+ textPreviewContent,
+ previewUrl,
+ minHours,
+ csrfToken,
+ } = elements;
+
+ return function fetchAndUpdateVotePreview() {
const bodyContent = bodyTextarea.value;
const voteDuration = voteDurationInput.value || minHours;
@@ -77,17 +93,29 @@ document.addEventListener("DOMContentLoaded", () => {
console.error("Error fetching email preview:",
error);
textPreviewContent.textContent = `Error loading
preview:\n${error.message}`;
});
- }
+ };
+}
+
+function setupVotePreviewListeners(elements, fetchPreview) {
+ let debounceTimeout;
+ const debounceDelay = 500;
- bodyTextarea.addEventListener("input", () => {
+ elements.bodyTextarea.addEventListener("input", () => {
clearTimeout(debounceTimeout);
- debounceTimeout = setTimeout(fetchAndUpdateVotePreview,
debounceDelay);
+ debounceTimeout = setTimeout(fetchPreview, debounceDelay);
});
- voteDurationInput.addEventListener("input", () => {
+ elements.voteDurationInput.addEventListener("input", () => {
clearTimeout(debounceTimeout);
- debounceTimeout = setTimeout(fetchAndUpdateVotePreview,
debounceDelay);
+ debounceTimeout = setTimeout(fetchPreview, debounceDelay);
});
+}
+
+document.addEventListener("DOMContentLoaded", () => {
+ const elements = getVotePreviewElements();
+ if (!elements) return;
- fetchAndUpdateVotePreview();
+ const fetchPreview = createPreviewFetcher(elements);
+ setupVotePreviewListeners(elements, fetchPreview);
+ fetchPreview();
});
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]