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
Gokussj7
Gokussj7 (Diskussion | Beiträge) (Die Seite wurde neu angelegt.)
 
 
(96 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%;
background-color: rgba(0, 0, 0, 0.8);
color: white;
text-shadow: 1px 1px 1px #333333;
right: 0;
right: 0;
padding: 5px;
left: 0;
padding: 10px;
background: rgba(0,0,0,0.8);
color: white;
text-align: left;
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 {
text-align: center;
font-size: 18px;
}
}


.swiper-button-next,
.newsSwiper .swiper-button-next,
.swiper-button-prev {
.newsSwiper .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://jojo-news.com/wp-json/wp/v2/posts?per_page=10", 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() {
var link = value.link;
$(".post" + key + "Link").attr('href', link);


$.getJSON(API_URL, {
var image = $('#post' + key + 'Image');
action: "query",
var dataSrc = value.uagb_featured_image_src.large[0];
generator: "categorymembers",
$(image).attr('data-src', dataSrc);
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) {
var title = value.title.rendered;
var excerpt = value.excerpt.rendered;


var pages = data.query && data.query.pages
$("#post" + key + "Title").html(title);
? Object.values(data.query.pages)
$("#post" + key + "Excerpt").html(excerpt);
});
: [];


pages.sort(function (a, b) {
createSlider();
return (a.index || 0) - (b.index || 0);
});


var wrapper = $("#wikiNewsSlides");
}
wrapper.empty();


function createSlider() {
if (!pages.length) {
wrapper.html(
var swiper = new Swiper(".mySwiper", {
'<div class="swiper-slide">Keine Beiträge gefunden.</div>'
centeredSlides: true,
observer: true,
);
observeParents: true,
return;
slidesPerView: 1,
lazy: true,
loop: true,
autoplay: {
delay: 5500,
disableOnInteraction: false,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
}
}

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

var title = $("<div>").text(page.title).html();
var excerpt = $("<div>").text(
page.extract || ""
).html();

var link = page.fullurl;
var image = page.thumbnail
? page.thumbnail.source
: "";

var slide = $('<div class="swiper-slide newsSlide"></div>');

if (image) {
$("<img>")
.attr("src", image)
.attr("alt", page.title)
.appendTo(slide);
}

var caption = $('<div class="newsCaption"></div>');

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

$("<div>")
.addClass("newsExcerpt")
.text(page.extract || "")
.appendTo(caption);

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

});

// SWIPER INITIALISIEREN
new Swiper(".newsSwiper", {
centeredSlides: true,
slidesPerView: 1,
loop: pages.length > 1,

autoplay: {
delay: 5500,
disableOnInteraction: false
},

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

navigation: {
nextEl: ".newsSwiper .swiper-button-next",
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