-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
102 lines (88 loc) · 3.49 KB
/
script.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
102
document.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.category-button');
const backButton = document.getElementById('back-button');
const galleryItems = document.querySelectorAll('.gallery-item');
const gallery = document.querySelector('.gallery');
const modal = document.getElementById('imageModal');
const fullImage = document.getElementById('fullImage');
const imageDescription = document.getElementById('imageDescription');
const downloadLink = document.getElementById('downloadLink');
const closeModalButton = document.getElementById('closeModalButton');
const searchInput = document.getElementById('Search');
buttons.forEach(button => {
button.addEventListener('click', () => {
const category = button.getAttribute('data-category');
filterImages(category);
});
});
backButton.addEventListener('click', () => {
filterImages('all');
});
closeModalButton.addEventListener('click', () => {
modal.style.display = 'none';
gallery.style.display = 'flex';
});
searchInput.addEventListener('input', () => {
const searchTerm = searchInput.value.toLowerCase();
searchImages(searchTerm);
});
function filterImages(category) {
galleryItems.forEach(item => {
if (item.getAttribute('data-category') === category || category === 'all') {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
}
function searchImages(term) {
galleryItems.forEach(item => {
const description = item.querySelector('.description').textContent.toLowerCase();
if (description.includes(term)) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
}
window.showImageModal = function (imgElement) {
const src = imgElement.src;
const description = imgElement.nextElementSibling ? imgElement.nextElementSibling.textContent : '';
fullImage.src = src;
imageDescription.textContent = description;
modal.style.display = 'flex';
gallery.style.display = 'none';
downloadLink.href = src;
};
filterImages('all');
});
document.addEventListener('DOMContentLoaded', () => {
const dynamicText = document.getElementById('dynamic-text');
const textContent = dynamicText.textContent;
dynamicText.classList.remove('hidden'); // Show the text
let index = 0;
let adding = true;
function typeEffect() {
if (adding) {
if (index < textContent.length) {
dynamicText.textContent += textContent.charAt(index);
index++;
} else {
adding = false;
setTimeout(typeEffect, 1000); // Pause before starting to delete
return;
}
} else {
if (index > 0) {
dynamicText.textContent = textContent.substring(0, index - 1);
index--;
} else {
adding = true;
setTimeout(typeEffect, 1000); // Pause before starting to type again
return;
}
}
setTimeout(typeEffect, 200);
}
setTimeout(typeEffect, 1000); // Start typing after a delay
});