Skip to content

Commit

Permalink
update js
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Nov 4, 2024
1 parent aec80df commit 395ae79
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Elements
const qrDataElement = document.querySelector("#qr-data");
const qrCodeListElement = document.querySelector("#qr-code-list");
const validateUrlElement = document.querySelector("#validate-url");
Expand All @@ -6,9 +7,11 @@ const validCountElement = document.querySelector("#valid-count");
const invalidCountElement = document.querySelector("#invalid-count");
const downloadZipButton = document.querySelector("#download-zip");

// Variables
let validUrls = [];
let invalidUrls = [];

// Functions
function isValidUrl(url) {
try {
new URL(url);
Expand Down Expand Up @@ -60,12 +63,11 @@ function updateCountElements() {
}
}

qrDataElement.addEventListener("input", generateQrCodes);
validateUrlElement.addEventListener("change", () => {
function updateURLs() {
generateQrCodes();

updateCountElements();
});
}

async function downloadQrCodesAsZip() {
const zip = new JSZip();
Expand All @@ -85,4 +87,7 @@ async function downloadQrCodesAsZip() {
downloadLink.click();
}

// Events
qrDataElement.addEventListener("input", generateQrCodes);
validateUrlElement.addEventListener("change", updateURLs);
downloadZipButton.addEventListener("click", downloadQrCodesAsZip);

0 comments on commit 395ae79

Please sign in to comment.