This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
331 lines (260 loc) · 14.7 KB
/
main.js
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
const uhr = document.getElementById("uhr");
function ticken() {
var stunden, minuten, sekunden;
var StundenZahl, MinutenZahl, SekundenZahl;
var heute;
heute = new Date();
StundenZahl = heute.getHours();
MinutenZahl = heute.getMinutes();
SekundenZahl = heute.getSeconds();
stunden = StundenZahl + ":";
if (MinutenZahl < 10) {
minuten = "0" + MinutenZahl + ":";
} else {
minuten = MinutenZahl + ":";
}
if (SekundenZahl < 10) {
sekunden = "0" + SekundenZahl + " ";
} else {
sekunden = SekundenZahl + " ";
}
zeit = stunden + minuten + sekunden + " Uhr";
document.getElementById("uhrzeit").textContent = zeit;
window.setTimeout("ticken();", 10);
}
ticken();
mybutton = document.getElementById("myBtn");
window.onscroll = function() {
scrollFunction();
};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
async function Coronaabfrage() {
const Covidresponse = await fetch(
"https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json"
);
const Covidresponsejson = await Covidresponse.json();
const CovidresultSchleHol = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Schleswig-Holstein").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultHamburg = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Hamburg").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultNiedersachsen = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Niedersachsen").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultBremen = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Bremen").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultNRW = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Nordrhein-Westfalen").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultHessen = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Hessen").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultRheiPfal = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Rheinland-Pfalz").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultBawue = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Baden-Württemberg").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultBayern = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Bayern").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultSaarland = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Saarland").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultBerlin = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Berlin").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultBrandenburg = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Brandenburg").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultMeckPom = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Mecklenburg-Vorpommern").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultSachsen = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Sachsen").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultSachsenAnhalt = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Sachsen-Anhalt").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
const CovidresultThueringen = Covidresponsejson.features.filter((feature) => feature.attributes.Bundesland === "Thüringen").reduce((acc, val) => acc + val.attributes.AnzahlFall, 0);
document.getElementById("coronalist1").innerHTML = "Schleswig-Holstein: " + CovidresultSchleHol;
document.getElementById("coronalist2").innerHTML = "Hamburg: " + CovidresultHamburg;
document.getElementById("coronalist3").innerHTML = "Niedersachsen: " + CovidresultNiedersachsen;
document.getElementById("coronalist4").innerHTML = "Bremen: " + CovidresultBremen;
document.getElementById("coronalist5").innerHTML = "NRW: " + CovidresultNRW;
document.getElementById("coronalist6").innerHTML = "Hessen: " + CovidresultHessen;
document.getElementById("coronalist7").innerHTML = "Rheinland-Pfalz: " + CovidresultRheiPfal;
document.getElementById("coronalist8").innerHTML = "Baden-Württemberg: " + CovidresultBawue;
document.getElementById("coronalist9").innerHTML = "Bayern: " + CovidresultBayern;
document.getElementById("coronalist10").innerHTML = "Saarland: " + CovidresultSaarland;
document.getElementById("coronalist11").innerHTML = "Berlin: " + CovidresultBerlin;
document.getElementById("coronalist12").innerHTML = "Brandenburg: " + CovidresultBrandenburg;
document.getElementById("coronalist13").innerHTML = "Mecklenburg-Vorpommern: " + CovidresultMeckPom;
document.getElementById("coronalist14").innerHTML = "Sachsen: " + CovidresultSachsen;
document.getElementById("coronalist15").innerHTML = "Sachsen-Anhalt: " + CovidresultSachsenAnhalt;
document.getElementById("coronalist16").innerHTML = "Thüringen: " + CovidresultThueringen;
}
Coronaabfrage();
let DiscordOnline = false;
async function Discordabfrage() {
const Discordresponse = await fetch("https://srhpyqt94yxb.statuspage.io/api/v2/status.json");
const Discordresponsejson = await Discordresponse.json();
if (Discordresponsejson.status.description == "All Systems Operational") {
DiscordOnline = true;
document.getElementById("Discord").innerHTML = "Discord hat aktuell keine Störungen!";
} else {
DiscordOnline = false;
document.getElementById("Discord").innerHTML = "Discord hat aktuell Störungen!";
}
}
Discordabfrage();
// Make the DIV element draggable:
dragElement(document.getElementsByClassName("draggable"));
var draggableleft = 0;
var draggabletop = 10;
var Screenwidth = Screen.width;
function dragElement(elmnts) {
for (let i = 0; i < elmnts.length; i++) {
const elmnt = elmnts[i];
var pos1 = 0,
pos2 = 0,
pos3 = 0,
pos4 = 0;
const header = elmnt.querySelector(".header");
if (header) {
header.onmousedown = dragMouseDown;
} else {
elmnt.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
console.log(pos3, pos4);
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element"s new position:
elmnt.style.top = elmnt.offsetTop - pos2 + "px";
elmnt.style.left = elmnt.offsetLeft - pos1 + "px";
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
}
}
function Datum() {
Zeit = new Date();
var wochentag = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"];
zeitWochentag = Zeit.getDay();
zeitJahr = Zeit.getFullYear();
zeitMonat = Zeit.getMonth() + 1;
zeitTag = Zeit.getDate();
Wochentag = wochentag[zeitWochentag];
document.getElementById("Datum2").innerHTML = "Heute ist <br>" + Wochentag + ", der <br>" + zeitTag + "." + zeitMonat + "." + zeitJahr;
}
Datum();
async function getBitcoin() {
const Bitcoinresponse = await fetch("https://api.binance.com/api/v1/ticker/24hr?symbol=BTCEUR");
const Bitcoinresponsejson = await Bitcoinresponse.json();
document.getElementById("Bitcoin").innerHTML = "Aktueller Preis:<br>" + Math.round(Bitcoinresponsejson.lastPrice) + "€";
}
getBitcoin();
function Navifunctions() {
function getBL() {
BL = navigator.language;
document.getElementById("BL").innerHTML = BL;
}
function getUA() {
UA = navigator.userAgent;
document.getElementById("UA").innerHTML = UA;
}
function getOnline() {
online = window.navigator.onLine;
if (online === true) {
document.getElementById("Online").innerHTML = "JA!";
} else document.getElementById("Online").innerHTML = "NÖÖÖÖ!";
}
function getPlatform() {
platform = navigator.platform;
document.getElementById("Platform").innerHTML = platform;
}
function getCookieEnabled() {
cookieEnabled = navigator.cookieEnabled;
if (cookieEnabled === true) {
document.getElementById("Cookie").innerHTML = "sind AN!";
} else if (cookieEnabled === false) {
document.getElementById("Cookie").innerHTML = "sind AUS!";
} else
document.getElementById("Cookie").innerHTML = "ERROR";
}
function getJavaEnabled() {
javaEnabled = navigator.javaEnabled();
if (javaEnabled === true) {
document.getElementById("Java").innerHTML = "ist AN!";
} else if (javaEnabled === false) {
document.getElementById("Java").innerHTML = "ist AUS!";
} else
document.getElementById("Java").innerHTML = "ERROR";
}
function getLocation() {
if (locationOn == true) {
locationOn = false;
document.getElementById("LocationButton").innerHTML = '<img id="LocationButtonOff" src="OffButton.png" />';
document.querySelector("#LocationButtonOff").addEventListener("click", getLocation);
return;
} else if (locationOn == false) {
locationOn = true;
document.getElementById("LocationButton").innerHTML = '<img id="LocationButtonOff" src="OnButton.png" onclick="location.reload()"/>';
document.querySelector("#LocationButtonOff").addEventListener("click", getLocation);
} else {
console.log("ERROR")
return;
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getWeather);
}
}
async function getWeather(position) {
document.getElementById("Geolocationbody").innerHTML = "Breitengrad: " + position.coords.latitude + "<br>Längengrad: " + position.coords.longitude;
var marker = L.marker([position.coords.latitude, position.coords.longitude]).addTo(mymap);
const Weatherresponse = await fetch("https://api.openweathermap.org/data/2.5/weather?lat=8&lon=40&appid=72f36c0ee49b59b1a9d2dcc59f5ec105&lang=de&units=metric"); // + position.coords.latitude + "}&lon={" + position.coords.longitude + "
const Weatherresponsejson = await Weatherresponse.json();
document.getElementById("weatherlist1").innerHTML = "Himmel: " + Weatherresponsejson.weather[0].description;
document.getElementById("weatherlist2").innerHTML = "Temperatur: " + Math.round(Weatherresponsejson.main.temp) + "°C";
document.getElementById("weatherlist3").innerHTML = "Gefühlte Temperatur: " + Math.round(Weatherresponsejson.main.feels_like) + "°C";
document.getElementById("weatherlist4").innerHTML = "Minimaltemperatur: " + Math.round(Weatherresponsejson.main.temp_min) + "°C";
document.getElementById("weatherlist5").innerHTML = "Höchsttemperatur: " + Math.round(Weatherresponsejson.main.temp_max) + "°C";
document.getElementById("weatherlist6").innerHTML = "Luftfeuchtigkeit: " + Math.round(Weatherresponsejson.main.humidity) + "%";
document.getElementById("weatherlist7").innerHTML = "Luftdruck: " + Math.round(Weatherresponsejson.main.pressure) + " hPa";
document.getElementById("weatherlist8").innerHTML = "Luftdruck Meeresspiegel: " + Math.round(Weatherresponsejson.main.sea_level) + " hPa";
document.getElementById("weatherlist9").innerHTML = "Luftdruck Bodenhöhe: " + Math.round(Weatherresponsejson.main.grnd_level) + " hPa";
document.getElementById("weatherlist10").innerHTML = "Sichtweite: " + Math.round(Weatherresponsejson.visibility) + " meter";
document.getElementById("weatherlist11").innerHTML = "Windgeschwindigkeit: " + Math.round(Weatherresponsejson.wind.speed) + " m/s";
document.getElementById("weatherlist12").innerHTML = "Windrichtung: " + Math.round(Weatherresponsejson.wind.deg) + "°";
document.getElementById("weatherlist12").innerHTML = "Wolkenbedeckung: " + Math.round(Weatherresponsejson.clouds.all) + "%";
}
getBitcoin();
getBL();
getUA();
getOnline();
getPlatform();
getCookieEnabled();
getJavaEnabled();
let locationOn = false;
document.querySelector("#LocationButtonOff").addEventListener("click", getLocation);
}
Navifunctions();
async function randomAdvice() {
const advice = await fetch("https://api.adviceslip.com/advice")
const advicejson = await advice.json();
document.getElementById("advice").innerHTML = advicejson.slip.advice;
}
randomAdvice();
async function randomCocktail() {
const cocktail = await fetch("https://www.thecocktaildb.com/api/json/v1/1/random.php")
const cocktailjson = await cocktail.json();
document.getElementById("cocktail").innerHTML = cocktailjson.drinks[0].strDrink;
}
randomCocktail();
async function randomWitz() {
const witz = await fetch("https://v2.jokeapi.dev/joke/Any?lang=de&blacklistFlags=nsfw&type=single")
const witzjson = await witz.json();
document.getElementById("witz").innerHTML = witzjson.joke;
}
randomWitz();