-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathindex.html
105 lines (92 loc) · 3.35 KB
/
index.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
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Perl Advent Calendar</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
}
.container h1 {
color: #333;
}
.container p {
color: #666;
}
</style>
<script>
const today = new Date();
const month = today.getMonth() + 1; // JavaScript months are 0-11
const day = today.getDate();
// Redirect directly to the calendar in December and January.
if (month === 12 || month === 1 ) {
const year = month === 1 ? today.getFullYear() - 1 : today.getFullYear();
window.location.href = `/${year}`;
}
// Based on:
// Count Down - Annual Occasions Script
// Visit http://rainbow.arch.scriptmania.com/scripts/
// for this script and many more
// Enter the occasion's MONTH (1-12) and DAY (1-31):
const theOccasion = new Date(today.getFullYear(), 12, 1);
// Customize text to show before and on occasion. Follow grammar below:
const beforeOccasionText = 'left until the next Perl Advent Calendar';
const onOccasionText = 'The Calendar should be posted shortly.';
const monthText = ['Jan','Feb','Mar','April','May','June','July','Aug','Sep','Oct','Nov','Dec'];
theOccasion.setMonth(theOccasion.getMonth() - 1); // change to 0-11 month format
// show date of occasion
const showDate = `(${monthText[theOccasion.getMonth()]}. ${theOccasion.getDate()})`;
const oneDay = 1000 * 60 * 60 * 24;
let calculateDiff = Math.ceil((theOccasion.getTime() - today.getTime()) / oneDay);
if (calculateDiff < 0) { // if already passed
const nextYearToday = new Date();
nextYearToday.setFullYear(today.getFullYear() + 1);
calculateDiff = Math.ceil((nextYearToday.getTime() - today.getTime()) / oneDay + calculateDiff);
}
// Display message accordingly
const pluralDayOrNot = calculateDiff === 1 ? 'day' : 'days';
let str;
if (calculateDiff > 0) {
str = `There are ${calculateDiff} ${pluralDayOrNot} ${beforeOccasionText} ${showDate}`;
}
else if (calculateDiff === 0) {
str = onOccasionText;
}
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelector('.countdown').textContent = str;
})
</script>
</head>
<body>
<div class="container">
<h1>Welcome to the Perl Advent Calendar!</h1>
<p class="countdown">
<noscript>This year's Perl Advent Calendar is still a ways away.</noscript>
</p>
<p>
In the meantime, you might like to check our
<a href="archives.html">archives</a>, or
<a href="FAQ-submit.html">help us create it</a>.
</p>
<p>
<a href="contact.html">Contact</a> ·
<a href="FAQ.html">FAQ</a>
</p>
</div>
</body>
</html>