MediaWiki:Strona główna.js: Różnice pomiędzy wersjami
Przejdź do nawigacji
Przejdź do wyszukiwania
Nie podano opisu zmian |
mNie podano opisu zmian |
||
| Linia 1: | Linia 1: | ||
fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCRiibFs5HGRW5EbAFwf5irA) | fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCRiibFs5HGRW5EbAFwf5irA") | ||
.then(response => response.text()) | .then(response => response.text()) | ||
.then(str => new window.DOMParser().parseFromString(str, "text/xml")) | .then(str => new window.DOMParser().parseFromString(str, "text/xml")) | ||
.then(data => { | .then(data => { | ||
const entry = data.querySelector("entry"); | const entry = data.querySelector("entry"); | ||
const | if (!entry) return; // brak wpisów w feedzie | ||
const videoIdElem = entry.querySelector("yt\\:videoId"); | |||
if (!videoIdElem) return; // brak videoId | |||
const videoId = videoIdElem.textContent; | |||
const iframe = document.createElement("iframe"); | const iframe = document.createElement("iframe"); | ||
iframe.width = "560"; | iframe.width = "560"; | ||
| Linia 12: | Linia 16: | ||
iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"; | iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"; | ||
iframe.allowFullscreen = true; | iframe.allowFullscreen = true; | ||
document.getElementById("yt-latest-video").appendChild(iframe); | |||
const container = document.getElementById("yt-latest-video"); | |||
if (container) { | |||
container.appendChild(iframe); | |||
} | |||
}) | |||
.catch(err => { | |||
console.error("Błąd przy ładowaniu filmu YouTube:", err); | |||
}); | }); | ||
Wersja z 20:13, 29 lip 2025
fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCRiibFs5HGRW5EbAFwf5irA")
.then(response => response.text())
.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
.then(data => {
const entry = data.querySelector("entry");
if (!entry) return; // brak wpisów w feedzie
const videoIdElem = entry.querySelector("yt\\:videoId");
if (!videoIdElem) return; // brak videoId
const videoId = videoIdElem.textContent;
const iframe = document.createElement("iframe");
iframe.width = "560";
iframe.height = "315";
iframe.src = `https://www.youtube.com/embed/${videoId}`;
iframe.frameBorder = "0";
iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
iframe.allowFullscreen = true;
const container = document.getElementById("yt-latest-video");
if (container) {
container.appendChild(iframe);
}
})
.catch(err => {
console.error("Błąd przy ładowaniu filmu YouTube:", err);
});