-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmy_history.html
More file actions
219 lines (164 loc) · 6.31 KB
/
my_history.html
File metadata and controls
219 lines (164 loc) · 6.31 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
<html>
<head>
<style>
#container {
width:960px;
margin:0 auto;
text-align:center;
}
.tab {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
}
/* Float the list items side by side */
.tab li {
float: left;
}
/* Style the links inside the list items */
.tab li a {
display: inline-block;
color: #000;
text-align: center;
text-decoration: none;
padding: 14px 16px;
font-size: 17px;
transition:0.3s;
}
/* Style the tab content */
.tabcontent {
display: none;
background-color:rgb(0,154,200);
padding: 6px 12px;
color:#fff;
}
ul.tab li.current{
background-color: rgb(0,154,200);
color: #222;
}
.tabcontent.current {
display: block;
}
</style>
<link rel="stylesheet" type="text/css" href="css/main.css">
<script src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<!-- 커스터마이징한 axiosInstace 들고있는 파일 -->
<script src="/custom_axios.js"></script>
</head>
<body>
<div id="container">
<h2>내 도전 이력</h2>
<ul class="tab">
<li class="current" data-tab="tab1"><a href="#">진행중</a></li>
<li data-tab="tab2"><a href="#">완료</a></li>
<li data-tab="tab3"><a href="#">중도포기</a></li>
</ul>
<div id="tab1" class="tabcontent current">
<ul id='ongoing_projects'>
</ul>
</div>
<div id="tab2" class="tabcontent">
<ul id='complete_projects'>
</ul>
</div>
<div id="tab3" class="tabcontent">
<ul id='fail_projects'>
</ul>
</div>
</div>
<div id="container">
<h2>내 날짜별 인증 내역</h2>
인증 확인 날짜 <input id='date' type="date">
<ul id='proofList'>
</ul>
</div>
<script>
// date input의 변경 이벤트
$('#date').change(function () {
// 날짜가 변경되면 해당 날짜의 내 인증 내역을 가져오기
axiosInstance.get('/my_info', {
params : {
'proof_date' : $('#date').val()
}
})
.then(function (res) {
console.log(res)
$('#proofList').empty()
res.data.data.proofs.forEach(proof => {
let proofLi = $(`
<li>
${proof.project.title} / ${proof.content}
</li>
`)
$('#proofList').append(proofLi)
});
})
.catch(function (err) {
console.log(err)
})
})
// 날짜 변경 이벤트가 세팅 되고 나면
// 오늘 날짜를 yyyy-MM-dd 양식으로 받아와서
let now = new Date()
let year = now.getFullYear()
let month = String(now.getMonth()+1).padStart(2, '0')
let day = String(now.getDate()).padStart(2, '0')
let today = `${year}-${month}-${day}`
// $('#date') 의 값으로 세팅. => 값이 변경되니까 서버에서 로딩.
$('#date').val(today)
// 코드로 값을 수정하면 change 이벤트 발생 X. => change 이벤트 강제 실행
$('#date').trigger('change')
</script>
<script>
$(function() {
$('ul.tab li').click(function() {
var activeTab = $(this).attr('data-tab');
$('ul.tab li').removeClass('current');
$('.tabcontent').removeClass('current');
$(this).addClass('current');
$('#' + activeTab).addClass('current');
})
});
</script>
<script>
axiosInstance.get('/my_info', {
params: {
'project_status':'ALL'
}
})
.then(function (res) {
res.data.data.projects.ONGOING.forEach(project => {
let projectLi = $(`
<li project_id=${project.id}>
<span>${project.title}</span>
</li>
`)
$('#ongoing_projects').append(projectLi)
});
res.data.data.projects.COMPLETE.forEach(project => {
let projectLi = $(`
<li project_id=${project.id}>
<span>${project.title}</span>
</li>
`)
$('#complete_projects').append(projectLi)
});
res.data.data.projects.FAIL.forEach(project => {
let projectLi = $(`
<li project_id=${project.id}>
<span>${project.title}</span>
</li>
`)
$('#fail_projects').append(projectLi)
});
})
.catch(function (error) {
// 실패시 error의 응답에 담긴 message를 얼럿으로
alert(error.response.data.message)
})
</script>
</body>
</html>