Implement month scrolling

This commit is contained in:
NovaFox161
2018-03-06 10:43:41 -06:00
parent 15e2232179
commit 917b818bdb
2 changed files with 21 additions and 6 deletions
@@ -101,14 +101,14 @@
<table id="calendar" style="border-color: #ef0813;" border="#ef0813" cellpadding="4"
cellspacing="0">
<tbody>
<tr style="height: 30px;">
<th class="nav"><</th>
<tr style="height: 50px;">
<th class="nav" onclick="previousMonth()"><</th>
<th></th>
<th></th>
<th id="month-display"></th>
<th></th>
<th></th>
<th class="nav">></th>
<th class="nav" onclick="nextMonth()">></th>
</tr>
<tr style="height: 40px;">
<th>Sunday</th>
@@ -1,3 +1,9 @@
var calendar = {
todaysDate: new Date(),
selectedDate: new Date()
};
function getMonthName(index) {
return ['January', 'February',
'March', 'April',
@@ -8,13 +14,22 @@ function getMonthName(index) {
}
function init() {
var today = new Date();
setMonth({date: today});
setMonth({date: calendar.todaysDate});
}
function setMonth(parameters) {
var date = parameters.date;
document.getElementById("month-display").innerHTML = getMonthName(date.getMonth()) + ' ' + date.getFullYear();
}
function previousMonth() {
calendar.selectedDate.setMonth(calendar.selectedDate.getMonth() - 1);
setMonth({date: calendar.selectedDate});
}
function nextMonth() {
calendar.selectedDate.setMonth(calendar.selectedDate.getMonth() + 1);
setMonth({date: calendar.selectedDate});
}