fixed dom extraction

This commit is contained in:
CocoByte 2024-07-23 10:55:02 -06:00
parent bc334bd41f
commit b245dfb2fe
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F

View file

@ -2,23 +2,40 @@
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('copy-summary-btn').addEventListener('click', function() {
// Generate the summary text
const organizationType = document.getElementById('id_organization_type').value;
const requestedDomain = document.getElementById('id_requested_domain').value;
const existingWebsites = Array.from(document.querySelectorAll('#id_current_websites')).map(el => el.text).join(', ');
const alternativeDomains = Array.from(document.querySelectorAll('#id_alternative_domains')).map(el => el.text).join(', ');
const submitter = document.getElementById('id_submitter').value;
const seniorOfficial = document.getElementById('id_senior_official').value;
const otherContacts = Array.from(document.querySelectorAll('#id_other_contacts option:checked')).map(el => el.text).join('\n ');
const organizationTypeElement = document.getElementById('id_organization_type');
const organizationType = organizationTypeElement.options[organizationTypeElement.selectedIndex].text;
const alternativeDomainsDiv = document.querySelector('.form-row.field-alternative_domains .readonly');
const alternativeDomainslinks = alternativeDomainsDiv.querySelectorAll('a');
const alternativeDomains = Array.from(alternativeDomainslinks).map(link => link.textContent);
const existingWebsitesDiv = document.querySelector('.form-row.field-current_websites .readonly');
const existingWebsiteslinks = existingWebsitesDiv.querySelectorAll('a');
const existingWebsites = Array.from(existingWebsiteslinks).map(link => link.textContent);
const otherContactsDiv = document.querySelector('.form-row.field-other_contacts .readonly');
const otherContactslinks = otherContactsDiv.querySelectorAll('a');
const otherContacts = Array.from(otherContactslinks).map(link => link.textContent);
const requestedDomainElement = document.getElementById('id_requested_domain');
const requestedDomain = requestedDomainElement.options[requestedDomainElement.selectedIndex].text;
const submitterElement = document.getElementById('id_submitter');
const submitter = submitterElement.options[submitterElement.selectedIndex].text;
const seniorOfficialElement = document.getElementById('id_senior_official');
const seniorOfficial = seniorOfficialElement.options[seniorOfficialElement.selectedIndex].text;
const summary = `<strong>Recommendation:</strong></br>` +
`<strong>Organization Type:</strong> ${organizationType}</br>` +
`<strong>Requested Domain:</strong> ${requestedDomain}</br>` +
`<strong>Existing website(s):</strong> ${existingWebsites}</br>` +
`<strong>Rationale:</strong>` +
`<strong>Alternate Domain(s):</strong> ${alternativeDomains.split(', ').join('\n ')}</br>` +
`<strong>Existing website(s):</strong> ${existingWebsites.join('</br>')}</br>` +
`<strong>Rationale:</strong></br>` +
`<strong>Alternate Domain(s):</strong> ${alternativeDomains.join('</br>')}</br>` +
`<strong>Submitter:</strong> ${submitter}</br>` +
`<strong>Senior Official:</strong> ${seniorOfficial}</br>` +
`<strong>Additional Contact(s):</strong> ${otherContacts}</br>`;
`<strong>Additional Contact(s):</strong> ${otherContacts.join('</br>')}</br>`;
// Create a temporary element
let tempElement = document.createElement('div');