Repository navigation
Expand file tree
/
Copy pathcode.js
More file actions
64 lines (44 loc) · 1.67 KB
/
Copy pathcode.js
File metadata and controls
64 lines (44 loc) · 1.67 KB
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
function vkConvert() {
const input = document.getElementById("vk-date").value;
const output = document.getElementById("vk-output");
if (!input) {
output.innerHTML = "";
return;
}
const date = new Date(input + "T00:00:00Z");
const year = date.getUTCFullYear();
const startOfYear = Date.UTC(year, 0, 1);
const dayOfYear = Math.floor((date - startOfYear) / 86400000);
const isLeap = (year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0));
const vulkanTagDOY = isLeap ? 230 : 229;
let vulkanYear = year - 1642;
if (dayOfYear === vulkanTagDOY) {
output.innerHTML = `🔥 <strong>Vulkantag</strong> – Vulkanistisches Neujahr ${vulkanYear}`;
return;
}
let offset = dayOfYear - vulkanTagDOY;
if (offset < 0) {
offset += isLeap ? 366 : 365;
vulkanYear -= 1;
}
const monthIndex = Math.floor(offset / 91);
const dayInMonth = (offset % 91) + 1;
const monthNames = ["Sobek", "Piez", "Frinek", "Arpol"];
const month = monthNames[monthIndex] || "Unbekannt";
output.innerHTML = `➡️ <strong>${dayInMonth}. ${month} ${vulkanYear}</strong>`;
}
function scrollFunction(header, toppos) {
if (window.pageYOffset > toppos) {
header.classList.add("sticky");
document.body.style.paddingTop = "100px";
} else {
header.classList.remove("sticky");
document.body.style.paddingTop = "0";
}
}
window.onload=function() {
const header = document.getElementById("myHeader");
const toppos = header.offsetTop;
window.onscroll = function() { scrollFunction(header, toppos); };
document.getElementById("vk-button").addEventListener("click", vkConvert);
};