-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (68 loc) · 2.39 KB
/
index.js
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
let newDateFunction = new Date()
function randerDate(){
newDateFunction.setDate(1)
let day = newDateFunction.getDay()
let currentDate = new Date(
newDateFunction.getFullYear(),
newDateFunction.getMonth() + 1,0
).getDate() // to get the last date of current month
let prevDate = new Date(
newDateFunction.getFullYear(),
newDateFunction.getMonth(), 0
).getDate() // to get the last date of previous month
let addNext = new Date(newDateFunction.getFullYear(),
newDateFunction.getMonth() + 2, 0).getDate() + 7;
console.log(currentDate, prevDate, addNext);
let month = newDateFunction.getMonth()
let year = newDateFunction.getFullYear()
let monthArr = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
document.getElementById("month").innerHTML = monthArr[month] + " - " + year
let today = new Date()
let weekDay = today.getDay()
document.getElementById("date").innerHTML = today.toDateString()
document.querySelector(`.week :nth-child(${weekDay + 1})`).classList.add("active")
let DATES = ""
for(let x = day; x > 0; x--){
DATES += "<div class='prev'>" + (prevDate - x + 1) + "</div>"
}
for(let i = 1; i <= currentDate; i++){
if(i === today.getDate() && newDateFunction.getMonth() == today.getMonth() && newDateFunction.getFullYear() === today.getFullYear()){
DATES += "<div class='today'>" + i + "</div>"
}
else{
DATES += "<div>" + i + "</div>"
}
}
for(let k = 1; k <= addNext; k++){
if(k <= 1){
DATES += "<div class='next'>" + k + "</div>"
}
else{
break;
}
}
document.querySelector('.dates').innerHTML = DATES
}
function moveDate(para){
if(para == 'prev'){
newDateFunction.setMonth(newDateFunction.getMonth() - 1)
}
else if(para == 'next'){
newDateFunction.setMonth(newDateFunction.getMonth() + 1)
}
randerDate()
}
var modal = document.getElementById("myModal");
var btn = document.getElementById("submit-btn-amenity");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}