-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
118 lines (102 loc) · 4.74 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
106
107
108
109
110
111
112
113
114
115
116
117
118
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="css/all.css" />
<meta name="viewport" content="width=device-width" />
</head>
<body>
<div id="navbar" class="fixed-top">
<div class="container">
<div class="row">
<div class="col-6 col-lg-2-5">
<a class="navbar-brand" href="/"><img src="images/logo-temp.png" alt="logo" style="max-height:45px;margin-top:5px;"></a>
</div>
</div>
</div>
</div>
<div id="navSpacer"></div>
<div class="homeSection" style="padding-top:20px">
<div class="container">
<div class="row">
<div class="col">
<div class="row">
<div class="col-xl-8 offset-xl-2">
<div id="currentDay"></div>
</div>
<hr style="margin-top:20px;" />
<div class="row" id="variants"></div>
</div>
</div>
</div>
</div>
</div>
<div class="homeSection alt">
<div class="container">
<h2>About the Verse of the Day</h2>
<p>This is a free service by <a href="https://livecs.org">Live Church Solutions</a>. All verse images on this site are original creations and avaiable for use on social media, websites, newsletters and elsewhere absolutely free of charge, and without citation required.</p>
<a href="preview.html">View all Days</a> | <a href="https://github.com/ChurchApps/votdcontent">Source Data</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script>
const getDateFromDay = (year, day) => {
var date = new Date(year, 0);
return new Date(date.setDate(day));
}
const getDayOfYear = () => {
let params = new URLSearchParams(window.location.search);
if (params.has("day")) return parseInt(params.get("day"));
else {
var now = new Date();
var start = new Date(now.getFullYear(), 0, 0);
var diff = now - start;
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
return day;
}
}
const fetchData = () => {
const day = getDayOfYear();
fetch("https://churchapps.github.io/VotdContent/v1/verses.json")
.then(resp => resp.json())
.then(data => populate(data, day));
}
const populateCurrentDay = (verse) => {
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
const day = getDateFromDay(new Date().getFullYear(), verse.day);
var displayDay = day.toLocaleDateString("en-US", options);
let result = '<iframe style="float:right" src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fchurchapps.github.io%2FVotdContent%2Findex.html%3Fday%3D' + verse.day + '&layout=button&size=large&width=77&height=28" width="77" height="28" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>'
+ '<h1>Verse of the Day - <span>' + displayDay + '</span></h1>'
+ '<h3>' + verse.reference + ' - <span>' + verse.text + '</span></h3>'
+ '<img src="v1/' + verse.day + '/720p/16x9.jpg" alt="' + verse.reference + '" class="img-fluid" />'
document.getElementById('currentDay').innerHTML = result;
}
const populateVariants = (verse) => {
let sizes = ["16x9", "1x1", "9x16"]
let result = [];
sizes.forEach(s => {
result.push('<div class="col">'
+ '<div><b>' + s + '</b></div>'
+ '<div><a href="v1/' + verse.day + '/720p/' + s + '.jpg">High Res</a> | '
+ '<a href="v1/' + verse.day + '/' + s + '.jpg">Max Res</a></div>'
+ '<img src="v1/' + verse.day + '/thumbs/' + s + '.jpg" alt="' + s + '" class="img-fluid" />'
+ '</div>')
});
document.getElementById('variants').innerHTML = result.join("");
}
const populateMeta = (verse) => {
let result = '<meta property="og:description" content="' + verse.reference + ' - ' + verse.text.replace('"', '') + '"/>'
+ '<meta property="og:image" content="v1/' + verse.day + '/720p/16x9.jpg"/>';
document.head.innerHTML += result;
document.title = verse.reference + ' - Verse of the Day';
}
const populate = (data, day) => {
const verse = data.verses[day - 1]
populateCurrentDay(verse, day);
populateVariants(verse)
populateMeta(verse)
}
fetchData();
</script>
</body>
</html>