Skip to content

Commit

Permalink
fix bug where more and more QR codes get added to page when user clic…
Browse files Browse the repository at this point in the history
…ks "Generate" button; scroll QR codes into view after clicking "Generate" button.
  • Loading branch information
ksze committed Feb 11, 2025
1 parent cfc28ba commit f8db953
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,13 @@ <h4 data-i18n="verificationOTP">Verification OTP:</h4>
document.getElementById('label2').textContent = name1;

document.getElementById('qrSection').style.display = 'block';

const qrcode1node = document.getElementById('qrcode1');
const qrcode2node = document.getElementById('qrcode2');
for (node of [qrcode1node, qrcode2node]) {
while (node.lastElementChild) {
node.removeChild(node.lastElementChild);
}
}
new QRCode(document.getElementById('qrcode1'), {
text: totp1.toString(),
width: 200,
Expand All @@ -249,6 +255,12 @@ <h4 data-i18n="verificationOTP">Verification OTP:</h4>
correctLevel: QRCode.CorrectLevel.H
});

// Smooth scroll to qrcode1 with animation
document.getElementById('qrcode1').scrollIntoView({
behavior: 'smooth',
block: 'center'
});

updateOtpDisplay();
interval = setInterval(updateOtpDisplay, 1000);
});
Expand Down

0 comments on commit f8db953

Please sign in to comment.