MediaWiki:Common.js: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
mw.loader.using(['mediawiki.util'], function () { | mw.loader.using(['mediawiki.util'], function () { | ||
| Zeile 8: | Zeile 7: | ||
const IHN_PER_AHN = IHN_PER_EHN * EHN_PER_AHN; // 80 * 40 = 3200 | const IHN_PER_AHN = IHN_PER_EHN * EHN_PER_AHN; // 80 * 40 = 3200 | ||
const IHN_PER_DAY = IHN_PER_AHN * AHN_PER_DAY; // | const IHN_PER_DAY = IHN_PER_AHN * AHN_PER_DAY; // 64000 | ||
const SEC_PER_IHN = 86400 / IHN_PER_DAY; // 86400 sec pro Tag -> goreanische Ihn | |||
const SEC_PER_IHN = 86400 / IHN_PER_DAY; // | |||
function getGoreanTime() { | function getGoreanTime() { | ||
const now = new Date(); | const now = new Date(); | ||
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate()); | const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate()); | ||
const elapsed = (now - midnight) / 1000; | const elapsed = (now - midnight) / 1000; | ||
const totalIhn = elapsed / SEC_PER_IHN; | const totalIhn = elapsed / SEC_PER_IHN; | ||
const dayIhn = ((totalIhn % IHN_PER_DAY) + IHN_PER_DAY) % IHN_PER_DAY; | const dayIhn = ((totalIhn % IHN_PER_DAY) + IHN_PER_DAY) % IHN_PER_DAY; | ||
const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN); | const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN); | ||
const rest1 = dayIhn % IHN_PER_AHN; | const rest1 = dayIhn % IHN_PER_AHN; | ||
const ehn = Math.floor(rest1 / IHN_PER_EHN); | const ehn = Math.floor(rest1 / IHN_PER_EHN); | ||
const ihn = rest1 % IHN_PER_EHN; | const ihn = rest1 % IHN_PER_EHN; | ||
const ahn = ahnIndex + 1; | const ahn = ahnIndex + 1; | ||
return { ahnIndex, ahn, ehn, ihn }; | return { ahnIndex, ahn, ehn, ihn }; | ||
| Zeile 36: | Zeile 34: | ||
if (!clock) return; | if (!clock) return; | ||
if (clock.dataset.gorDialBuilt === "1") return; | if (clock.dataset.gorDialBuilt === "1") return; | ||
clock.dataset.gorDialBuilt = "1"; | clock.dataset.gorDialBuilt = "1"; | ||
| Zeile 43: | Zeile 40: | ||
const centerY = clock.clientHeight / 2; | const centerY = clock.clientHeight / 2; | ||
const radiusOuter = 100; | const radiusOuter = 100; // für 1–10 | ||
const radiusInner = 78; | const radiusInner = 78; // für 11–20 | ||
// | // Nur Zahlen (1–10 außen, 11–20 innen) | ||
for (let i = 0; i < 10; i++) { | for (let i = 0; i < 10; i++) { | ||
const angle = (360 / 10) * i; | const angle = (360 / 10) * i; | ||
const rad = (angle - 90) * Math.PI / 180; | |||
const | |||
// Äußere Zahl | // Äußere Zahl 1–10 | ||
const numOuter = document.createElement("div"); | const numOuter = document.createElement("div"); | ||
numOuter.className = "gor-number"; | 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); | clock.appendChild(numOuter); | ||
// Innere Zahl | // 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"; | ||
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); | clock.appendChild(numInner); | ||
} | } | ||
| Zeile 89: | Zeile 80: | ||
const time = getGoreanTime(); | const time = getGoreanTime(); | ||
// Ahn-Zeiger: 10er-Ziffernblatt, | // Ahn-Zeiger: 10er-Ziffernblatt, zwei Umdrehungen pro Tag | ||
const ahnCycle = (time.ahn - 1) % 10; | |||
const ahnCycle = (time.ahn - 1) % 10; | const angleAhn = ((ahnCycle + time.ehn / 40 + time.ihn / 3200) / 10) * 360; | ||
const angleAhn = ((ahnCycle + time.ehn / | |||
// | const angleEhn = ((time.ehn + time.ihn / 80) / 40) * 360; | ||
const angleIhn = (time.ihn / | const angleIhn = (time.ihn / 80) * 360; | ||
handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`; | handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`; | ||
| Zeile 104: | Zeile 91: | ||
handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`; | handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`; | ||
const pad2 = n => String(Math.floor(n)).padStart(2, "0"); | |||
const dAhn = document.getElementById("digitalAhn"); | const dAhn = document.getElementById("digitalAhn"); | ||
const dEhn = document.getElementById("digitalEhn"); | const dEhn = document.getElementById("digitalEhn"); | ||
const dIhn = document.getElementById("digitalIhn"); | const dIhn = document.getElementById("digitalIhn"); | ||
if (dAhn) dAhn.textContent = "Ahn " + pad2(time.ahn); | if (dAhn) dAhn.textContent = "Ahn " + pad2(time.ahn); | ||
| Zeile 116: | Zeile 101: | ||
if (dIhn) dIhn.textContent = "Ihn " + pad2(time.ihn); | if (dIhn) dIhn.textContent = "Ihn " + pad2(time.ihn); | ||
const info = document.getElementById("ahnInfo"); | |||
if (info) { | if (info) { | ||
if (time.ahn === 10) | if (time.ahn === 10) info.textContent = "10. Ahn – goreanischer Mittag"; | ||
else if (time.ahn === 20) info.textContent = "20. Ahn – goreanische Mitternacht"; | |||
else info.textContent = time.ahn + ". Ahn des goreanischen Tages"; | |||
} | } | ||
} | } | ||
function initGoreanClock() { | function initGoreanClock() { | ||
if (!document.getElementById("gorClock")) return; | |||
buildDial(); | buildDial(); | ||
| Zeile 136: | Zeile 117: | ||
} | } | ||
mw.hook('wikipage.content').add(initGoreanClock); | mw.hook('wikipage.content').add(initGoreanClock); | ||
}); | }); | ||
Version vom 25. November 2025, 09:30 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; // 80 * 40 = 3200
const IHN_PER_DAY = IHN_PER_AHN * AHN_PER_DAY; // 64000
const SEC_PER_IHN = 86400 / IHN_PER_DAY; // 86400 sec pro Tag -> goreanische Ihn
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 rest1 = dayIhn % IHN_PER_AHN;
const ehn = Math.floor(rest1 / IHN_PER_EHN);
const ihn = rest1 % 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; // für 1–10
const radiusInner = 78; // für 11–20
// Nur Zahlen (1–10 außen, 11–20 innen)
for (let i = 0; i < 10; i++) {
const angle = (360 / 10) * i;
const rad = (angle - 90) * Math.PI / 180;
// Äußere 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 || !handEhn || !handIhn) return;
const time = getGoreanTime();
// Ahn-Zeiger: 10er-Ziffernblatt, zwei Umdrehungen pro Tag
const ahnCycle = (time.ahn - 1) % 10;
const angleAhn = ((ahnCycle + time.ehn / 40 + time.ihn / 3200) / 10) * 360;
const angleEhn = ((time.ehn + time.ihn / 80) / 40) * 360;
const angleIhn = (time.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)`;
const pad2 = n => String(Math.floor(n)).padStart(2, "0");
const dAhn = document.getElementById("digitalAhn");
const dEhn = document.getElementById("digitalEhn");
const dIhn = document.getElementById("digitalIhn");
if (dAhn) dAhn.textContent = "Ahn " + pad2(time.ahn);
if (dEhn) dEhn.textContent = "Ehn " + pad2(time.ehn);
if (dIhn) dIhn.textContent = "Ihn " + pad2(time.ihn);
const info = document.getElementById("ahnInfo");
if (info) {
if (time.ahn === 10) info.textContent = "10. Ahn – goreanischer Mittag";
else if (time.ahn === 20) info.textContent = "20. Ahn – goreanische Mitternacht";
else info.textContent = time.ahn + ". Ahn des goreanischen Tages";
}
}
function initGoreanClock() {
if (!document.getElementById("gorClock")) return;
buildDial();
updateGoreanClock();
setInterval(updateGoreanClock, 150);
}
mw.hook('wikipage.content').add(initGoreanClock);
});