1if (document.readyState === "loading") { 2 document.addEventListener("DOMContentLoaded", setDateAttribute); 3} else { 4 setDateAttribute(); 5} 6 7function setDateAttribute() { 8 console.info("DOM loaded - Running Multi-Form Injection"); 9 10 const sourceElementId = 'TriviaRegistrationForm'; 11 const sourceAttribute = 'eventDate'; 12 const registrationDiv = document.getElementById(sourceElementId); 13 14 if (!registrationDiv) { 15 console.error(`â Source div ID '${sourceElementId}' not found on the page.`); 16 return; 17 } 18 19 const rawDateString = registrationDiv.getAttribute(sourceAttribute); 20 if (!rawDateString || rawDateString.length < 8) { 21 console.error(`â Valid raw date attribute not found.`); 22 return; 23 } 24 25 // Parse YYYYMMDD to YYYY-MM-DD 26 const year = rawDateString.substring(0, 4); 27 const month = rawDateString.substring(4, 6); 28 const day = rawDateString.substring(6, 8); 29 const targetDateString = `${year}-${month}-${day}`; 30 31 // Find EVERY input element with the name "event-date" across the entire document 32 const dateFields = document.querySelectorAll('input[name="event-date"]'); 33 34 if (dateFields.length > 0) { 35 console.log(`ð¯ Found ${dateFields.length} instances of the date field on this page.`); 36 37 const forceAllValues = () => { 38 dateFields.forEach((field, index) => { 39 field.value = targetDateString; 40 field.setAttribute('value', targetDateString); 41 field.readOnly = true; 42 43 // Keep background readable but distinctly locked 44 field.style.backgroundColor = "#f5f5f5"; 45 46 // Fire validation events for Contact Form 7 on each field instance 47 field.dispatchEvent(new Event('input', { bubbles: true })); 48 field.dispatchEvent(new Event('change', { bubbles: true })); 49 50 console.log(`â Injected date into field instance #${index}`); 51 }); 52 }; 53 54 // Blast the values across the initialization sequence to override CF7 boot cycles 55 forceAllValues(); 56 setTimeout(forceAllValues, 100); 57 setTimeout(forceAllValues, 500); 58 setTimeout(forceAllValues, 1500); 59 setTimeout(forceAllValues, 3000); 60 61 } else { 62 console.error("â Could not find any input fields matching name='event-date'."); 63 } 64}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.