-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
523 lines (462 loc) · 20.2 KB
/
index.html
File metadata and controls
523 lines (462 loc) · 20.2 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
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>4MEN</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
<!-- css 분리 -->
<link href="./css/common.css" rel="stylesheet">
<style>
body {
background-color: black;
color: white;
}
.btn {
background-color: transparent;
}
.main {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-top: 20px;
}
.logo {
margin: auto;
}
.introduce {
margin-bottom: 100px;
}
.goal {
margin-bottom: 50px;
}
.mycards {
width: 1300px;
margin: 30px auto 0px auto;
}
.card {
background-color: black;
}
.visitor {
text-align: center;
border: 1px solid white;
border-radius: 2px;
}
.name {
width: 130px;
margin-right: 30px;
}
.comment {
width: 1000px;
margin-right: 30px;
}
.password{
margin-right: 30px;
}
.form-floating>input {
background-color: transparent;
margin-right: 20px;
color: white;
}
.guestbook {
border: 1px solid white;
border-radius: 5px;
margin-bottom: 20px;
}
.guestbook_writing {
padding: 20px;
display: flex;
}
.guestbook_data {
padding: 20px;
margin-bottom: 200px;
display: flex;
flex-direction: column;
}
.guest_comment {
display: flex;
flex-direction: row;
margin-bottom: 20px;
}
.name_data {
width: 130px;
min-width: 130px;
margin-right: 30px;
}
.comment_data {
width: 100%;
margin-right: 10px;
}
.delete_comment{
width: 80px;
}
.guestbook_writing>button {
border-color: white;
color: white;
width: 80px;
height: 59px;
}
.modal {
color: black;
}
.card>img {
width: 250px;
height: 300px;
}
.timestamp {
font-size: 8pt;
}
</style>
<script type="module">
// Firebase SDK 라이브러리 가져오기
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
import { getFirestore } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
import { collection, addDoc, query, orderBy } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
import { getDocs, updateDoc, deleteDoc, doc ,getDoc} from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyBQNEBL9e782JBMk00D0ey3SamXVFnCyM0",
authDomain: "sparta-c0f81.firebaseapp.com",
projectId: "sparta-c0f81",
storageBucket: "sparta-c0f81.firebasestorage.app",
messagingSenderId: "1083054784111",
appId: "1:1083054784111:web:2c0007c2bb79f1ce97179a",
measurementId: "G-HSRZCTYE5T"
};
// Firebase 인스턴스 초기화
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
//멤버 등록
$('#saveTeam').click(async function () {
const imgurl = $('#image').val();
const name = $('#name').val();
const mbti = $('#mbti').val();
const goal = $('#goal').val();
const pros = $('#pros').val();
const cons = $('#cons').val();
const introduce = $('#introduce').val();
const short = $('#short').val();
const passwd = $('#passwd').val();
if (!passwd) {
return alert('비밀번호를 입력하시오')
}
const doc = {
imgurl, name, mbti, goal, pros, cons, introduce, id: new Date().getTime(), chara: short, passwd
};
await addDoc(collection(db, "members"), doc);
window.location.reload();
})
//멤버 로딩
$('#members').empty();
let mems = await getDocs(query(collection(db, "members"), orderBy('name', 'asc')));
mems.forEach((mem) => {
let row = mem.data();
let imgurl = row['imgurl'];
let name = row['name'];
let chara = row['chara'];
let id = mem.id;
let temp_html = `
<div class="col">
<div class="card custom-class" data-id="${id}">
<img src="${imgurl}" class="card-img-top" alt="...">
<div class="card-body">
<h5 style="color: white;" class="card-title">${name}</h5>
<p style="color: white;" class="card-text">${chara}</p>
</div>
</div>
</div>`;
$('#members').append(temp_html);
});
//멤버 버튼
$(".custom-class").click(function () {
let id = $(this).data("id")
let url = `./about.html?id=${id}`
location.href = url;
});
//방명록 버튼
$("#postingbtn").click(async function () {
let nickname = $('#nickname').val();
if (!nickname)
return alert('별명을 입력해주세요!');
let comment = $('#comment').val();
if (!comment)
return alert('코멘트을 입력해주세요!');
let cpasswd = $('#cpasswd').val();
if(!cpasswd)
return alert('비밀번호를 입력해주세요!');
let date = new Date();
let doc = {
'nickname': nickname,
'comment': comment,
'passwd' : cpasswd,
'date': date
};
await addDoc(collection(db, "guestbook"), doc);
window.location.reload();
});
//방명록 삭제버튼
$('#deleteButton').click(async function () {
let id = $("#commentid").val();
if(!id) {
console.log("삭제 오류")
return;
}
const docRef = doc(db, "guestbook", id)
const docSnap = await getDoc(docRef);
if (docSnap.exists()) {
if(docSnap.data()['passwd']==$('#commentPasswd').val()){
await deleteDoc(doc(db, "guestbook", id));
alert('삭제되었습니다');
window.location.reload();
}
else
return alert('비밀번호 오류');
} else {
console.log("조회 실패")
}
})
//방명록 로딩
$('#guestbook').empty();
let docs = await getDocs(query(collection(db, "guestbook"), orderBy('date', 'desc')));
docs.forEach((doc) => {
let row = doc.data();
let nickname = row['nickname'];
let comment = row['comment'];
let timestamp = formatDate(row['date'].toDate());
// let date = timestamp.toDate();
// console.log(date);
// let formattedDate = formatDate(date);
// console.log(formattedDate);
let temp_html = `
<div class="guest_comment">
<div class="name_data">
<p style="background-color: transparent; color: white;" class="form-control"
id="floatingInput">${nickname} <span class="timestamp"></br>${timestamp}</span></p>
</div>
<div class="comment_data">
<p style="background-color: transparent; color: white;" class="form-control"
id="floatingInput">${comment}</p>
</div>
<div class="delete_comment">
<button type="button" class="btn btn-danger comment-del" data-commentno="${doc.id}">삭제</button>
</div>
</div>`
$('#guestbook').append(temp_html);
});
$('.comment-del').click(function() {
$("#commentPasswd").val('');
$("#commentid").val($(this).data("commentno"));
$("#exampleModal2").modal("show");
})
function formatDate(date) {
let year = date.getFullYear();
let month = (date.getMonth() + 1).toString().padStart(2, '0'); // 월은 0부터 시작하므로 1을 더해줌
let day = date.getDate().toString().padStart(2, '0');
let hours = date.getHours().toString().padStart(2, '0');
let minutes = date.getMinutes().toString().padStart(2, '0');
let seconds = date.getSeconds().toString().padStart(2, '0');
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
}
$('#designed').click(function () {
alert('정준호, 장윤혁, 유은호, 이인학')
})
$("#addMemberBtn").click(function () {
$('#image').val('');
$('#name').val('');
$('#mbti').val('');
$('#goal').val('');
$('#pros').val('');
$('#cons').val('');
$('#introduce').val('');
$('#short').val('');
$('#passwd').val('');
$('#addMemberModal').modal('show');
})
</script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container px-5">
<a class="navbar-brand" href="./index.html">4MEN</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
</div>
</nav>
<div class="main" class="row gx-4 gx-lg-5 align-items-center my-5">
<div class="logo" class="col-lg-7"><img class="img-fluid rounded mb-4 mb-lg-0"
src="https://wixmp-fe53c9ff592a4da924211f23.wixmp.com/users/7e80959c-db9b-49d0-8bea-424646ddf06e/design-previews/577bbbd7-97eb-4470-9547-a2fbbc793098/1735198598239-thumbnail.jpeg"
alt="..."></div>
<div style="margin-right: 40px;" class="col-lg-5">
<div class="introduce">
<h1 class="font-weight-light">팀 소개</h1>
<p>백엔드의 미래를 향해 나아가는 네 남자의 여정! 이름에서 알 수 있듯이, 저희는 네 명의 열정 넘치는 남자들로 구성된 팀입니다. 백엔드 개발의 세계에서 우리의 꿈을 실현하고자 하는
공통된 목표로 뭉쳤습니다.</p>
</div>
<div class="goal">
<h1 class="font-weight-light">목표</h1>
<ol>
<li>기초 다지기</li>
<li>팀워크 강화</li>
<li>프로젝트 경험 쌓기</li>
<li>지속적인 학습 습관 형성</li>
</ol>
</div>
</div>
</div>
<div class="mycards">
<button id="addMemberBtn" style="border-color: white; margin: 0px 0px 20px 92%;" type="button" class="btn btn-primary">멤버 등록</button>
<div class="modal fade" id="addMemberModal" tabindex="-1" aria-labelledby="addMemberModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addMemberModalLabel">멤버 등록</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="iamge" class="col-form-label">사진:</label>
<input type="text" class="form-control" id="image">
</div>
<div class="mb-3">
<label for="name" class="col-form-label">이름:</label>
<input type="text" class="form-control" id="name">
</div>
<div class="mb-3">
<label for="mbti" class="col-form-label">mbti:</label>
<input type="text" class="form-control" id="mbti">
</div>
<div class="mb-3">
<label for="introduce" class="col-form-label">한 줄 소개:</label>
<input type="text" class="form-control" id="introduce">
</div>
<div class="mb-3">
<label for="short" class="col-form-label">짧은 소개:</label>
<input type="text" class="form-control" id="short">
</div>
<div class="mb-3">
<label for="goal" class="col-form-label">목표(포부):</label>
<textarea class="form-control" id="goal"></textarea>
</div>
<div class="mb-3">
<label for="pros" class="col-form-label">장점:</label>
<input type="text" class="form-control" id="pros">
</div>
<div class="mb-3">
<label for="cons" class="col-form-label">단점:</label>
<input type="text" class="form-control" id="cons">
</div>
<div class="mb-3">
<label for="passwd" class="col-form-label">패스워드:</label>
<input type="password" class="form-control" id="passwd">
</div>
</form>
</div>
<div class="modal-footer">
<button id="saveTeam" style="background-color: blue;" type="button"
class="btn btn-primary">등록</button>
<button style="background-color: gray;" type="button" class="btn btn-secondary"
data-bs-dismiss="modal">닫기</button>
</div>
</div>
</div>
</div>
<div id="members" class="row row-cols-1 row-cols-md-4 g-4">
<!-- 비동기 호출 -->
<a href="./about.html?id=0">
<div class="col">
<div class="card">
<img src="https://search.pstatic.net/sunny/?src=https%3A%2F%2Fst.depositphotos.com%2F1177973%2F3836%2Fi%2F450%2Fdepositphotos_38368579-stock-photo-little-kitten-isolated-on-white.jpg&type=a340"
class="card-img-top" alt="...">
<div class="card-body">
<h5 style="color: white;" class="card-title">유은호</h5>
<p style="color: white;" class="card-text">특징(한줄)</p>
</div>
</div>
</div>
</a>
</div>
<div>
<h4 class="visitor">Visitor</h4>
</div>
<div class="guestbook">
<div class="guestbook_writing">
<div class="name">
<div class="form-floating mb-3">
<input maxlength="6" id="nickname" type="email" class="form-control" placeholder="name@example.com">
<label for="nickname">닉네임</label>
</div>
</div>
<div class="comment">
<div class="form-floating mb-3">
<input maxlength="50" type="email" class="form-control" id="comment" placeholder="name@example.com">
<label for="comment">한마디</label>
</div>
</div>
<div class="password">
<div class="form-floating mb-3">
<input type="password" class="form-control" id="cpasswd" placeholder="name@example.com">
<label for="comment">비밀번호</label>
</div>
</div>
<button id="postingbtn" type="button" class="btn btn-outline-dark">등록</button>
</div>
<div class="guestbook_data" id="guestbook">
<div class="guest_comment">
<div class="name_data">
<p style="background-color: transparent; color: white;" class="form-control" id="floatingInput">
</p>
</div>
<div class="comment_data">
<p style="background-color: transparent; color: white;" class="form-control" id="floatingInput">
</p>
</div>
</div>
</div>
</div>
</div>
<footer class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container px-5">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<button id="designed" class="btn" class="nav-item"><a class="nav-link active" aria-current="page"
href="#!">Designed by</a></button>
</ul>
</div>
</div>
</footer>
<div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModal2Label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2">멤버 삭제</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="commentPasswd" class="col-form-label">패스워드:</label>
<input type="password" class="form-control" id="commentPasswd">
<input type="hidden" class="form-control" id="commentid">
</div>
</form>
</div>
<div class="modal-footer">
<button id="deleteButton" style="background-color: red;" type="button"
class="btn btn-primary">삭제</button>
<button style="background-color: gray;" type="button" class="btn btn-secondary"
data-bs-dismiss="modal">닫기</button>
</div>
</div>
</div>
</div>
</body>
</html>