-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
124 lines (109 loc) · 3.59 KB
/
index.html
File metadata and controls
124 lines (109 loc) · 3.59 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
<!DOCTYPE html>
<html lang="ne">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>नेपाली पात्रो 2082</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
.calendar th, .calendar td {
height: 80px;
vertical-align: middle;
font-size: 20px;
}
td.empty {
background-color: #f9f9f9;
}
</style>
</head>
<body>
<div class="container text-center mt-5">
<h1>नेपाली पात्रो 2082</h1>
<div class="d-flex justify-content-between align-items-center my-4">
<button class="btn btn-outline-primary" onclick="prevMonth()">अघिल्लो महिना</button>
<h3 id="monthYear" class="mb-0"></h3>
<button class="btn btn-outline-primary" onclick="nextMonth()">अर्को महिना</button>
</div>
<table class="table table-bordered calendar">
<thead>
<tr>
<th>आइत</th><th>सोम</th><th>मंगल</th><th>बुध</th><th>बिही</th><th>शुक्र</th><th>शनि</th>
</tr>
</thead>
<tbody id="calendarBody">
<!-- Calendar will be injected here -->
</tbody>
</table>
</div>
<script>
const months = [
{ name: "बैशाख", days: 31 },
{ name: "जेठ", days: 31 },
{ name: "असार", days: 32 },
{ name: "साउन", days: 31 },
{ name: "भदौ", days: 31 },
{ name: "आश्विन", days: 31 },
{ name: "कार्तिक", days: 30 },
{ name: "मंसिर", days: 29 },
{ name: "पुष", days: 30 },
{ name: "माघ", days: 29 },
{ name: "फागुन", days: 30 },
{ name: "चैत", days: 30 }
];
let startDays = [];
let currentMonth = 0;
function calculateStartDays() {
startDays = [];
let day = 1; // Baishakh 1 starts on Monday (1)
for (let i = 0; i < months.length; i++) {
startDays.push(day);
day = (day + months[i].days) % 7;
}
}
function renderCalendar(monthIndex) {
const month = months[monthIndex];
const daysInMonth = month.days;
const startDay = startDays[monthIndex];
document.getElementById("monthYear").innerText = `${month.name} 2082`;
const tbody = document.getElementById("calendarBody");
tbody.innerHTML = "";
let date = 1;
for (let i = 0; i < 6; i++) {
let row = document.createElement("tr");
for (let j = 0; j < 7; j++) {
let cell = document.createElement("td");
if (i === 0 && j < startDay) {
cell.classList.add("empty");
} else if (date <= daysInMonth) {
cell.innerText = convertToNepaliNumber(date);
date++;
} else {
cell.classList.add("empty");
}
row.appendChild(cell);
}
tbody.appendChild(row);
if (date > daysInMonth) break;
}
}
function prevMonth() {
if (currentMonth > 0) {
currentMonth--;
renderCalendar(currentMonth);
}
}
function nextMonth() {
if (currentMonth < 11) {
currentMonth++;
renderCalendar(currentMonth);
}
}
function convertToNepaliNumber(num) {
const nepaliNums = ['०','१','२','३','४','५','६','७','८','९'];
return String(num).split('').map(d => nepaliNums[d]).join('');
}
calculateStartDays();
renderCalendar(currentMonth);
</script>
</body>
</html>