Files
resume/calendar.html
T
2024-08-17 16:18:50 -06:00

252 lines
10 KiB
HTML

<!doctype html>
<html lang="en_US">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>Some calendar thing</title>
<style>
html, body {
background-color: #000;
color: #ccc;
font-family: "Consolas", monospace;
margin: 0;
padding: 0;
width: 100%;
}
table {
border: 1px solid #888;
border-collapse: collapse;
margin: 2.5rem auto;
overflow: hidden;
}
tbody tr:hover {
background-color: rgba(128, 64, 0, 0.5);
}
th {
vertical-align: bottom;
}
th.year {
font-size: x-large;
font-weight: bold;
vertical-align: middle;
}
td {
padding: 0.25rem;
text-align: center;
width: 40px;
}
td.today span {
border: 2px solid #fff;
border-radius: 1rem;
padding: 0.25rem;
}
.d28,
.d29,
.d30,
.d31 {
color: #000;
}
.d28 {
background-color: #faa;
}
.d29 {
background-color: #fe8;
}
.d30 {
background-color: #8c8;
}
.d31 {
background-color: #88f;
}
.today {
color: #fff;
}
</style>
</head>
<body>
<main id="main">
<table>
<thead>
<tr>
<th class="year" colspan="5"><span>Year</span></th>
<th class="col-1"></th>
<th class="col-2"></th>
<th class="col-3"></th>
<th class="col-4"></th>
<th class="col-5"></th>
<th class="col-6"></th>
<th class="col-0"></th>
</tr>
</thead>
<tbody>
<tr>
<td><span>1</span></td>
<td><span>8</span></td>
<td><span>15</span></td>
<td><span>22</span></td>
<td class="d29"><span>29</span></td>
<td class="col-1"><span>Mon</span></td>
<td class="col-2"><span>Tue</span></td>
<td class="col-3"><span>Wed</span></td>
<td class="col-4"><span>Thu</span></td>
<td class="col-5"><span>Fri</span></td>
<td class="col-6"><span>Sat</span></td>
<td class="col-0"><span>Sun</span></td>
</tr>
<tr>
<td><span>2</span></td>
<td><span>9</span></td>
<td><span>16</span></td>
<td><span>23</span></td>
<td class="d30"><span>30</span></td>
<td class="col-2"><span>Tue</span></td>
<td class="col-3"><span>Wed</span></td>
<td class="col-4"><span>Thu</span></td>
<td class="col-5"><span>Fri</span></td>
<td class="col-6"><span>Sat</span></td>
<td class="col-0"><span>Sun</span></td>
<td class="col-1"><span>Mon</span></td>
</tr>
<tr>
<td><span>3</span></td>
<td><span>10</span></td>
<td><span>17</span></td>
<td><span>24</span></td>
<td class="d31"><span>31</span></td>
<td class="col-3"><span>Wed</span></td>
<td class="col-4"><span>Thu</span></td>
<td class="col-5"><span>Fri</span></td>
<td class="col-6"><span>Sat</span></td>
<td class="col-0"><span>Sun</span></td>
<td class="col-1"><span>Mon</span></td>
<td class="col-2"><span>Tue</span></td>
</tr>
<tr>
<td><span>4</span></td>
<td><span>11</span></td>
<td><span>18</span></td>
<td><span>25</span></td>
<td></td>
<td class="col-4"><span>Thu</span></td>
<td class="col-5"><span>Fri</span></td>
<td class="col-6"><span>Sat</span></td>
<td class="col-0"><span>Sun</span></td>
<td class="col-1"><span>Mon</span></td>
<td class="col-2"><span>Tue</span></td>
<td class="col-3"><span>Wed</span></td>
</tr>
<tr>
<td><span>5</span></td>
<td><span>12</span></td>
<td><span>19</span></td>
<td><span>26</span></td>
<td></td>
<td class="col-5"><span>Fri</span></td>
<td class="col-6"><span>Sat</span></td>
<td class="col-0"><span>Sun</span></td>
<td class="col-1"><span>Mon</span></td>
<td class="col-2"><span>Tue</span></td>
<td class="col-3"><span>Wed</span></td>
<td class="col-4"><span>Thu</span></td>
</tr>
<tr>
<td><span>6</span></td>
<td><span>13</span></td>
<td><span>20</span></td>
<td><span>27</span></td>
<td></td>
<td class="col-6"><span>Sat</span></td>
<td class="col-0"><span>Sun</span></td>
<td class="col-1"><span>Mon</span></td>
<td class="col-2"><span>Tue</span></td>
<td class="col-3"><span>Wed</span></td>
<td class="col-4"><span>Thu</span></td>
<td class="col-5"><span>Fri</span></td>
</tr>
<tr>
<td><span>7</span></td>
<td><span>14</span></td>
<td><span>21</span></td>
<td class="d28"><span>28</span></td>
<td></td>
<td class="col-0"><span>Sun</span></td>
<td class="col-1"><span>Mon</span></td>
<td class="col-2"><span>Tue</span></td>
<td class="col-3"><span>Wed</span></td>
<td class="col-4"><span>Thu</span></td>
<td class="col-5"><span>Fri</span></td>
<td class="col-6"><span>Sat</span></td>
</tr>
</tbody>
</table>
</main>
<script>
const today = new Date();
const now = new Date();
now.setHours(0, 0, 0);
const currentYear = now.getFullYear();
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
let template = document.importNode(document.getElementsByTagName("table")[0], true);
const main = document.getElementById("main");
main.removeChild(main.firstElementChild);
for (let year = 0; year < 5; year++) {
const table = document.importNode(template, true); // Clone
now.setFullYear(currentYear + year);
table.querySelector(".year span").textContent = now.getFullYear();
for (let day = 0; day < 7; day++) {
for (let month = 0; month < 12; month++) {
now.setDate(1);
now.setMonth(month);
const future = new Date(now);
if (month + 1 >= months.length) {
future.setFullYear(currentYear + 1);
}
future.setMonth((month + 1) % months.length);
future.setTime(future.getTime() - 60000); // A minute before
if (now.getDay() == day) {
const div = document.createElement("div");
const span = document.createElement("span");
span.textContent = months[month];
div.appendChild(span);
table.querySelector(`thead .col-${day}`).appendChild(div);
div.classList.add(`d${future.getDate()}`);
div.setAttribute("title", `${future.getDate()} days`);
if (now.getFullYear() == today.getFullYear() && month == today.getMonth()) div.classList.add("today");
}
}
}
main.appendChild(table);
}
const todayTable = document.getElementsByTagName("table")[0];
todayTable.querySelector(".year").classList.add("today");
const row = todayTable.querySelector(`tbody tr:nth-child(${today.getDate() % 7})`);
const dateColumn = Math.ceil(today.getDate() / 7);
row.querySelector(`td:nth-child(${dateColumn})`).classList.add("today");
row.querySelector(`.col-${today.getDay()}`).classList.add("today");
</script>
</body>
</html>