This repository has been archived by the owner on Nov 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
122 lines (100 loc) · 4.08 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
119
120
121
122
<html>
<head>
<title>moin meista</title>
<link rel="stylesheet" href="https://bootswatch.com/4/superhero/bootstrap.css">
</head>
<body>
<!-- <{tag} {attribut}>{content}</{tag}> -->
<h1>Ferien-Countdown</h1>
<p id="ferienCounter">Loading dates...</p>
<h3 id="ferienArt">bis zu den Sommerferien! 📅</h3>
<br>
<select id="ferienAuswahl">
<option value="winterferien-">Winterferien</option>
<option value="osterferien-">Osterferien</option>
<option value="pfingstferien-">Pfingstferien</option>
<option value="sommerferien-">Sommerferien</option>
<option value="herbstferien-">Herbstferien</option>
<option value="weihnachtsferien-">Weihnachtsferien</option>
</select>
<br>
<br>
<table id="datenTabelle" border="">
<thead>
<tr>
<td>
<p>Ferien</p>
</td>
<td>
<p>Beginn</p>
</td>
<td>
<p>Ende</p>
</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<br>
<a href="https://github.com/lgh-ag/lghag.de">die toooolen Coder 🚀</a>
<script src="https://cdn.jsdelivr.net/npm/underscore@latest/underscore-umd-min.js"></script>
<script>
var json = "";
var obj = null;
var ferienDate = null;
function reqListener() {
json = this.responseText;
obj = JSON.parse(json);
selectChange();
getSeconds();
tabelleDatenHolen();
}
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://lgh-ag-cors.herokuapp.com/https://ferien-api.de/api/v1/holidays/TH/" + new Date().getFullYear());
oReq.setRequestHeader("x-requested-with", "lghag.de");
oReq.send();
function getSeconds() {
var currentDate = Date.now();
var milli = ferienDate - currentDate;
var abgezogen = 0;
var wochen = Math.floor(milli / 1000 / 60 / 60 / 24 / 7);
abgezogen = abgezogen + wochen * 1000 * 60 * 60 * 24 * 7;
var tage = Math.floor((milli - abgezogen) / 1000 / 60 / 60 / 24);
abgezogen = abgezogen + tage * 1000 * 60 * 60 * 24;
var stunden = Math.floor((milli - abgezogen) / 1000 / 60 / 60);
abgezogen = abgezogen + stunden * 1000 * 60 * 60;
var minuten = Math.floor((milli - abgezogen) / 1000 / 60);
abgezogen = abgezogen + minuten * 1000 * 60;
var sekunden = Math.floor((milli - abgezogen) / 1000);
document.getElementById("ferienCounter").innerText = "Das sind : " + wochen + " Wochen, " + tage + " Tage, " + stunden + " Stunden, " + minuten + " Minuten und " + sekunden + " Sekunden";
setTimeout(getSeconds, 1000);
}
var select = document.getElementById("ferienAuswahl");
function selectChange() {
ferienDate = Date.parse(_.where(obj, {"slug": select.value + new Date().getFullYear() + "-TH"})[0].start);
var ferien = _.where(obj, {"slug": select.value + new Date().getFullYear() + "-TH"})[0].name;
document.getElementById("ferienArt").innerHTML = "bis zu den " + ferien.slice(0, 1).toUpperCase() + ferien.slice(1) + "! 📅";
getSeconds();
}
select.onchange = selectChange;
function tabelleDatenHolen() {
var i;
for (i = 0; i < obj.length; i++) {
tabelleAusfuellen(i + 1, obj[i].name, new Date(obj[i].start), new Date(obj[i].end));
}
}
function tabelleAusfuellen(targetRow, cell1text, cell2text, cell3text) {
var table = document.getElementById("datenTabelle");
var row = table.insertRow(targetRow);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
cell1.innerHTML = cell1text.slice(0, 1).toUpperCase() + cell1text.slice(1);
cell2.innerHTML = cell2text.getDate() + "." + cell2text.getMonth() + "." + cell2text.getFullYear();
cell3.innerHTML = cell3text.getDate() + "." + cell3text.getMonth() + "." + cell3text.getFullYear();
}
</script>
</body>
</html>