Skip to content

Commit

Permalink
Fixup. Format code with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jan 25, 2024
1 parent 9a492e4 commit 3251cfd
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pod/main/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,13 @@ document.addEventListener("hidden.bs.collapse", (e) => {
if (e.target.id === "qrcode") e.target.setAttribute("src", "");
});

if(document.getElementById("btn-download-qr-code") !== null){
document.getElementById("btn-download-qr-code").addEventListener('click', (e) => {
let nameOfDownload = e.target.dataset.slug + "-qrcode.png";
downloadImage(document.getElementById('qrcode').src, nameOfDownload);
});
if (document.getElementById("btn-download-qr-code") !== null) {
document
.getElementById("btn-download-qr-code")
.addEventListener("click", (e) => {
let nameOfDownload = e.target.dataset.slug + "-qrcode.png";
downloadImage(document.getElementById("qrcode").src, nameOfDownload);
});
}

/**
Expand All @@ -314,15 +316,12 @@ if(document.getElementById("btn-download-qr-code") !== null){
* @param nameOfDownload Given name for download
* @returns {Promise<void>}
*/
async function downloadImage(
imageSrc,
nameOfDownload = 'default.png',
) {
async function downloadImage(imageSrc, nameOfDownload = "default.png") {
const response = await fetch(imageSrc);
const blobImage = await response.blob();
const href = URL.createObjectURL(blobImage);

const anchorElement = document.createElement('a');
const anchorElement = document.createElement("a");
anchorElement.href = href;
anchorElement.download = nameOfDownload;

Expand Down

0 comments on commit 3251cfd

Please sign in to comment.