implement nbstand URL argument to enable carousel

This commit is contained in:
Stefan Schmidt-Bilkenroth 2024-11-15 11:00:44 +01:00
parent 973a3b9342
commit 678e08e681

View file

@ -55,6 +55,8 @@ let duration;
let refresh; let refresh;
// extra cards text // extra cards text
let extraCards; let extraCards;
// toggle Carousel
let withCarousel=false;
// fetchConfig fetches the configuration from the config.json file // fetchConfig fetches the configuration from the config.json file
const fetchConfig = async function() { const fetchConfig = async function() {
@ -336,6 +338,11 @@ $(document).ready(async function() {
const hashtagsArray = hashtags ? hashtags.split(',') : []; const hashtagsArray = hashtags ? hashtags.split(',') : [];
const serverUrl = getUrlParameter('server') || defaultServerUrl; const serverUrl = getUrlParameter('server') || defaultServerUrl;
const enableCarousel = getUrlParameter('nbstand' );
if ( enableCarousel == '1' )
withCarousel = true;
console.log("show carousel: "+withCarousel);
$('#hashtag-display').on('click', function() { $('#hashtag-display').on('click', function() {
handleHashtagDisplayClick(serverUrl); handleHashtagDisplayClick(serverUrl);
}); });
@ -351,13 +358,14 @@ $(document).ready(async function() {
$('.masonry-grid').masonry('layout'); $('.masonry-grid').masonry('layout');
}, 2000); }, 2000);
updateCarousel(slides, allPosts.flat()); if ( withCarousel) {
updateCarousel(slides, allPosts.flat());
setTimeout(async function() { showCarousel(); }, duration) setTimeout(async function() { showCarousel(); }, duration)
}
setInterval(async function() { setInterval(async function() {
const newPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag))); const newPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag)));
let updated = updateWall(newPosts.flat()); let updated = updateWall(newPosts.flat());
if ( updated > 0 ) { if ( withCarousel && updated > 0 ) {
updateCarousel(slides, newPosts.flat()); updateCarousel(slides, newPosts.flat());
} }
}, refresh); }, refresh);