-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (89 loc) · 2.78 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
box-sizing: border-box;
margin: 0;
}
body {
background: #eee;
}
.calendar {
margin-top: 40px;
box-shadow: 0 0 15px rgba(0,0,0,0.2);
padding: 0.5em;
text-align: center;
width: 100%;
height: auto;
word-break: break-all;
}
.element {
text-align: center;
background: #e83c34;
color: #fff;
display: inline-block;
width: calc(20% - 0.1em);
margin: 0.09em;
overflow: hidden;
height: 65px;
box-sizing: border-box;
cursor: pointer;
}
.today {
background: #3f51b5;
}
.today:after {
padding: 1em;
content: "bugün";
left: 0;
top: 0;
}
.calendar-title {
background: #f44336;
height: 50px;
text-align: #f00;
color: #fff;
top: 0;
left: 0;
text-indent: 2em;
line-height: 50px;
box-shadow: 0 0 15px rgba(0,0,0,0.5);
position: fixed;
width: 100%;
}
</style>
</head>
<body>
<div class="calendar-title"></div>
<div class="calendar"></div>
<script>
const tarih = new Date();
const suan = new Date();
let getDayName = i => ["pazar", "pazartesi", "salı", "çarşamba", "perşembe", "cuma", "cumartesi"][i];
let getMonthName = i => ["ocak", "şubat", "mart", "nisan", "mayıs", "haziran", "temmuz", "agustos", "eylul", "ekim", "kasım", "aralık"][i];
let dayCount = () => new Date(suan.getFullYear(), suan.getMonth() + 1, 0).getDate();
let calendar = document.querySelector(".calendar");
document.querySelector(".calendar-title").innerHTML = getMonthName(tarih.getMonth()) + " " + tarih.getFullYear();
for (let i = 1; i <= dayCount(); i++) {
tarih.setDate(i);
let createDiv = document.createElement("div");
if (suan.getDate() === tarih.getDate())
createDiv.className = "today element";
else
createDiv.className = "element";
createDiv.dataset.day = getDayName(tarih.getDay());
createDiv.dataset.date = tarih.getDate();
createDiv.dataset.month = getMonthName(tarih.getMonth());
createDiv.onclick = function () {
alert(this.dataset.month + " " + this.dataset.day + " " + this.dataset.date)
};
createDiv.innerHTML = tarih.getDate() + "</br>" + getDayName(tarih.getDay());
calendar.appendChild(createDiv);
}
</script>
</script>
</body>
</html>