From 06080e09a1624b9d4bd62f29909ef3cb63596dac Mon Sep 17 00:00:00 2001 From: Stefan Schmidt-Bilkenroth Date: Thu, 16 Nov 2023 16:14:06 +0100 Subject: [PATCH] fix some startup issues, default to BDK config --- script.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/script.js b/script.js index 325f193..cb17ad2 100644 --- a/script.js +++ b/script.js @@ -12,6 +12,7 @@ function getUrlParameter(name) { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var results = regex.exec(location.search); + console.log(results) return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); } @@ -49,7 +50,11 @@ const fetchConfig = async function() { includeReplies = config.includeReplies; return config.defaultServerUrl; } catch (error) { - console.error("Error loading config.json:", error); + console.log("Error loading config.json:", error); + $('#navbar-brand').text("Netzbegrünung Mastowall"); + $('.navbar').css('background-color', "#008939"); + includeReplies = true; + return "https://gruene.social"; } } @@ -161,7 +166,7 @@ const updateCarousel = function(slides, posts) { const showCarousel = function() { // show popover - document.getElementById('popover').style.opacity = '0.95'; + document.getElementById('popover').style.opacity = '1'; // Activate Carousel $('#myCarousel').carousel("cycle"); } @@ -194,6 +199,9 @@ const handleHashtagDisplayClick = function(serverUrl) { $('#zero-state').removeClass('d-none'); const currentHashtags = getUrlParameter('hashtags').split(','); + if ( currentHashtags = null ) { + currentHasttags = "netzbegruenung,bdk23".split(',') + } for (let i = 0; i < currentHashtags.length; i++) { $(`#hashtag${i+1}`).val(currentHashtags[i]); @@ -239,9 +247,12 @@ $(document).ready(async function() { setInterval(function() { $('.masonry-grid').masonry('layout'); - }, 10000); + }, refresh); - const hashtags = getUrlParameter('hashtags'); + let hashtags = getUrlParameter('hashtags'); + if ( hashtags == '' ) { + hashtags = "netzbegruenung,bdk23"; + } const hashtagsArray = hashtags ? hashtags.split(',') : []; const serverUrl = getUrlParameter('server') || defaultServerUrl; @@ -255,6 +266,10 @@ $(document).ready(async function() { if (hashtagsArray.length > 0 && hashtagsArray[0] !== '') { const allPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag))); updateWall(allPosts.flat()); + setTimeout(function() { + $('.masonry-grid').masonry('layout'); + }, 100); + updateCarousel(slides, allPosts.flat()); setTimeout(async function() { showCarousel(); }, duration)