-
Notifications
You must be signed in to change notification settings - Fork 3
/
communties.php
275 lines (203 loc) · 7.49 KB
/
communties.php
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
264
265
266
267
268
269
270
271
272
273
274
275
<?php
session_start();
if (!isset($_SESSION["username"])) {
header("Location: ../user/login.php");
exit();
}
include("important/db.php");
$icon = "home";
?>
<?php
if(isset($_GET['trump'])) {
echo '<link rel="stylesheet" href="assets/css/trump.css">';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<title>Loogle+</title>
<link rel="stylesheet" href="assets/css/2013isamess.css">
<link rel="stylesheet" href="assets/css/2013indexres.css">
<link rel="stylesheet" href="assets/css/2013notes.css">
<link rel="stylesheet" href="assets/css/univesalcoolstuff.css">
<link rel="stylesheet" href="assets/css/headerfix.css">
<link rel="stylesheet" href="assets/css/community.css">
<link rel="icon"
type="image/png"
href="assets/important-images/fav.png" />
</head>
<body>
<?php require_once("inc/topstuffs.php")?>
<!-- I cannot spell -->
<div class="coumminity-con">
<div id="coms-you-in">
<div id="top">
<span id="info-top-stuff-1">
<h3 id="okayyoucanalsocryonapril22becausetrickydickdiedthatday">Communties you've joined</h3>
<button id="bobisshit" class="ihavestrongfeelingsagaistaman" type="submit">
<p>Create Community</p>
</button>
</span>
</div>
<div id="stuff-thingys">
</div>
<div id="whatwein">
</div>
</div>
<div id="coms-you-must-join-you-hippie">
<h3 id="trickydickdiedthatday">Recommended Communties</h3>
</div>
<div id="emerwhatthesigma">
</div>
<div>
<div class="create-community" class="modal">
<div class="modal-content">
<br>
<div id="top-stuff-2">
<p>What kind of community are you making?</p>
</div>
<div id="make-thing">
<span id="top-mt">
<p id="st1">Public</p>
</span>
<span id="text-mt">
<p id="st2">What do you want to call it?</p>
</span>
<span id="input-mt">
<textarea class="ta-mt" id="ci1"></textarea>
</span>
</div>
<div id="bottom-stuff">
<button id="menshallonlycryonthe5thofjune" class="ihavestrongfeelingsagaistaman" type="submit">
<p id="st3">Cancel</p>
</button>
<button id="loogleshutdownjune4th" class="ihavestrongfeelingsagaistaman" type="submit">
<p>Create Community</p>
</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script>
$(".create-community").hide();
function smoothReload(delay) {
$("body").fadeOut(delay, function() {
history.replaceState({}, document.title, window.location.pathname);
location.reload();
});
}
$("#menshallonlycryonthe5thofjune").click(function() {
$(".create-community").hide();
});
$("#bobisshit").click(function() {
$(".create-community").show();
});
$('#loogleshutdownjune4th').click(function() {
var communityName = $('#ci1').val();
if (communityName === '') {
alert('Please enter a community name.');
return;
}
$.ajax({
type: 'POST',
url: '<?php echo $siteurl?>/apiv1/create_community.php',
data: {
name: communityName,
creator_username: '<?php echo $_SESSION["username"]; ?>'
},
success: function(response) {
if (response.status === 'success') {
$(".create-community").hide();
smoothReload(500);
smoothRel
} else {
$(".create-community").hide();
smoothReload(500);
}
},
error: function(xhr, status, error) {
alert('Error: ' + error);
}
});
});
$.ajax({
url: '<?php echo $siteurl ?>/apiv1/fetch_all_coms.php?username=<?php echo $_SESSION["username"];?>',
type: 'GET',
dataType: 'json',
success: function(data) {
var container = $('#whatwein');
$.each(data, function(index, community) {
var card = $('<div class="card"></div>');
var image = $('<img class="card-img" src="<?php echo $siteurl ?>/apiv1/fetch_cover_api.php?cover=' + community.community_id + '" style="width: 30%;">');
card.append(image);
var name = $('<div class="card-name">' + community.name + '</div>');
card.append(name);
var membersArray = community.members_list.split(':');
var membersCount = membersArray.length - 1;
var members = $('<div class="card-members">' + membersCount + ' members</div>');
card.append(members);
card.on('click', function() {
window.location.href = '<?php echo $siteurl ?>/view_community.php?community_id=' + community.community_id;
});
container.append(card);
});
},
error: function(xhr, status, error) {
console.error('Error fetching community data: ' + error);
}
});
$.ajax({
url: '<?php echo $siteurl ?>/apiv1/fetch_all_coms.php',
type: 'GET',
dataType: 'json',
success: function(data) {
var container = $('#emerwhatthesigma');
$.each(data, function(index, community) {
var card = $('<div class="card-other"></div>');
var image = $('<img style="100%" class="card-img-other" src="<?php echo $siteurl ?>/apiv1/fetch_cover_api.php?cover=' + community.community_id + '" style="width: 50%;">');
card.append(image);
var name = $('<div class="card-name-other">' + community.name + '</div>');
card.append(name);
var membersArray = community.members_list.split(':');
var membersCount = membersArray.length - 1;
var membersText = membersCount === 1 ? ' member' : (membersCount > 1 ? ' members' : '0 members');
var postsText = community.total_posts === '1' ? ' post' : ' posts';
var space = ' ';
var members = $('<div class="card-members-other">' + membersCount + membersText + space + community.total_posts + postsText + '</div>');
card.append(members);
var image1 = $('<img style="100%" class="card-img-two" src="<?php echo $siteurl ?>/apiv1/fetch_cover_api.php?cover=' + community.community_id + '" style="width: 50%;">');
card.append(image1);
card.on('click', function() {
window.location.href = '<?php echo $siteurl ?>/view_community.php?community_id=' + community.community_id;
});
container.append(card);
});
},
error: function(xhr, status, error) {
console.error('Error fetching community data: ' + error);
}
});
$(document).ready(function() {
const sidebar = $('.sidebar');
const openSidebarButton = $('.com-c-icon');
let sidebarOpen = false;
openSidebarButton.on('click', function() {
if (!sidebarOpen) {
sidebar.css('transform', 'translateX(0)');
sidebarOpen = true;
} else {
sidebar.css('transform', 'translateX(-100%)');
sidebarOpen = false;
}
});
$(document).on('click', function(event) {
if (sidebarOpen && !$(event.target).closest('.coumminity-con').length && !$(event.target).is(openSidebarButton)) {
sidebar.css('transform', 'translateX(-100%)');
sidebarOpen = false;
}
});
});
</script>