Jump to content
Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.

Widget:DragonballWikiNews: Unterschied zwischen den Versionen

Aus DragonballWiki
Inhalt gelöscht Inhalt hinzugefügt
 
(9 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
<noinclude>__NOTOC__
<noinclude>__NOTOC__
DragonballWiki News Widget.
DragonballWiki News Widget
</noinclude><includeonly>
</noinclude><includeonly>

<style>
<style>
.swiper {
.newsSwiper {
width: auto;
width: 100%;
max-width: 600px;
max-width: 600px;
overflow: hidden;
}
}


.newsSlide {
.swiper-slide img {
height: 100%;
width: 100%;
object-fit: cover;
}

.sliderBox {
position: relative;
position: relative;
height: 337px;
height: 337px;
text-align: center;
}
}


.newsSlide img {
.postTitle {
font-weight: bold;
width: 100%;
font-size: large;
height: 100%;
padding-top: 10px;
object-fit: cover;
text-transform: uppercase;
}
}


.postExcerpt {
.newsCaption {
font-size: small;
margin-top: -1%;
margin-bottom: 3%;
}

.sliderCaption {
position: absolute;
position: absolute;
bottom: 2%;
bottom: 2%;
right: 0;
background-color: rgba(0, 0, 0, 0.8);
left: 0;
padding: 10px;
background: rgba(0,0,0,0.8);
color: white;
color: white;
text-shadow: 1px 1px 1px #333333;
text-align: left;
right: 0;
padding: 5px;
line-height: 1.5;
line-height: 1.5;
}
}


.sliderCaption a {
.newsCaption a {
color: white;
color: white !important;
font-weight: bold;
text-transform: uppercase;
text-transform: uppercase;
text-decoration: none;
}
}


.sliderBox a {
.newsExcerpt {
font-size: small;
color: white !important;
font-weight: bolder;
margin-top: 5px;
letter-spacing: -1px;
}
}


.swiper-slide {
.newsSwiper .swiper-button-next,
.newsSwiper .swiper-button-prev {
text-align: center;
font-size: 18px;
}

.swiper-button-next,
.swiper-button-prev {
top: 40%;
top: 40%;
color: white;
background: #455389;
padding: 5px;
border-radius: 10px;
}
}


.swiper-button-prev, .swiper-button-next {
.newsSwiper .swiper-pagination-bullet {
background-color: #455389;
background: white;
padding: 5px;
border-radius: 10px;
}
}
</style>
</style>

<div class="swiper newsSwiper">
<div class="swiper-wrapper" id="wikiNewsSlides">
<div class="swiper-slide">
Lade aktuelle Beiträge ...
</div>
</div>

<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-pagination"></div>
</div>

<script>
<script>
(function () {
// DEFER LOADING SCRIPT UNTIL JQUERY IS READY. WAIT 40MS BETWEEN ATTEMPTS.
function defer(method) {
if (window.jQuery) {
method();
} else {
setTimeout(function () { defer(method) }, 40);
}
}


// API-ENDPUNKT DES QUELL-WIKIS
// INITIALISATION
var API_URL = "https://bratpfannenberg.com/mediawiki/api.php";
defer(function () {
$.getJSON("https://mastodon.social/api/v1/accounts/295223/statuses?exclude_reblogs=1&exclude_replies&limit=5", function (data) {
initialize(data);
})
.fail(function () {
console.log("Error! Could not load the JSON file.");
});


// QUELL-KATEGORIE
var postData;
var CATEGORY = "Category:Blogpost";


// ANZAHL DER BEITRÄGE
function initialize(data) {
postData = data;
var LIMIT = 10;


$.each(postData, function (key, value) {
function loadWikiNews() {


$.getJSON(API_URL, {
action: "query",
generator: "categorymembers",
gcmtitle: CATEGORY,
gcmtype: "page",
gcmnamespace: 0,
gcmprop: "title|timestamp",
gcmlimit: LIMIT,
prop: "extracts|pageimages|info",
exintro: true,
explaintext: true,
exchars: 300,
piprop: "thumbnail",
pithumbsize: 900,
inprop: "url",
format: "json",
origin: "*"
})


.done(function (data) {
if (value.card !== null && value.media_attachments == "[]") {


var link = value.url;
var pages = data.query && data.query.pages
? Object.values(data.query.pages)
$(".post" + key + "Link").attr('href', link);
: [];


pages.sort(function (a, b) {
var image = $('#post' + key + 'Image');
var dataSrc = value.card.image;
return (a.index || 0) - (b.index || 0);
});
$(image).attr('data-src', dataSrc);


var title = value.application.name;
var wrapper = $("#wikiNewsSlides");
wrapper.empty();
var excerpt = value.content;


if (!pages.length) {
$("#post" + key + "Title").html(title);
$("#post" + key + "Excerpt").html(excerpt);
wrapper.html(
'<div class="swiper-slide">Keine Beiträge gefunden.</div>'
);
return;
}


$.each(pages, function (index, page) {


var title = $("<div>").text(page.title).html();
console.log(number);
var excerpt = $("<div>").text(
console.log('Hello, Dragon Ball!');
page.extract || ""
console.log(value.card);
).html();


var link = page.fullurl;
} else {
var link = value.url;
var image = page.thumbnail
$(".post" + key + "Link").attr('href', link);
? page.thumbnail.source
: "";


var image = $('#post' + key + 'Image');
var slide = $('<div class="swiper-slide newsSlide"></div>');
var dataSrc = value.media_attachments[0].url;
$(image).attr('data-src', dataSrc);


if (image) {
var title = value.application.name;
var excerpt = value.content;
$("<img>")
.attr("src", image)
.attr("alt", page.title)
.appendTo(slide);
}


$("#post" + key + "Title").html(title);
var caption = $('<div class="newsCaption"></div>');
$("#post" + key + "Excerpt").html(excerpt);


$("<a>")
.attr("href", link)
.attr("target", "_blank")
.attr("rel", "noopener")
.text(title)
.appendTo(caption);


$("<div>")
console.log('Hello, World!');
.addClass("newsExcerpt")
console.log(value.media_attachments[0].url);
.text(page.extract || "")
}
});
.appendTo(caption);


createSlider();
slide.append(caption);
wrapper.append(slide);
}


});


// SWIPER INITIALISIEREN
function createSlider() {
var swiper = new Swiper(".mySwiper", {
new Swiper(".newsSwiper", {
centeredSlides: true,
centeredSlides: true,
observer: true,
slidesPerView: 1,
observeParents: true,
loop: pages.length > 1,

slidesPerView: 1,
lazy: true,
autoplay: {
loop: true,
delay: 5500,
autoplay: {
disableOnInteraction: false
delay: 5500,
},

disableOnInteraction: false,
},
pagination: {
pagination: {
el: ".newsSwiper .swiper-pagination",
el: ".swiper-pagination",
clickable: true
clickable: true,
},

},
navigation: {
navigation: {
nextEl: ".swiper-button-next",
nextEl: ".newsSwiper .swiper-button-next",
prevEl: ".swiper-button-prev",
prevEl: ".newsSwiper .swiper-button-prev"
},
}
});
});

}
})

.fail(function (xhr, status, error) {
console.error("Wiki News Fehler:", error);
$("#wikiNewsSlides").html(
'<div class="swiper-slide">Beiträge konnten nicht geladen werden.</div>'
);
});
});
}

// Warten, bis jQuery und Swiper geladen sind
function initialize() {
if (window.jQuery && window.Swiper) {
loadWikiNews();
} else {
setTimeout(initialize, 100);
}
}

initialize();

})();
</script>
</script>

</includeonly>
</includeonly>

Aktuelle Version vom 6. November 2026, 19:04 Uhr

DragonballWiki News Widget