MediaWiki:Common.js: Unterschied zwischen den Versionen
Änderung 917 von Secretsofnele (Diskussion) rückgängig gemacht. Markierung: Rückgängigmachung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 6: | Zeile 6: | ||
const AHN_PER_DAY = 20; | const AHN_PER_DAY = 20; | ||
const IHN_PER_AHN = IHN_PER_EHN * EHN_PER_AHN; | const IHN_PER_AHN = IHN_PER_EHN * EHN_PER_AHN; | ||
const IHN_PER_DAY = IHN_PER_AHN * AHN_PER_DAY; | const IHN_PER_DAY = IHN_PER_AHN * AHN_PER_DAY; | ||
const SEC_PER_IHN = 86400 / IHN_PER_DAY; | const SEC_PER_IHN = 86400 / IHN_PER_DAY; | ||
function getGoreanTime() { | function getGoreanTime() { | ||
| Zeile 20: | Zeile 20: | ||
const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN); | const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN); | ||
const | const rest = dayIhn % IHN_PER_AHN; | ||
const ehn = Math.floor( | const ehn = Math.floor(rest / IHN_PER_EHN); | ||
const ihn = | const ihn = rest % IHN_PER_EHN; | ||
const ahn = ahnIndex + 1; | const ahn = ahnIndex + 1; | ||
| Zeile 40: | Zeile 40: | ||
const centerY = clock.clientHeight / 2; | const centerY = clock.clientHeight / 2; | ||
const radiusOuter = 100; // | const radiusOuter = 100; // 1–10 | ||
const radiusInner = 78; | const radiusInner = 78; // 11–20 | ||
// Wir wollen: oben = 10 (außen) + 20 (innen) | |||
// Standard 0° = rechts, aber oben ist -90° | |||
// Wir verschieben um +180°, damit oben 10 erscheint | |||
const baseOffset = -36; | |||
for (let i = 0; i < 10; i++) { | for (let i = 0; i < 10; i++) { | ||
// Winkel für 1–10/11–20: 36° Schritte | |||
const angle = baseOffset + (360 / 10) * i; | |||
// Umrechnung auf Kreis-Math-Winkel: oben = -90° | |||
const rad = (angle - 90) * Math.PI / 180; | const rad = (angle - 90) * Math.PI / 180; | ||
// | // ÄUSSERE ZAHL (1–10) | ||
const numOuter = document.createElement("div"); | const numOuter = document.createElement("div"); | ||
numOuter.className = "gor-number"; | numOuter.className = "gor-number"; | ||
| Zeile 59: | Zeile 66: | ||
clock.appendChild(numOuter); | clock.appendChild(numOuter); | ||
// | // INNERE ZAHL (11–20) | ||
const numInner = document.createElement("div"); | const numInner = document.createElement("div"); | ||
numInner.className = "gor-number gor-number-inner"; | numInner.className = "gor-number gor-number-inner"; | ||
| Zeile 76: | Zeile 83: | ||
const handIhn = document.getElementById("handIhn"); | const handIhn = document.getElementById("handIhn"); | ||
if (!handAhn | if (!handAhn) return; | ||
const t = getGoreanTime(); | |||
const | // Ahn-Zeiger: 10er-Blatt mit zwei Runden | ||
const ahnCycle = (t.ahn - 1) % 10; | |||
const angleAhn = ((ahnCycle + t.ehn / 40 + t.ihn / 3200) / 10) * 360; | |||
// | // Ehn-Zeiger (40 Ehn) | ||
const angleEhn = ((t.ehn + t.ihn / 80) / 40) * 360; | |||
const | |||
// Ihn-Zeiger (80 Ihn) | |||
const angleIhn = ( | const angleIhn = (t.ihn / 80) * 360; | ||
handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`; | handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`; | ||
| Zeile 91: | Zeile 101: | ||
handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`; | handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`; | ||
// Digitale Ausgabe | |||
const pad2 = n => String(Math.floor(n)).padStart(2, "0"); | const pad2 = n => String(Math.floor(n)).padStart(2, "0"); | ||
document.getElementById("digitalAhn").textContent = "Ahn " + pad2(t.ahn); | |||
document.getElementById("digitalEhn").textContent = "Ehn " + pad2(t.ehn); | |||
document.getElementById("digitalIhn").textContent = "Ihn " + pad2(t.ihn); | |||
const info = document.getElementById("ahnInfo"); | |||
if (t.ahn === 10) info.textContent = "10. Ahn – goreanischer Mittag"; | |||
if ( | else if (t.ahn === 20) info.textContent = "20. Ahn – goreanische Mitternacht"; | ||
else info.textContent = t.ahn + ". Ahn des goreanischen Tages"; | |||
} | } | ||
function | function init() { | ||
if (!document.getElementById("gorClock")) return; | if (!document.getElementById("gorClock")) return; | ||
| Zeile 117: | Zeile 123: | ||
} | } | ||
mw.hook('wikipage.content').add( | mw.hook('wikipage.content').add(init); | ||
}); | }); | ||
Version vom 25. November 2025, 11:56 Uhr
mw.loader.using(['mediawiki.util'], function () {
// Goreanische Konstanten
const IHN_PER_EHN = 80;
const EHN_PER_AHN = 40;
const AHN_PER_DAY = 20;
const IHN_PER_AHN = IHN_PER_EHN * EHN_PER_AHN;
const IHN_PER_DAY = IHN_PER_AHN * AHN_PER_DAY;
const SEC_PER_IHN = 86400 / IHN_PER_DAY;
function getGoreanTime() {
const now = new Date();
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const elapsed = (now - midnight) / 1000;
const totalIhn = elapsed / SEC_PER_IHN;
const dayIhn = ((totalIhn % IHN_PER_DAY) + IHN_PER_DAY) % IHN_PER_DAY;
const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN);
const rest = dayIhn % IHN_PER_AHN;
const ehn = Math.floor(rest / IHN_PER_EHN);
const ihn = rest % IHN_PER_EHN;
const ahn = ahnIndex + 1;
return { ahnIndex, ahn, ehn, ihn };
}
function buildDial() {
const clock = document.getElementById("gorClock");
if (!clock) return;
if (clock.dataset.gorDialBuilt === "1") return;
clock.dataset.gorDialBuilt = "1";
const centerX = clock.clientWidth / 2;
const centerY = clock.clientHeight / 2;
const radiusOuter = 100; // 1–10
const radiusInner = 78; // 11–20
// Wir wollen: oben = 10 (außen) + 20 (innen)
// Standard 0° = rechts, aber oben ist -90°
// Wir verschieben um +180°, damit oben 10 erscheint
const baseOffset = -36;
for (let i = 0; i < 10; i++) {
// Winkel für 1–10/11–20: 36° Schritte
const angle = baseOffset + (360 / 10) * i;
// Umrechnung auf Kreis-Math-Winkel: oben = -90°
const rad = (angle - 90) * Math.PI / 180;
// ÄUSSERE ZAHL (1–10)
const numOuter = document.createElement("div");
numOuter.className = "gor-number";
numOuter.textContent = i + 1;
numOuter.style.left = (centerX + radiusOuter * Math.cos(rad)) + "px";
numOuter.style.top = (centerY + radiusOuter * Math.sin(rad)) + "px";
clock.appendChild(numOuter);
// INNERE ZAHL (11–20)
const numInner = document.createElement("div");
numInner.className = "gor-number gor-number-inner";
numInner.textContent = i + 11;
numInner.style.left = (centerX + radiusInner * Math.cos(rad)) + "px";
numInner.style.top = (centerY + radiusInner * Math.sin(rad)) + "px";
clock.appendChild(numInner);
}
}
function updateGoreanClock() {
const handAhn = document.getElementById("handAhn");
const handEhn = document.getElementById("handEhn");
const handIhn = document.getElementById("handIhn");
if (!handAhn) return;
const t = getGoreanTime();
// Ahn-Zeiger: 10er-Blatt mit zwei Runden
const ahnCycle = (t.ahn - 1) % 10;
const angleAhn = ((ahnCycle + t.ehn / 40 + t.ihn / 3200) / 10) * 360;
// Ehn-Zeiger (40 Ehn)
const angleEhn = ((t.ehn + t.ihn / 80) / 40) * 360;
// Ihn-Zeiger (80 Ihn)
const angleIhn = (t.ihn / 80) * 360;
handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`;
handEhn.style.transform = `translate(-50%, -100%) rotate(${angleEhn}deg)`;
handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`;
// Digitale Ausgabe
const pad2 = n => String(Math.floor(n)).padStart(2, "0");
document.getElementById("digitalAhn").textContent = "Ahn " + pad2(t.ahn);
document.getElementById("digitalEhn").textContent = "Ehn " + pad2(t.ehn);
document.getElementById("digitalIhn").textContent = "Ihn " + pad2(t.ihn);
const info = document.getElementById("ahnInfo");
if (t.ahn === 10) info.textContent = "10. Ahn – goreanischer Mittag";
else if (t.ahn === 20) info.textContent = "20. Ahn – goreanische Mitternacht";
else info.textContent = t.ahn + ". Ahn des goreanischen Tages";
}
function init() {
if (!document.getElementById("gorClock")) return;
buildDial();
updateGoreanClock();
setInterval(updateGoreanClock, 150);
}
mw.hook('wikipage.content').add(init);
});