-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
184 lines (159 loc) · 5.63 KB
/
script.js
File metadata and controls
184 lines (159 loc) · 5.63 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// // Can check whether needed to implement later
// // https://github.com/fireship-io/flamethrower
// import flamethrower from 'flamethrower-router';
// const router = flamethrower();
// // also maybe implement a password system so that not anyone can join the groupme? perhaps in groupme moderation for the group or in site itself
// Get the elements with class="column"
var elements = document.getElementsByClassName("column");
// Image grid system
var i;
// Full-width images
function one() {
for (i = 0; i < elements.length; i++) {
elements[i].style.msFlex = "100%"; // IE10
elements[i].style.flex = "100%";
}
}
// Two images side by side
function two() {
for (i = 0; i < elements.length; i++) {
elements[i].style.msFlex = "50%"; // IE10
elements[i].style.flex = "50%";
}
}
// Four images side by side
function four() {
for (i = 0; i < elements.length; i++) {
elements[i].style.msFlex = "25%"; // IE10
elements[i].style.flex = "25%";
}
}
function toggleDarkMode() {
var element = document.body;
element.classList.toggle("dark-mode");
}
// Image Modal functionality - wait for DOM to load
document.addEventListener('DOMContentLoaded', function() {
// Get DOM elements after they're loaded
const imageModal = document.getElementById('imageModal');
const modalImage = document.getElementById('modalImage');
const closeBtn = document.querySelector('.close-btn');
const currentImageNum = document.getElementById('currentImageNum');
const totalImages = document.getElementById('totalImages');
// Image data array
const images = [
'images/photos/1.jpg',
'images/photos/2.jpg',
'images/photos/3.jpg',
'images/photos/4.jpg',
'images/photos/5.jpg',
'images/photos/6.jpg',
'images/photos/7.png',
'images/photos/8.png',
'images/photos/9.png',
'images/photos/10.jpg',
'images/photos/11.jpg',
'images/photos/12.jpg',
'images/photos/13.jpg'
];
let currentImageIndex = 0;
// Set total images count
if (totalImages) {
totalImages.textContent = images.length;
}
// Mobile gallery elements
const mobileGalleryImage = document.getElementById('mobileGalleryImage');
const mobileCurrentImageNum = document.getElementById('mobileCurrentImageNum');
const mobileTotalImages = document.getElementById('mobileTotalImages');
// Set mobile gallery total
if (mobileTotalImages) {
mobileTotalImages.textContent = images.length;
}
// Mobile gallery click handler
if (mobileGalleryImage) {
mobileGalleryImage.addEventListener('click', function() {
currentImageIndex = (currentImageIndex + 1) % images.length;
updateMobileGallery();
});
}
// Update mobile gallery display
function updateMobileGallery() {
if (mobileGalleryImage && mobileCurrentImageNum) {
mobileGalleryImage.src = images[currentImageIndex];
mobileGalleryImage.alt = `Engineering Club Photo ${currentImageIndex + 1}`;
mobileCurrentImageNum.textContent = currentImageIndex + 1;
}
}
// Initialize mobile gallery
updateMobileGallery();
// Open modal with specific image
window.openModal = function(imageIndex) {
currentImageIndex = imageIndex;
showImage(imageIndex);
imageModal.classList.add('active');
document.body.style.overflow = 'hidden'; // Prevent background scrolling
}
// Close modal
window.closeModal = function() {
imageModal.classList.remove('active');
document.body.style.overflow = 'auto'; // Restore scrolling
}
// Show specific image
function showImage(index) {
if (index >= 0 && index < images.length && modalImage) {
modalImage.src = images[index];
modalImage.alt = `Engineering Club Photo ${index + 1}`;
if (currentImageNum) {
currentImageNum.textContent = index + 1;
}
}
}
// Change image (next/previous)
window.changeImage = function(direction) {
currentImageIndex += direction;
// Wrap around if at boundaries
if (currentImageIndex >= images.length) {
currentImageIndex = 0;
} else if (currentImageIndex < 0) {
currentImageIndex = images.length - 1;
}
showImage(currentImageIndex);
}
// Keyboard navigation
document.addEventListener('keydown', function(event) {
if (imageModal && imageModal.classList.contains('active')) {
switch(event.key) {
case 'Escape':
window.closeModal();
break;
case 'ArrowLeft':
window.changeImage(-1);
event.preventDefault();
break;
case 'ArrowRight':
window.changeImage(1);
event.preventDefault();
break;
}
}
});
// Close modal when clicking outside the image
if (imageModal) {
imageModal.addEventListener('click', function(event) {
if (event.target === imageModal) {
window.closeModal();
}
});
}
// Close button functionality
if (closeBtn) {
closeBtn.addEventListener('click', window.closeModal);
}
// Prevent modal content clicks from closing modal
const modalContent = document.querySelector('.modal-content');
if (modalContent) {
modalContent.addEventListener('click', function(event) {
event.stopPropagation();
});
}
});