Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26-Copy to clipboard by button #34

Merged
merged 3 commits into from
Nov 8, 2024
Merged
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
9 changes: 7 additions & 2 deletions addon/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ function acknowledgeUser(bestMatchSection) {
}

function showCoverLetter(coverLetter) {
const copyButton = document.createElement("button");
copyButton.innerHTML = "Copy to Clipboard";
copyButton.classList.add("btn", "btn-primary", "mt-2");
copyButton.onclick = function () {
copyToClipboard(coverLetter);
};
const div = document.createElement("div");
div.innerHTML = `<div class="mt-2">
<p>Cover Letter:</p>
Expand All @@ -56,6 +62,7 @@ function showCoverLetter(coverLetter) {
clArea.style.resize = "none";

const mainDiv = document.getElementById("popup");
mainDiv.appendChild(copyButton);
mainDiv.appendChild(div);
mainDiv.appendChild(clArea);
}
Expand Down Expand Up @@ -90,10 +97,8 @@ generateCLButton.addEventListener("click", async function () {
loader.hidden = true;
if (response.ok) {
const data = await response.json();
// COPY TO CLIPBOARD
acknowledgeUser(data.bestMatchSection);
showCoverLetter(data.coverLetter);
copyToClipboard(data.coverLetter);
} else {
console.error("Network response was not ok.");
}
Expand Down