-
Notifications
You must be signed in to change notification settings - Fork 2
/
weeklyrank.html
64 lines (56 loc) · 2.63 KB
/
weeklyrank.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>주간 랭킹</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
<script>
var currentDay = new Date();
var theYear = currentDay.getFullYear();
var theMonth = currentDay.getMonth();
var theDate = currentDay.getDate();
var theDayOfWeek = currentDay.getDay();
var thisWeek = [];
for(var i=0; i<7; i++) {
var resultDay = new Date(theYear, theMonth, theDate + (i - theDayOfWeek));
var yyyy = resultDay.getFullYear();
var mm = Number(resultDay.getMonth()) + 1;
var dd = resultDay.getDate();
mm = String(mm).length === 1 ? '0' + mm : mm;
dd = String(dd).length === 1 ? '0' + dd : dd;
thisWeek[i] = yyyy + '-' + mm + '-' + dd;
}
// thisWeek : ['2023-02-19', '2023-02-20', '2023-02-21', '2023-02-22',
// '2023-02-23', '2023-02-24', '2023-02-25']
$(document).ready(function () {
$.ajax({
type: 'GET',
url: `http://127.0.0.1:8000/note/rank/weekly?startdate=${thisWeek[0]}&lastdate=${thisWeek[6]}`,
success: (result) => {
$("#rank").html("");
for (let i = 0; i < result.length; i++) {
const note = result[i];
$("#rank").append(
$(`<li class="list-group-item">
${note.title}
</li>`)
)
}
}
})
})
</script>
</head>
<body>
<main>
<div class="container">
<p>주간 랭킹</p>
<ul class="list-group list-group-flush" id="rank">
</ul>
</div>
</main>
</body>
</html>