for-pi2 #2
1 changed files with 19 additions and 4 deletions
23
script.js
23
script.js
|
@ -12,6 +12,7 @@ function getUrlParameter(name) {
|
||||||
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
||||||
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
||||||
var results = regex.exec(location.search);
|
var results = regex.exec(location.search);
|
||||||
|
console.log(results)
|
||||||
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +50,11 @@ const fetchConfig = async function() {
|
||||||
includeReplies = config.includeReplies;
|
includeReplies = config.includeReplies;
|
||||||
return config.defaultServerUrl;
|
return config.defaultServerUrl;
|
||||||
} catch (error) {
|
} 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() {
|
const showCarousel = function() {
|
||||||
// show popover
|
// show popover
|
||||||
document.getElementById('popover').style.opacity = '0.95';
|
document.getElementById('popover').style.opacity = '1';
|
||||||
// Activate Carousel
|
// Activate Carousel
|
||||||
$('#myCarousel').carousel("cycle");
|
$('#myCarousel').carousel("cycle");
|
||||||
}
|
}
|
||||||
|
@ -194,6 +199,9 @@ const handleHashtagDisplayClick = function(serverUrl) {
|
||||||
$('#zero-state').removeClass('d-none');
|
$('#zero-state').removeClass('d-none');
|
||||||
|
|
||||||
const currentHashtags = getUrlParameter('hashtags').split(',');
|
const currentHashtags = getUrlParameter('hashtags').split(',');
|
||||||
|
if ( currentHashtags = null ) {
|
||||||
|
currentHasttags = "netzbegruenung,bdk23".split(',')
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < currentHashtags.length; i++) {
|
for (let i = 0; i < currentHashtags.length; i++) {
|
||||||
$(`#hashtag${i+1}`).val(currentHashtags[i]);
|
$(`#hashtag${i+1}`).val(currentHashtags[i]);
|
||||||
|
@ -239,9 +247,12 @@ $(document).ready(async function() {
|
||||||
|
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
$('.masonry-grid').masonry('layout');
|
$('.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 hashtagsArray = hashtags ? hashtags.split(',') : [];
|
||||||
const serverUrl = getUrlParameter('server') || defaultServerUrl;
|
const serverUrl = getUrlParameter('server') || defaultServerUrl;
|
||||||
|
|
||||||
|
@ -255,6 +266,10 @@ $(document).ready(async function() {
|
||||||
if (hashtagsArray.length > 0 && hashtagsArray[0] !== '') {
|
if (hashtagsArray.length > 0 && hashtagsArray[0] !== '') {
|
||||||
const allPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag)));
|
const allPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag)));
|
||||||
updateWall(allPosts.flat());
|
updateWall(allPosts.flat());
|
||||||
|
setTimeout(function() {
|
||||||
|
$('.masonry-grid').masonry('layout');
|
||||||
|
}, 100);
|
||||||
|
|
||||||
updateCarousel(slides, allPosts.flat());
|
updateCarousel(slides, allPosts.flat());
|
||||||
|
|
||||||
setTimeout(async function() { showCarousel(); }, duration)
|
setTimeout(async function() { showCarousel(); }, duration)
|
||||||
|
|
Loading…
Reference in a new issue