-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
357 lines (316 loc) · 9.6 KB
/
index.html
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chime - Social Media</title>
<style>
/* General Reset */
body, h1, p, button, input, textarea {
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
}
body {
background-color: #f5f7fa;
color: #333;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
min-height: 100vh;
padding-top: 80px;
transition: background-color 0.3s ease-in-out;
}
/* Header */
header {
width: 100%;
background-color: #4CAF50;
padding: 15px 20px;
position: fixed;
top: 0;
left: 0;
z-index: 100;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
header h1 {
color: white;
font-size: 1.8em;
font-weight: bold;
letter-spacing: 1px;
}
.btn {
background-color: #4CAF50;
color: white;
padding: 12px 25px;
border-radius: 30px;
border: none;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #45a049;
}
/* Sign-Up & Log-In Form */
#signup-form, #login-form {
margin-top: 120px;
width: 100%;
max-width: 500px;
background-color: white;
border-radius: 8px;
padding: 30px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
text-align: center;
opacity: 0;
transform: translateY(30px);
transition: opacity 0.5s, transform 0.5s;
}
#signup-form.active, #login-form.active {
opacity: 1;
transform: translateY(0);
}
#signup-form input, #login-form input {
width: 100%;
padding: 15px;
margin-bottom: 20px;
border-radius: 8px;
border: 1px solid #ddd;
font-size: 16px;
transition: border-color 0.3s ease;
}
#signup-form input:focus, #login-form input:focus {
border-color: #4CAF50;
outline: none;
}
/* Profile Section */
#profile {
display: none;
margin-top: 20px;
text-align: center;
width: 90%;
max-width: 500px;
}
#profile img {
width: 80px;
height: 80px;
border-radius: 50%;
margin-bottom: 10px;
}
/* Post Section */
#create-post {
margin-top: 20px;
text-align: center;
width: 90%;
max-width: 600px;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
#create-post textarea {
width: 100%;
padding: 15px;
border-radius: 8px;
border: 1px solid #ddd;
font-size: 16px;
margin-bottom: 10px;
resize: vertical;
}
#posts {
width: 90%;
max-width: 800px;
margin-top: 20px;
}
.post {
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
padding: 15px;
margin-bottom: 20px;
display: flex;
flex-direction: column;
gap: 10px;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.post:hover {
transform: translateY(-5px);
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}
.post h3 {
margin-bottom: 10px;
font-size: 1.2em;
color: #4CAF50;
}
.post p {
font-size: 1em;
line-height: 1.6;
color: #333;
}
.post img, .post video {
max-width: 100%;
border-radius: 10px;
}
.post-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
.like-comment-section {
display: flex;
gap: 20px;
align-items: center;
font-size: 14px;
color: #4CAF50;
}
/* Media Upload */
input[type="file"], textarea {
width: 100%;
margin: 10px 0;
padding: 10px;
border-radius: 8px;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<header>
<h1>Chime</h1>
<div>
<button class="btn" id="logout-btn" onclick="logOut()" style="display:none;">Log Out</button>
</div>
</header>
<!-- Sign Up Form with Dropdown Effect -->
<div id="signup-form">
<input type="email" id="signup-email" placeholder="Email" required />
<input type="password" id="signup-password" placeholder="Password" required />
<button class="btn" onclick="signUp()">Sign Up</button>
</div>
<!-- Log In Form -->
<div id="login-form">
<input type="email" id="login-email" placeholder="Email" required />
<input type="password" id="login-password" placeholder="Password" required />
<button class="btn" onclick="logIn()">Log In</button>
</div>
<!-- Profile Section -->
<div id="profile">
<img id="profile-pic" src="default.jpg" alt="Profile Picture" />
<button class="btn" onclick="loadProfile()">Edit Profile</button>
</div>
<!-- Create Post Section -->
<div id="create-post">
<textarea id="post-text" placeholder="What's on your mind?"></textarea>
<input type="file" id="video-input" accept="video/*" onchange="uploadVideo(event)" />
<button class="btn" onclick="createPost()">Post</button>
</div>
<!-- Displaying Posts -->
<div id="posts"></div>
<!-- Firebase SDK -->
<script src="https://www.gstatic.com/firebasejs/11.0.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/11.0.2/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/11.0.2/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/11.0.2/firebase-storage.js"></script>
<script>
// Firebase Configuration
const firebaseConfig = {
apiKey: "AIzaSyD-xHxtA45RLADysSa2PuYyunH1bk3C18I",
authDomain: "gigibi.firebaseapp.com",
projectId: "gigibi",
storageBucket: "gigibi.appspot.com",
messagingSenderId: "491236320445",
appId: "1:491236320445:web:8f709c515c221551de43d4",
measurementId: "G-VFHBRGKN0C"
};
// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);
const db = firebase.firestore();
const storage = firebase.storage();
const auth = firebase.auth();
// Sign Up Function
async function signUp() {
const email = document.getElementById("signup-email").value;
const password = document.getElementById("signup-password").value;
try {
await auth.createUserWithEmailAndPassword(email, password);
alert("Signed Up Successfully!");
document.getElementById("signup-form").style.display = "none";
document.getElementById("login-form").style.display = "none";
} catch (error) {
alert(error.message);
}
}
// Log In Function
async function logIn() {
const email = document.getElementById("login-email").value;
const password = document.getElementById("login-password").value;
try {
await auth.signInWithEmailAndPassword(email, password);
alert("Logged In Successfully!");
document.getElementById("login-form").style.display = "none";
} catch (error) {
alert(error.message);
}
}
// Log Out Function
function logOut() {
auth.signOut();
document.getElementById("login-form").style.display = "block";
}
// Create Post Function
async function createPost() {
const user = auth.currentUser;
const text = document.getElementById("post-text").value;
const mediaFile = document.getElementById("video-input").files[0];
let mediaUrl = "";
if (mediaFile) {
const mediaRef = storage.ref().child("posts/" + mediaFile.name);
await mediaRef.put(mediaFile);
mediaUrl = await mediaRef.getDownloadURL();
}
const postData = {
text: text,
username: user.email,
mediaUrl: mediaUrl,
createdAt: firebase.firestore.FieldValue.serverTimestamp(),
};
await db.collection("posts").add(postData);
document.getElementById("post-text").value = "";
document.getElementById("video-input").value = "";
loadPosts();
}
// Load Posts Function
async function loadPosts() {
const postsContainer = document.getElementById("posts");
postsContainer.innerHTML = "";
const querySnapshot = await db.collection("posts").orderBy("createdAt", "desc").get();
querySnapshot.forEach((doc) => {
const post = doc.data();
const postElement = document.createElement("div");
postElement.classList.add("post");
postElement.innerHTML = `
<h3>${post.username}</h3>
<p>${post.text}</p>
${post.mediaUrl ? `<img src="${post.mediaUrl}" alt="Post Media" />` : ""}
`;
postsContainer.appendChild(postElement);
});
}
// Load Profile
function loadProfile() {
const user = auth.currentUser;
if (user) {
document.getElementById("profile").style.display = "block";
document.getElementById("profile-pic").src = "default.jpg"; // Add logic for actual profile image upload
}
}
// Initialize View
window.onload = function() {
loadPosts();
loadProfile();
}
</script>
</body>
</html>