Skip to content
Merged

Dev #65

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<button type="button" class="btn btn-outline" href="#" onclick="copyToClipboard(event)">Copy</button>
<button type="button" class="btn btn-outline" href="#" onclick="downloadFile(event)">Download</button>
<button type="button" class="btn btn-outline" href="#" onclick="createProjectPR(event)">Create Pull Request</button>
<button type="button" class="btn btn-outline" href="#" onclick="emailFile(event)">Email</button>
</div>

</body>
Expand Down
30 changes: 30 additions & 0 deletions js/formDataToJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,37 @@ async function downloadFile(event) {
link.click();
}

// Triggers email(mailtolink)
async function emailFile(event) {
event.preventDefault();

const codeJson = document.getElementById("json-result").value
const jsonObject = JSON.parse(codeJson);

try {
const cleanData = {...jsonObject};
delete cleanData.submit;

const jsonString = JSON.stringify(cleanData, null, 2);

const subject = "Code.json generator Results";
const body = `Hello,\n\nHere are the code.json results:\n\n${jsonString}\n\nThank you!`;

const recipients = ["opensource@cms.hhs.gov"];

const mailtoLink = `mailto:${recipients}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;

window.location.href = mailtoLink;

console.log("Email client opened");
} catch {
console.error("Error preparing email:", error);
showNotificationModal("Error preparing email. Please try again or copy the data manually.", 'error');
}
}

window.createCodeJson = createCodeJson;
window.copyToClipboard = copyToClipboard;
window.downloadFile = downloadFile;
window.createProjectPR = createProjectPR;
window.emailFile = emailFile;
Loading