Skip to content

Commit ec51a51

Browse files
committed
updated
1 parent 0838596 commit ec51a51

File tree

9 files changed

+1882
-113
lines changed

9 files changed

+1882
-113
lines changed

community-server.js

Lines changed: 268 additions & 106 deletions
Large diffs are not rendered by default.

community.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,20 @@ <h4>Online Users (24)</h4>
11361136
<script src="scripts/dashboard.js"></script>
11371137
<script src="scripts/api.js"></script>
11381138
<script src="scripts/auth.js"></script>
1139-
<script src="scripts/community.js"></script>
1139+
<script src="scripts/community-new.js"></script>
11401140
<script src="scripts/community-integration.js"></script>
1141+
1142+
<!-- Initialize Community System -->
1143+
<script>
1144+
document.addEventListener('DOMContentLoaded', function() {
1145+
// Initialize Community Manager
1146+
const communityManager = new CommunityManager();
1147+
1148+
// Make it globally available for debugging
1149+
window.communityManager = communityManager;
1150+
1151+
console.log('✅ Community system initialized');
1152+
});
1153+
</script>
11411154
</body>
11421155
</html>

node_modules/.package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"express": "^4.21.2",
1717
"jsonwebtoken": "^9.0.2",
1818
"multer": "^1.4.5-lts.1",
19-
"socket.io": "^4.8.1"
19+
"socket.io": "^4.8.1",
20+
"uuid": "^11.1.0"
2021
},
2122
"devDependencies": {
2223
"nodemon": "^3.0.2"
@@ -29,5 +30,13 @@
2930
"programming"
3031
],
3132
"author": "OpenRockets Team",
32-
"license": "MIT"
33+
"license": "MIT",
34+
"repository": {
35+
"type": "git",
36+
"url": "git+https://github.com/NekshaDeSilva/openrockets.me.git"
37+
},
38+
"bugs": {
39+
"url": "https://github.com/NekshaDeSilva/openrockets.me/issues"
40+
},
41+
"homepage": "https://github.com/NekshaDeSilva/openrockets.me#readme"
3342
}

scripts/api.js

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,46 @@ class OpenRocketsAPI {
247247
return await this.request(`/api/search?${params}`);
248248
}
249249

250+
// Community API Methods
251+
async getPosts(filters = {}) {
252+
const params = new URLSearchParams(filters);
253+
return await this.request(`/api/community/posts?${params}`);
254+
}
255+
256+
async createPost(postData, imageFiles = []) {
257+
const formData = new FormData();
258+
formData.append('data', JSON.stringify(postData));
259+
260+
imageFiles.forEach((file, index) => {
261+
formData.append(`image_${index}`, file);
262+
});
263+
264+
return await this.request('/api/community/posts', {
265+
method: 'POST',
266+
body: formData,
267+
headers: {
268+
'Authorization': this.token ? `Bearer ${this.token}` : ''
269+
}
270+
});
271+
}
272+
273+
async likePost(postId) {
274+
return await this.request(`/api/community/posts/${postId}/like`, {
275+
method: 'POST'
276+
});
277+
}
278+
279+
async getComments(postId) {
280+
return await this.request(`/api/community/posts/${postId}/comments`);
281+
}
282+
283+
async addComment(postId, content) {
284+
return await this.request(`/api/community/posts/${postId}/comments`, {
285+
method: 'POST',
286+
body: JSON.stringify({ content })
287+
});
288+
}
289+
250290
// Utility methods
251291
isAuthenticated() {
252292
return !!this.token && !!this.currentUser;
@@ -298,6 +338,97 @@ class OpenRocketsAPI {
298338
return emailRegex.test(email);
299339
}
300340

341+
showNotification(message, type = 'info') {
342+
console.log(`[${type.toUpperCase()}] ${message}`);
343+
344+
// Create notification element
345+
const notification = document.createElement('div');
346+
notification.className = `notification notification-${type}`;
347+
notification.innerHTML = `
348+
<div class="notification-content">
349+
<i class="fas fa-${type === 'success' ? 'check-circle' : type === 'error' ? 'exclamation-circle' : 'info-circle'}"></i>
350+
<span>${message}</span>
351+
</div>
352+
<button class="notification-close" onclick="this.parentElement.remove()">
353+
<i class="fas fa-times"></i>
354+
</button>
355+
`;
356+
357+
// Style the notification
358+
Object.assign(notification.style, {
359+
position: 'fixed',
360+
top: '20px',
361+
right: '20px',
362+
padding: '12px 16px',
363+
backgroundColor: this.getNotificationColor(type),
364+
color: 'white',
365+
borderRadius: '8px',
366+
boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
367+
zIndex: '10000',
368+
display: 'flex',
369+
alignItems: 'center',
370+
gap: '12px',
371+
maxWidth: '400px',
372+
animation: 'slideInRight 0.3s ease',
373+
fontFamily: 'Inter, sans-serif'
374+
});
375+
376+
document.body.appendChild(notification);
377+
378+
// Auto-remove after 4 seconds
379+
setTimeout(() => {
380+
if (notification.parentNode) {
381+
notification.style.animation = 'slideOutRight 0.3s ease';
382+
setTimeout(() => notification.remove(), 300);
383+
}
384+
}, 4000);
385+
}
386+
387+
getNotificationColor(type) {
388+
switch (type) {
389+
case 'success': return '#10b981';
390+
case 'error': return '#ef4444';
391+
case 'warning': return '#f59e0b';
392+
default: return '#3b82f6';
393+
}
394+
}
395+
396+
showLoadingSpinner(element, show = true) {
397+
if (!element) return;
398+
399+
if (show) {
400+
element.style.position = 'relative';
401+
element.style.opacity = '0.6';
402+
403+
const spinner = document.createElement('div');
404+
spinner.className = 'loading-spinner-overlay';
405+
spinner.innerHTML = `
406+
<div class="loading-spinner">
407+
<i class="fas fa-spinner fa-spin"></i>
408+
</div>
409+
`;
410+
411+
Object.assign(spinner.style, {
412+
position: 'absolute',
413+
top: '0',
414+
left: '0',
415+
right: '0',
416+
bottom: '0',
417+
display: 'flex',
418+
alignItems: 'center',
419+
justifyContent: 'center',
420+
backgroundColor: 'rgba(255,255,255,0.8)',
421+
zIndex: '100'
422+
});
423+
424+
element.appendChild(spinner);
425+
} else {
426+
element.style.opacity = '';
427+
const spinner = element.querySelector('.loading-spinner-overlay');
428+
if (spinner) spinner.remove();
429+
}
430+
}
431+
301432
validatePassword(password) {
302433
return password.length >= 6;
303434
}

0 commit comments

Comments
 (0)