-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommunities.html
More file actions
263 lines (239 loc) · 12.3 KB
/
communities.html
File metadata and controls
263 lines (239 loc) · 12.3 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Communities - Mitra Mandali</title>
<link rel="stylesheet" href="styles.css">
<style>
.social-links {
display: none;
margin-top: 10px;
background-color: #f4f4f4;
padding: 10px;
border-radius: 5px;
}
.social-links.visible {
display: block;
}
.social-links a {
display: block;
margin: 5px 0;
color: #007bff;
text-decoration: none;
}
.social-links a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="blogs.html">Blogs</a></li>
<li><a href="communities.html" class="active">Communities</a></li>
<li><a href="explore.html">Explore</a></li>
<li><a href="library.html">Library</a></li>
<li><a href="help.html">Help</a></li>
<li><a href="login.html">Login</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
</nav>
</header>
<section id="communities">
<h1>Join a Community</h1>
<a href="#" id="add-community-btn" class="add-community-btn">+ Create New Community</a>
<div id="new-community-form" style="display:none;">
<form id="create-community-form">
<input type="text" id="community-name" placeholder="Community Name" required>
<textarea id="community-description" placeholder="Community Description" required></textarea>
<button type="submit">Create Community</button>
<button type="button" id="cancel-community-form">Cancel</button>
</form>
</div>
<div id="read-more-dialog" class="dialog">
<div class="dialog-content">
<h2 id="dialog-title"></h2>
<p id="dialog-description"></p>
<button id="close-dialog">Close</button>
</div>
</div>
<div id="dialog-overlay" class="dialog-overlay"></div>
<div class="community-cards" id="community-cards">
<div class="card" data-community-id="startup-enthusiasts">
<h2>Lalbagh Reads</h2>
<p>Reading community at Lalbagh</p>
<a href="https://linktr.ee/lalbaghreads" class="btn read-more" data-description="Reading community at Lalbagh, BLR🌿
We meet every Sunday from 10am - 1pm🌸
Get a book to read! 📖">Read More</a>
<div class="community-card-actions">
<button class="join-btn">Join</button>
</div>
<div class="social-links">
<h3>Community Social Links</h3>
<a href="https://linktr.ee/lalbaghreads" target="_blank">Linktr.ee Profile</a>
<a href="https://www.instagram.com/lalbaghreads/" target="_blank">Instagram</a>
<a href="https://www.facebook.com/lalbaghreads" target="_blank">Facebook</a>
</div>
</div>
<div class="card" data-community-id="photography-lovers">
<h2>Photography Lovers</h2>
<p>Connect with Bangalore's photography community and share your best clicks.</p>
<a href="#" class="btn read-more" data-description="Photography Lovers is a vibrant community where you can share your best shots, participate in photo walks, and learn from professionals.">Read More</a>
<div class="community-card-actions">
<button class="join-btn">Join</button>
</div>
<div class="social-links">
<h3>Community Social Links</h3>
<a href="https://www.instagram.com/blr_photo_lovers" target="_blank">Instagram</a>
<a href="https://www.facebook.com/groups/bangalorephotography" target="_blank">Facebook Group</a>
<a href="https://discord.gg/photographycommunity" target="_blank">Discord Server</a>
</div>
</div>
<div class="card" data-community-id="bangalore-book-club">
<h2>Bangalore Book Club</h2>
<p>A place for book lovers to discuss literature, share recommendations, and meet like-minded individuals.</p>
<a href="#" class="btn read-more" data-description="The Bangalore Book Club offers monthly meetups to discuss selected books, share insights, and enjoy themed gatherings.">Read More</a>
<div class="community-card-actions">
<button class="join-btn">Join</button>
</div>
<div class="social-links">
<h3>Community Social Links</h3>
<a href="https://www.meetup.com/bangalore-book-club" target="_blank">Meetup Group</a>
<a href="https://www.goodreads.com/group/show/bangalore-book-club" target="_blank">Goodreads Group</a>
<a href="https://www.instagram.com/bangalore.bookclub" target="_blank">Instagram</a>
</div>
</div>
</div>
</section>
<script>
// Get references to key elements
const addCommunityBtn = document.getElementById('add-community-btn');
const newCommunityForm = document.getElementById('new-community-form');
const createCommunityForm = document.getElementById('create-community-form');
const cancelCommunityFormBtn = document.getElementById('cancel-community-form');
const communityCards = document.getElementById('community-cards');
const dialog = document.getElementById('read-more-dialog');
const dialogOverlay = document.getElementById('dialog-overlay');
const dialogTitle = document.getElementById('dialog-title');
const dialogDescription = document.getElementById('dialog-description');
const closeDialogBtn = document.getElementById('close-dialog');
// Show new community form
addCommunityBtn.addEventListener('click', (e) => {
e.preventDefault();
newCommunityForm.style.display = 'block';
});
// Cancel new community form
cancelCommunityFormBtn.addEventListener('click', () => {
newCommunityForm.style.display = 'none';
createCommunityForm.reset();
});
// Close dialog
closeDialogBtn.addEventListener('click', () => {
dialog.classList.remove('active');
dialogOverlay.classList.remove('active');
});
// Attach Join and Delete Listeners to Community Cards
function attachCommunityCardListeners(card) {
const joinBtn = card.querySelector('.join-btn');
const deleteBtn = card.querySelector('.delete-btn');
const readMoreBtn = card.querySelector('.read-more');
const socialLinks = card.querySelector('.social-links');
// Join button functionality
joinBtn.addEventListener('click', () => {
if (!joinBtn.classList.contains('joined')) {
joinBtn.textContent = 'Joined';
joinBtn.classList.add('joined');
const tickSpan = document.createElement('span');
tickSpan.textContent = '✓';
tickSpan.classList.add('joined-tick');
joinBtn.appendChild(tickSpan);
// Show social links when joined
if (socialLinks) {
socialLinks.classList.add('visible');
}
}
});
// Delete button functionality (only for dynamically created communities)
if (deleteBtn) {
deleteBtn.addEventListener('click', () => {
const communityId = card.getAttribute('data-community-id');
const originalCommunities = [
'startup-enthusiasts',
'photography-lovers',
'bangalore-book-club'
];
if (!originalCommunities.includes(communityId)) {
card.remove();
} else {
alert('This community cannot be deleted.');
}
});
}
// Re-attach read more functionality
readMoreBtn.addEventListener('click', (e) => {
e.preventDefault();
dialogTitle.textContent = readMoreBtn.previousElementSibling.previousElementSibling.textContent;
dialogDescription.textContent = readMoreBtn.dataset.description;
dialog.classList.add('active');
dialogOverlay.classList.add('active');
});
}
// When creating a new community, add social links section
createCommunityForm.addEventListener('submit', (e) => {
e.preventDefault();
const communityName = document.getElementById('community-name').value;
const communityDescription = document.getElementById('community-description').value;
const newCommunityCard = document.createElement('div');
newCommunityCard.classList.add('card');
const communityId = communityName.toLowerCase().replace(/\s+/g, '-');
newCommunityCard.setAttribute('data-community-id', communityId);
newCommunityCard.innerHTML = `
<h2>${communityName}</h2>
<p>${communityDescription}</p>
<a href="#" class="btn read-more" data-description="Description of ${communityName}">Read More</a>
<div class="community-card-actions">
<button class="join-btn">Join</button>
<button class="delete-btn">Delete</button>
</div>
<div class="social-links">
<h3>Community Social Links</h3>
<input type="text" placeholder="Instagram Link" class="social-input">
<input type="text" placeholder="Facebook Link" class="social-input">
<input type="text" placeholder="Discord/Other Link" class="social-input">
<button class="save-social-links">Save Links</button>
</div>
`;
communityCards.appendChild(newCommunityCard);
// Attach event listeners to new buttons
attachCommunityCardListeners(newCommunityCard);
// Add functionality to save social links
const saveLinksBtn = newCommunityCard.querySelector('.save-social-links');
const socialInputs = newCommunityCard.querySelectorAll('.social-input');
const socialLinksContainer = newCommunityCard.querySelector('.social-links');
saveLinksBtn.addEventListener('click', () => {
// Clear existing links
const existingLinks = socialLinksContainer.querySelectorAll('a');
existingLinks.forEach(link => link.remove());
// Add new links
socialInputs.forEach(input => {
if (input.value.trim() !== '') {
const link = document.createElement('a');
link.href = input.value;
link.textContent = input.placeholder.replace(' Link', '');
link.target = '_blank';
socialLinksContainer.insertBefore(link, saveLinksBtn);
}
});
});
// Reset and hide form
createCommunityForm.reset();
newCommunityForm.style.display = 'none';
});
// Initial attachment of listeners to existing community cards
document.querySelectorAll('.card').forEach(attachCommunityCardListeners);
</script>
</body>
</html>