-
Notifications
You must be signed in to change notification settings - Fork 0
/
memento-b.html
100 lines (86 loc) · 3.55 KB
/
memento-b.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
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Marcos Antonio Lopes</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@200;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/main.css">
<link href="data:image/x-icon;base64," rel="icon" type="image/x-icon" />
</head>
<body>
<div class="wrapper memento">
<h1 class="name">B Lopes</h1>
<div class="contact">
<p>marcos <span>[dot]</span> <a href="/memento-m.html">abil</a> <span>[at]</span> gmail <span>[dot]</span> com</p>
<!--
<p>Tauranga, NZ</p>
-->
<div class="links">
<p><a href="/memento-m.html">Memento M</a></p>
<p><a href="/memento-f.html">Memento F</a></p>
</div>
</div>
<div class="content">
<h2>Memento Mori - Decima Decembris MMXVIII</h2>
</div>
</div>
</body>
<script>
// bring everything to the smallest unit, from years to weeks
// the definition of week is 7 lived days so the in this case
// 1 week will only be counted at the end of 7 days
// there are still some issues, on the first year of living,
// but i am not planning on having more kids, so this will do
// https://stackoverflow.com/a/6117889
Date.prototype.getWeekNumber = function(){
var d = new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
var dayNum = d.getUTCDay() || 7;
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
return Math.floor((((d - yearStart) / 86400000) + 1)/7)
};
const now = new Date();
const birth = new Date(2018, 11, 10); // month starts at 0 = jan, 4 = may
const weeks = 100 * 52; // 100 years
const chunks = 10 * 52; // split into decades
let content = document.querySelector(".content");
for(var i = 0; i < weeks; i++) {
let year = parseInt(i / 52);
var row = null;
if (i % 52 == 0) {
row = document.createElement('div');
row.setAttribute("id", `year-${year}`);
row.classList.add('year');
content.appendChild(row);
} else {
row = document.querySelector(`#year-${year}`);
}
let item = document.createElement('span');
item.classList.add('week');
var week = new Date(birth.getTime());
week.setDate(week.getDate() + (i * 7));
// if past years, just fill the whole row otherwise deal with weeks
if (week.getFullYear() < now.getFullYear()) {
if (week < now) {
item.classList.add('week--filled');
}
} else if (week.getFullYear() == now.getFullYear()) {
if (week.getWeekNumber() + 1 < now.getWeekNumber()) { // offset so week is counted at the end
item.classList.add('week--filled');
} else if (week.getWeekNumber() + 1 == now.getWeekNumber()) {
item.classList.add('week--current');
}
}
row.appendChild(item);
// add roman labels
if ((i + 1) % chunks == 0 && i !== 0) {
let label = document.createElement('div');
label.classList.add('chunk--label');
content.appendChild(label);
}
}
</script>
</html>