-
Notifications
You must be signed in to change notification settings - Fork 0
/
otp.js
44 lines (38 loc) · 1.42 KB
/
otp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const showCodeLink = document.querySelector('.js-show-qr-code');
const showImageLink = document.querySelector('.js-show-qr-image');
const closeCopy = document.querySelector('.js-close-copy');
const closeModal = document.querySelector('.js-close-qr-modal');
const codeInput = document.querySelector('.js-qr-code-input');
const codeCopy = document.querySelector('.js-qr-hash');
const imageCont = document.querySelector('.js-image-cont');
const codeCont = document.querySelector('.js-code-cont');
const qrModal = document.querySelector('.js-qr-modal');
const copyModal = document.querySelector('.js-copy-modal');
function isMobile() {
return document.body.clientWidth <= 540;
}
codeCopy.addEventListener('click', function () {
codeInput.select();
codeInput.setSelectionRange(0, 99999);
document.execCommand('copy');
codeInput.setSelectionRange(0, 0);
copyModal.style.display = 'flex';
});
closeCopy.addEventListener('click', function () {
copyModal.style.display = 'none';
});
closeModal.addEventListener('click', function () {
qrModal.style.display = 'none';
});
showCodeLink.addEventListener('click', function () {
imageCont.style.display = 'none';
codeCont.style.display = 'block';
});
showImageLink.addEventListener('click', function () {
if (isMobile()) {
qrModal.style.display = 'flex';
} else {
codeCont.style.display = 'none';
imageCont.style.display = 'block';
}
});