-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodal.js
More file actions
61 lines (53 loc) · 1.76 KB
/
modal.js
File metadata and controls
61 lines (53 loc) · 1.76 KB
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
// Get the configure modal elements
const configureModal = document.getElementById('configureModal');
const configureBtn = document.getElementById('configure-btn');
const closeConfigureModalBtn = document.getElementsByClassName('close')[0];
// Get the FAQ modal elements
const faqModal = document.getElementById('faqModal');
const openFaqModalBtn = document.getElementById('openFaqModal');
const closeFaqModalBtn = document.getElementsByClassName('close')[1];
// Function to open a modal
function openModal(modal) {
modal.style.display = "block";
document.body.classList.add('no-scroll'); // Disable background scroll
}
// Function to close a modal
function closeModal(modal) {
modal.style.display = "none";
document.body.classList.remove('no-scroll'); // Enable background scroll
}
// Event listeners for configure modal
configureBtn.onclick = function () {
openModal(configureModal);
}
closeConfigureModalBtn.onclick = function () {
closeModal(configureModal);
const selectedUrl = feedSelector.value;
if (selectedUrl) {
fetchAndDisplayFeed(selectedUrl);
} else {
noFeedMessage.style.display = 'block';
}
}
// Event listeners for FAQ modal
openFaqModalBtn.onclick = function () {
openModal(faqModal);
}
closeFaqModalBtn.onclick = function () {
closeModal(faqModal);
}
// When the user clicks anywhere outside of the modals, close them
window.onclick = function (event) {
if (event.target == configureModal) {
closeModal(configureModal);
const selectedUrl = feedSelector.value;
if (selectedUrl) {
fetchAndDisplayFeed(selectedUrl);
} else {
noFeedMessage.style.display = 'block';
}
}
if (event.target == faqModal) {
closeModal(faqModal);
}
}