fix some startup issues, default to BDK config

This commit is contained in:
Stefan Schmidt-Bilkenroth 2023-11-16 16:14:06 +01:00
parent c951f47034
commit 06080e09a1

View file

@ -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)