-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
92 lines (82 loc) · 2.68 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Stoic Exercises</title>
<meta name="description" content="Each day, view a one of the Stoic exercises compiled by Massimo Pigliucci and Greg Lopez">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=PT+Serif" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">
<style>
[v-cloak] {
display: none
}
body {
font-family: 'PT Serif', serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #222;
}
.content {
padding: 25px;
}
</style>
</head>
<body>
<div id="container" class="" v-cloak>
<section class="hero is-dark">
<div class="hero-body">
<div class="container">
<h1 class="title">
{{ active.name }}
</h1>
<h2 class="subtitle">
{{ today }}
</h2>
</div>
</div>
</section>
<section class="content">
<blockquote>
{{ active.quote }}
<cite>{{ active.source }}</cite>
</blockquote>
</section>
</div>
<script src="https://cdn.jsdelivr.net/gh/knrz/CSV.js@3.6.4/csv.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
<script>
fetch('./exercises.csv')
.then(function(response) {
return response.text();
})
.then(function(csvString) {
var data = new CSV(csvString, { header: true, cellDelimiter: ';' }).parse();
var app = new Vue({
el: '#container',
data: {
exercises: data
},
computed: {
active: function() {
var millisecondsDay = 24 * 60 * 60 * 1000;
var start = new Date(2018, 0, 1);
var today = new Date();
start.setHours(0,0,0);
today.setHours(0,0,0);
var daysSinceStart = Math.round(Math.abs((start.getTime() - today.getTime()) / millisecondsDay));
var active = daysSinceStart % 24;
return this.exercises[active];
},
today: function() {
var date = new Date();
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
return date.toLocaleDateString('en-GB', options);
}
}
});
}).catch(console.error);
</script>
</body>
</html>