MediaWiki:Common.js: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
K Änderung von Narvik (Diskussion) wurde auf die letzte Version von Secretsofnele zurückgesetzt Markierung: Zurücksetzung |
||
| (8 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
mw.loader.using(['mediawiki.util'], function () { | mw.loader.using(['mediawiki.util'], function () { | ||
| Zeile 12: | Zeile 11: | ||
// Erdtag (24h) → goreanischer Tag (64000 Ihn) | // Erdtag (24h) → goreanischer Tag (64000 Ihn) | ||
const SEC_PER_IHN = 86400 / IHN_PER_DAY; // ≈ 1,35 s pro Ihn | const SEC_PER_IHN = 86400 / IHN_PER_DAY; // ≈ 1,35 s pro Ihn | ||
// Ziffernblatt-Konstanten für Ahn (10er-Blatt) | |||
const STEP_AHN = 360 / 10; // 10 Felder | |||
const BASE_OFFSET_AHN = 36; // sorgt dafür, dass 10/20 oben stehen | |||
function getGoreanTime() { | function getGoreanTime() { | ||
| Zeile 22: | Zeile 25: | ||
const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN); // 0–19 | const ahnIndex = Math.floor(dayIhn / IHN_PER_AHN); // 0–19 | ||
const | const rest = dayIhn % IHN_PER_AHN; | ||
const ehn = Math.floor( | const ehn = Math.floor(rest / IHN_PER_EHN); // 0–39 | ||
const ihn = | const ihn = rest % IHN_PER_EHN; // 0–79 (inkl. Nachkomma) | ||
const ahn = ahnIndex + 1; // | const ahn = ahnIndex + 1; // 1–20 | ||
return { ahnIndex, ahn, ehn, ihn }; | return { ahnIndex, ahn, ehn, ihn }; | ||
| Zeile 36: | Zeile 39: | ||
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 45: | ||
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 | ||
for (let i = 0; i < 10; i++) { | for (let i = 0; i < 10; i++) { | ||
// Winkel für 1–10 / 11–20 in 36°-Schritten, oben = 10/20 | |||
const angle = BASE_OFFSET_AHN + STEP_AHN * i; | |||
// | // Umrechnung auf Canvas-Math: oben = -90° | ||
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"; | ||
numOuter.textContent = i + 1; | |||
numOuter.style.left = (centerX + radiusOuter * Math.cos( | numOuter.style.left = (centerX + radiusOuter * Math.cos(rad)) + "px"; | ||
numOuter.style.top = (centerY + radiusOuter * Math.sin( | numOuter.style.top = (centerY + radiusOuter * Math.sin(rad)) + "px"; | ||
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"; | ||
numInner.textContent = i + 11; | |||
numInner.style.left = (centerX + radiusInner * Math.cos( | numInner.style.left = (centerX + radiusInner * Math.cos(rad)) + "px"; | ||
numInner.style.top = (centerY + radiusInner * Math.sin( | numInner.style.top = (centerY + radiusInner * Math.sin(rad)) + "px"; | ||
clock.appendChild(numInner); | clock.appendChild(numInner); | ||
} | } | ||
| Zeile 87: | Zeile 82: | ||
if (!handAhn || !handEhn || !handIhn) return; | if (!handAhn || !handEhn || !handIhn) return; | ||
const | const t = getGoreanTime(); | ||
// === Ahn-Zeiger: 10er-Blatt, zwei Runden pro Tag, passend zum Ziffernblatt === | |||
const ahnCycle = (t.ahn - 1) % 10; // 0..9 (1–10 / 11–20) | |||
const fractionInAhn = | |||
t.ehn / EHN_PER_AHN + t.ihn / IHN_PER_AHN; // Anteil innerhalb der aktuellen Ahn | |||
const angleAhn = BASE_OFFSET_AHN + STEP_AHN * (ahnCycle + fractionInAhn); | |||
const angleAhn = | |||
// Ehn-Zeiger | // === Ehn-Zeiger (40 Ehn pro Umdrehung) === | ||
const angleEhn = (( | const angleEhn = ((t.ehn + t.ihn / IHN_PER_EHN) / EHN_PER_AHN) * 360; | ||
// Ihn-Zeiger | // === Ihn-Zeiger (80 Ihn pro Umdrehung) === | ||
const angleIhn = ( | const angleIhn = (t.ihn / IHN_PER_EHN) * 360; | ||
handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`; | handAhn.style.transform = `translate(-50%, -100%) rotate(${angleAhn}deg)`; | ||
| Zeile 104: | Zeile 101: | ||
handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`; | handIhn.style.transform = `translate(-50%, -100%) rotate(${angleIhn}deg)`; | ||
// Digitale | // Digitale Ausgabe | ||
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"); | ||
| Zeile 110: | Zeile 109: | ||
const info = document.getElementById("ahnInfo"); | const info = document.getElementById("ahnInfo"); | ||
if (dAhn) dAhn.textContent = "Ahn " + pad2(t.ahn); | |||
if (dEhn) dEhn.textContent = "Ehn " + pad2(t.ehn); | |||
if (dAhn) dAhn.textContent = "Ahn " + pad2( | if (dIhn) dIhn.textContent = "Ihn " + pad2(t.ihn); | ||
if (dEhn) dEhn.textContent = "Ehn " + pad2( | |||
if (dIhn) dIhn.textContent = "Ihn " + pad2( | |||
if (info) { | if (info) { | ||
if ( | if (t.ahn === 10) { | ||
info.textContent = "10. Ahn – goreanischer Mittag"; | info.textContent = "10. Ahn – goreanischer Mittag"; | ||
} else if ( | } else if (t.ahn === 20) { | ||
info.textContent = "20. Ahn – goreanische Mitternacht"; | info.textContent = "20. Ahn – goreanische Mitternacht"; | ||
} else { | } else { | ||
info.textContent = | info.textContent = t.ahn + ". Ahn des goreanischen Tages"; | ||
} | } | ||
} | } | ||
} | } | ||
function | function init() { | ||
if (!document.getElementById("gorClock")) return; | |||
buildDial(); | buildDial(); | ||
updateGoreanClock(); | updateGoreanClock(); | ||
setInterval(updateGoreanClock, | setInterval(updateGoreanClock, 300); // 300 ms = ok für Performance | ||
} | } | ||
mw.hook('wikipage.content').add(init); | |||
mw.hook('wikipage.content').add( | |||
}); | }); | ||
Aktuelle Version vom 27. November 2025, 08:26 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; // 3200 * 20 = 64000
// Erdtag (24h) → goreanischer Tag (64000 Ihn)
const SEC_PER_IHN = 86400 / IHN_PER_DAY; // ≈ 1,35 s pro Ihn
// Ziffernblatt-Konstanten für Ahn (10er-Blatt)
const STEP_AHN = 360 / 10; // 10 Felder
const BASE_OFFSET_AHN = 36; // sorgt dafür, dass 10/20 oben stehen
function getGoreanTime() {
const now = new Date();
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const elapsed = (now - midnight) / 1000; // Sekunden seit Mitternacht
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); // 0–19
const rest = dayIhn % IHN_PER_AHN;
const ehn = Math.floor(rest / IHN_PER_EHN); // 0–39
const ihn = rest % IHN_PER_EHN; // 0–79 (inkl. Nachkomma)
const ahn = ahnIndex + 1; // 1–20
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
for (let i = 0; i < 10; i++) {
// Winkel für 1–10 / 11–20 in 36°-Schritten, oben = 10/20
const angle = BASE_OFFSET_AHN + STEP_AHN * i;
// Umrechnung auf Canvas-Math: 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 || !handEhn || !handIhn) return;
const t = getGoreanTime();
// === Ahn-Zeiger: 10er-Blatt, zwei Runden pro Tag, passend zum Ziffernblatt ===
const ahnCycle = (t.ahn - 1) % 10; // 0..9 (1–10 / 11–20)
const fractionInAhn =
t.ehn / EHN_PER_AHN + t.ihn / IHN_PER_AHN; // Anteil innerhalb der aktuellen Ahn
const angleAhn = BASE_OFFSET_AHN + STEP_AHN * (ahnCycle + fractionInAhn);
// === Ehn-Zeiger (40 Ehn pro Umdrehung) ===
const angleEhn = ((t.ehn + t.ihn / IHN_PER_EHN) / EHN_PER_AHN) * 360;
// === Ihn-Zeiger (80 Ihn pro Umdrehung) ===
const angleIhn = (t.ihn / IHN_PER_EHN) * 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");
const dAhn = document.getElementById("digitalAhn");
const dEhn = document.getElementById("digitalEhn");
const dIhn = document.getElementById("digitalIhn");
const info = document.getElementById("ahnInfo");
if (dAhn) dAhn.textContent = "Ahn " + pad2(t.ahn);
if (dEhn) dEhn.textContent = "Ehn " + pad2(t.ehn);
if (dIhn) dIhn.textContent = "Ihn " + pad2(t.ihn);
if (info) {
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, 300); // 300 ms = ok für Performance
}
mw.hook('wikipage.content').add(init);
});