Ich habe mit einem Kollegen besprochen, wie man aus den Mondbildern (moon0.gif, moon1.gif ...) ein Script erstellen das mit KI erzeugt worden ist.
Die Verarbeitung kann in Wswin in der Custom Schiene oder in einer anderen Datei eingebunden werden.
<!-- %customfile=gauges-ss-basic.html% -->
<!-- %openfile=mondphasen.txt% -->
Somit lässt sich für jeden Monat und Jahr der Kalender aufrufen, mit den Grafiken siehe oben.
Diese Datei stelle ich von Harald Schuster hier mal zur Verfügung. Ja es hat in Wirklichkeit nichts mit Variablen in dieser Datei zu tun. Aber es ist sehr toll geworden, bin echt davon begeistert
Code: Alles auswählen
<!-- %customfile=C:\www.sternwarte-ehingen\Wetterdaten\mondphasen.html% -->
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WsWin Mondkalender</title>
<style>
body {
font-family: Arial, sans-serif;
/* Original-Hintergrund wie in der bisherigen Seite: unverändert gekachelt */
background-image: url("blustone.gif");
background-repeat: repeat;
background-position: left top;
background-attachment: scroll;
color: #263445;
margin: 0;
padding: 12px;
}
#mondkalender {
max-width: 850px;
margin: auto;
padding: 15px;
background: rgba(255, 255, 255, 0.88);
border: 1px solid #ccd5df;
border-radius: 10px;
}
h2 {
text-align: center;
margin: 5px 0 15px;
}
.auswahl {
display: flex;
justify-content: center;
gap: 10px;
margin-bottom: 18px;
flex-wrap: wrap;
}
select {
padding: 8px;
font-size: 15px;
border: 1px solid #aab8c8;
border-radius: 5px;
}
#kalender {
display: grid;
grid-template-columns: repeat(7, 1fr);
gap: 4px;
}
.wochentag {
text-align: center;
font-weight: bold;
padding: 8px 2px;
background: #e5edf6;
border-radius: 4px;
}
.tag {
min-height: 115px;
text-align: center;
border: 1px solid #dce3eb;
border-radius: 5px;
padding: 4px 1px;
background: #fafcff;
}
.heute {
border: 2px solid #2878c7;
background: #eaf4ff;
}
.datum {
font-weight: bold;
font-size: 14px;
}
.tag img {
display: block;
width: 90px;
height: 90px;
object-fit: contain;
margin: 3px auto;
}
.phase {
font-size: 10px;
color: #52657b;
}
.beleuchtung {
font-size: 17px;
font-weight: bold;
color: #0056b3;
margin-top: 3px;
}
.vollmond {
color: #d00000;
font-weight: bold;
animation: vollmondBlink 1s steps(2, start) infinite;
}
@keyframes vollmondBlink {
to { visibility: hidden; }
}
.aktualisiert {
text-align: center;
font-size: 13px;
color: #263445;
margin: -7px 0 14px;
font-weight: bold;
}
#hinweis {
text-align: center;
font-size: 12px;
margin-top: 12px;
color: #607080;
}
@media(max-width:480px) {
.tag { min-height: 80px; }
.tag img { width: 36px; height: 36px; }
.phase { font-size: 8px; }
.beleuchtung { font-size: 14px; }
.vollmond { font-size: 14px; }
}
</style>
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#800080" alink="#FF0000" background="blustone.gif">
<div id="mondkalender">
<h2 id="monatstitel">Mondkalender</h2>
<div class="aktualisiert">
Aktualisiert am: %ws_date% um %ws_time% Uhr
</div>
<div class="auswahl">
<label>
Monat:
<select id="monat"></select>
</label>
<label>
Jahr:
<select id="jahr"></select>
</label>
</div>
<div id="kalender"></div>
<div id="fusszeile" style="text-align:center; margin-top:18px; font-size:13px;">
© Harald Schuster |
<a href="https://www.wetterstation.hiltenfingen.com/">https://www.wetterstation.hiltenfingen.com/</a>
</div>
</div>
<script>
/* =========================================
WsWin MONDKALENDER
=========================================
Mondbilder:
moon0.gif bis moon29.gif
Grafikverzeichnis:
https://www.wetterstation.hiltenfingen.com/mondphasen/
Auswahl:
Januar 2023 bis Dezember 2050
========================================= */
// GRAFIKVERZEICHNIS
const grafikPfad =
"https://www.wetterstation.hiltenfingen.com/mondphasen/";
// MONATE
const monate = [
"Januar", "Februar", "März", "April",
"Mai", "Juni", "Juli", "August",
"September", "Oktober", "November", "Dezember"
];
// WOCHENTAGE
const wochentage = [
"Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"
];
// ASTRONOMISCHE GRUNDLAGE
// Referenz-Neumond: 06.01.2000, 18:14 UTC
const referenzNeumond =
Date.UTC(2000, 0, 6, 18, 14, 0);
const synodischerMonat = 29.530588853;
// MONDALTER BERECHNEN
function mondalter(datum) {
let zeit = Date.UTC(
datum.getFullYear(),
datum.getMonth(),
datum.getDate(),
12
);
let tage = (zeit - referenzNeumond) / 86400000;
let alter =
((tage % synodischerMonat) + synodischerMonat)
% synodischerMonat;
return alter;
}
// MONDBELEUCHTUNG IN PROZENT
function mondbeleuchtung(alter) {
const anteil = alter / synodischerMonat;
const beleuchtung = (1 - Math.cos(2 * Math.PI * anteil)) / 2;
return Math.round(beleuchtung * 100);
}
// MONDBILD-NUMMER
function mondbild(alter) {
let nummer = Math.floor(alter);
nummer = Math.max(0, Math.min(29, nummer));
return nummer;
}
// AUSWAHLMENÜ ERSTELLEN
function auswahlErstellen() {
const monat = document.getElementById("monat");
const jahr = document.getElementById("jahr");
monate.forEach((name, index) => {
let option = document.createElement("option");
option.value = index;
option.textContent = name;
monat.appendChild(option);
});
for (let j = 2023; j <= 2050; j++) {
let option = document.createElement("option");
option.value = j;
option.textContent = j;
jahr.appendChild(option);
}
const heute = new Date();
// Aktuellen Monat vorauswählen.
// Falls außerhalb des Bereichs: Januar 2023.
monat.value = heute.getMonth();
jahr.value = Math.max(2023, Math.min(2050,
heute.getFullYear()));
}
// KALENDER ERSTELLEN
function kalenderErstellen() {
const monat =
Number(document.getElementById("monat").value);
const jahr =
Number(document.getElementById("jahr").value);
const kalender =
document.getElementById("kalender");
const titel =
document.getElementById("monatstitel");
kalender.innerHTML = "";
titel.textContent =
monate[monat] + " " + jahr;
// WOCHENTAGE
wochentage.forEach(tag => {
let feld = document.createElement("div");
feld.className = "wochentag";
feld.textContent = tag;
kalender.appendChild(feld);
});
// ERSTER TAG DES MONATS
let ersterTag = new Date(jahr, monat, 1);
// Montag = 0, Sonntag = 6
let start =
(ersterTag.getDay() + 6) % 7;
// ANZAHL DER TAGE
// JavaScript berücksichtigt automatisch Schaltjahre.
let anzahlTage =
new Date(jahr, monat + 1, 0).getDate();
// LEERE FELDER VOR MONATSBEGINN
for (let i = 0; i < start; i++) {
let feld = document.createElement("div");
kalender.appendChild(feld);
}
const heute = new Date();
// JEDEN KALENDERTAG ERSTELLEN
for (let tag = 1; tag <= anzahlTage; tag++) {
let datum = new Date(jahr, monat, tag);
let alter = mondalter(datum);
let nummer = mondbild(alter);
let licht = mondbeleuchtung(alter);
let feld = document.createElement("div");
feld.className = "tag";
// HEUTIGEN TAG MARKIEREN
if (
tag === heute.getDate() &&
monat === heute.getMonth() &&
jahr === heute.getFullYear()
) {
feld.classList.add("heute");
}
// TAGESNUMMER
let nummerText = document.createElement("div");
nummerText.className = "datum";
nummerText.textContent = tag;
// MONDGRAFIK
let bild = document.createElement("img");
bild.src =
grafikPfad + "moon" + nummer + ".gif";
bild.alt = "Mondbeleuchtung " + licht + " Prozent";
bild.title =
"Beleuchtung: " + licht + " % – Mondalter: " +
alter.toFixed(1) + " Tage";
// TAEGLICHE MONDBELEUCHTUNG
let lichtText = document.createElement("div");
lichtText.className = "beleuchtung";
// Bei 100 % statt der Prozentangabe "Vollmond" anzeigen
if (licht === 100) {
lichtText.classList.add("vollmond");
lichtText.textContent = "Vollmond";
} else {
lichtText.textContent = licht + " %";
}
feld.appendChild(nummerText);
feld.appendChild(bild);
feld.appendChild(lichtText);
kalender.appendChild(feld);
}
}
// INITIALISIERUNG
auswahlErstellen();
kalenderErstellen();
// MONAT UND JAHR NEU AUSWÄHLEN
document.getElementById("monat")
.addEventListener("change", kalenderErstellen);
document.getElementById("jahr")
.addEventListener("change", kalenderErstellen);
</script>
</body>
</html>
Hier zu sehen:
https://www.sternwarte-ehingen.de/Wette ... hasen.html
Was noch angepasst werden muss ist:
/* =========================================
WsWin MONDKALENDER
=========================================
Mondbilder:
moon0.gif bis moon29.gif
Grafikverzeichnis:
https://www.sternwarte-ehingen.de/Wetterdaten/
Auswahl:
Januar 2023 bis Dezember 2050
========================================= */
// GRAFIKVERZEICHNIS
const grafikPfad =
"
https://www.sternwarte-ehingen.de/Wetterdaten/";
Also wo sich diese Bilder befinden