-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
101 lines (88 loc) · 3.73 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
document.addEventListener('DOMContentLoaded', function () {
// Function to open the QR Code modal
function openQRCodeModal(event) {
event.stopPropagation();
const qrModal = document.getElementById('qrCodeModal');
if (qrModal) {
closeAllModals();
qrModal.classList.add('active');
document.body.classList.add('modal-open');
} else {
console.error('QR Code Modal not found!');
}
}
// Function to close the QR Code modal
function closeQRCodeModal() {
const qrModal = document.getElementById('qrCodeModal');
if (qrModal) {
qrModal.classList.remove('active');
document.body.classList.remove('modal-open');
} else {
console.error('QR Code Modal not found!');
}
}
// Function to open the Mempool Tiny Data modal
function openMempoolTinyDataModal(event) {
event.stopPropagation();
const mempoolModal = document.getElementById('mempoolTinyDataModal');
if (mempoolModal) {
closeAllModals();
mempoolModal.classList.add('active');
document.body.classList.add('modal-open');
} else {
console.error('Mempool Tiny Data Modal not found!');
}
}
// Function to close the Mempool Tiny Data modal
function closeMempoolTinyDataModal() {
const mempoolModal = document.getElementById('mempoolTinyDataModal');
if (mempoolModal) {
mempoolModal.classList.remove('active');
document.body.classList.remove('modal-open');
} else {
console.error('Mempool Tiny Data Modal not found!');
}
}
// Function to close all modals
function closeAllModals() {
document.querySelectorAll('.description-modal.active').forEach(function (modal) {
modal.classList.remove('active');
});
document.body.classList.remove('modal-open');
}
// Attach global functions to the window object
window.openQRCodeModal = openQRCodeModal;
window.closeQRCodeModal = closeQRCodeModal;
window.openMempoolTinyDataModal = openMempoolTinyDataModal;
window.closeMempoolTinyDataModal = closeMempoolTinyDataModal;
// Handle clicks outside of modals to close them
window.addEventListener('click', function (event) {
const qrModal = document.getElementById('qrCodeModal');
const mempoolModal = document.getElementById('mempoolTinyDataModal');
const activeDescriptionModal = document.querySelector('.description-modal.active');
if (qrModal && qrModal.classList.contains('active') && !qrModal.contains(event.target)) {
closeQRCodeModal();
}
if (mempoolModal && mempoolModal.classList.contains('active') && !mempoolModal.contains(event.target)) {
closeMempoolTinyDataModal();
}
if (activeDescriptionModal && !activeDescriptionModal.contains(event.target) && !event.target.closest('.image-box')) {
activeDescriptionModal.classList.remove('active');
document.body.classList.remove('modal-open');
}
});
// Attach click event to lightning icon specifically
const lightningIcon = document.querySelector('.lni-bolt-2');
if (lightningIcon) {
lightningIcon.addEventListener('click', openQRCodeModal);
}
// Attach click event to block height and fee rate spans
const feeRateSpan = document.getElementById('fee-rate');
const blockHeightSpan = document.getElementById('block-height');
if (feeRateSpan) {
feeRateSpan.addEventListener('click', openMempoolTinyDataModal);
}
if (blockHeightSpan) {
blockHeightSpan.addEventListener('click', openMempoolTinyDataModal);
}
});