Widget:DragonballWikiNews: Unterschied zwischen den Versionen
Aus DragonballWiki
Weitere Optionen
Inhalt gelöscht Inhalt hinzugefügt
| (4 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> |
||
. |
.newsSwiper { |
||
width: |
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 { |
|||
width: 100%; |
|||
height: 100%; |
|||
object-fit: cover; |
|||
text-transform: uppercase; |
|||
} |
} |
||
. |
.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; |
||
left: 0; |
|||
padding: 10px; |
|||
background: rgba(0,0,0,0.8); |
|||
color: white; |
|||
text-align: left; |
|||
line-height: 1.5; |
line-height: 1.5; |
||
} |
} |
||
. |
.newsCaption a { |
||
color: white; |
color: white !important; |
||
font-weight: bold; |
|||
text-transform: uppercase; |
text-transform: uppercase; |
||
text-decoration: none; |
|||
} |
} |
||
. |
.newsExcerpt { |
||
font-size: small; |
|||
color: white !important; |
|||
margin-top: 5px; |
|||
letter-spacing: -1px; |
|||
} |
} |
||
.swiper- |
.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; |
|||
} |
} |
||
. |
.newsSwiper .swiper-pagination-bullet { |
||
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) { |
|||
// API-ENDPUNKT DES QUELL-WIKIS |
|||
if (window.jQuery) { |
|||
var API_URL = "https://bratpfannenberg.com/mediawiki/api.php"; |
|||
method(); |
|||
} else { |
|||
// QUELL-KATEGORIE |
|||
setTimeout(function () { defer(method) }, 40); |
|||
var CATEGORY = "Category:Blogpost"; |
|||
// ANZAHL DER BEITRÄGE |
|||
var LIMIT = 10; |
|||
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) { |
|||
var pages = data.query && data.query.pages |
|||
? Object.values(data.query.pages) |
|||
: []; |
|||
pages.sort(function (a, b) { |
|||
return (a.index || 0) - (b.index || 0); |
|||
}); |
|||
var wrapper = $("#wikiNewsSlides"); |
|||
wrapper.empty(); |
|||
if (!pages.length) { |
|||
wrapper.html( |
|||
'<div class="swiper-slide">Keine Beiträge gefunden.</div>' |
|||
); |
|||
return; |
|||
} |
} |
||
} |
|||
$.each(pages, function (index, page) { |
|||
// INITIALISATION |
|||
defer(function () { |
|||
$.getJSON("https://mastodon.social/api/v1/accounts/295223/statuses?exclude_replies=1&exclude_reblogs=1&limit=5&max_id=111257986610248478&exclude_card=true", function (data) { |
|||
initialize(data); |
|||
}) |
|||
.fail(function () { |
|||
console.log("Error! Could not load the JSON file."); |
|||
}); |
|||
var title = $("<div>").text(page.title).html(); |
|||
var postData; |
|||
var excerpt = $("<div>").text( |
|||
page.extract || "" |
|||
).html(); |
|||
var link = page.fullurl; |
|||
function initialize(data) { |
|||
var image = page.thumbnail |
|||
? page.thumbnail.source |
|||
: ""; |
|||
var slide = $('<div class="swiper-slide newsSlide"></div>'); |
|||
$.each(postData, function (key, value) { |
|||
if (image) { |
|||
$("<img>") |
|||
.attr("src", image) |
|||
.attr("alt", page.title) |
|||
.appendTo(slide); |
|||
} |
|||
var caption = $('<div class="newsCaption"></div>'); |
|||
$(".post" + key + "Link").attr('href', link); |
|||
$("<a>") |
|||
.attr("href", link) |
|||
var dataSrc = value.media_attachments[0]; |
|||
.attr("target", "_blank") |
|||
.attr("rel", "noopener") |
|||
.text(title) |
|||
.appendTo(caption); |
|||
$("<div>") |
|||
var title = value.application.name; |
|||
.addClass("newsExcerpt") |
|||
var excerpt = value.content; |
|||
.text(page.extract || "") |
|||
.appendTo(caption); |
|||
slide.append(caption); |
|||
wrapper.append(slide); |
|||
}); |
|||
// SWIPER INITIALISIEREN |
|||
console.log('Hello, Dragon Ball!'); |
|||
new Swiper(".newsSwiper", { |
|||
console.log(value.media_attachments[0]); |
|||
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" |
|||
} |
|||
}); |
|||
}) |
|||
function createSlider() { |
|||
var swiper = new Swiper(".mySwiper", { |
|||
.fail(function (xhr, status, error) { |
|||
centeredSlides: true, |
|||
console.error("Wiki News Fehler:", error); |
|||
observer: true, |
|||
$("#wikiNewsSlides").html( |
|||
observeParents: true, |
|||
'<div class="swiper-slide">Beiträge konnten nicht geladen werden.</div>' |
|||
slidesPerView: 1, |
|||
); |
|||
loop: true, |
|||
autoplay: { |
|||
delay: 5500, |
|||
disableOnInteraction: false, |
|||
}, |
|||
pagination: { |
|||
el: ".swiper-pagination", |
|||
clickable: true, |
|||
}, |
|||
navigation: { |
|||
nextEl: ".swiper-button-next", |
|||
prevEl: ".swiper-button-prev", |
|||
}, |
|||
}); |
|||
} |
|||
}); |
}); |
||
} |
|||
// 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