2023-05-19 16:16:49 +02:00
|
|
|
// The existingPosts array is used to track already displayed posts
|
2023-05-17 15:46:48 +02:00
|
|
|
let existingPosts = [];
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// getUrlParameter helps to fetch URL parameters
|
2023-05-19 14:58:02 +02:00
|
|
|
function getUrlParameter(name) {
|
|
|
|
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
|
|
|
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
|
|
|
var results = regex.exec(location.search);
|
2023-11-16 16:14:06 +01:00
|
|
|
console.log(results)
|
2023-05-19 14:58:02 +02:00
|
|
|
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
|
|
}
|
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// secondsAgo calculates how many seconds have passed since the provided date
|
2023-05-19 14:58:02 +02:00
|
|
|
const secondsAgo = date => Math.floor((new Date() - date) / 1000);
|
2023-05-19 16:16:49 +02:00
|
|
|
|
|
|
|
// timeAgo formats the time elapsed in a human readable format
|
2023-05-19 14:58:02 +02:00
|
|
|
const timeAgo = function(seconds) {
|
2023-05-19 16:16:49 +02:00
|
|
|
// An array of intervals for years, months, days, hours, and minutes.
|
2023-05-19 14:58:02 +02:00
|
|
|
const intervals = [
|
2023-11-23 20:44:42 +01:00
|
|
|
{ limit: 31536000, singular: 'Jahre', plural: 'Jahren' },
|
|
|
|
{ limit: 2592000, singular: 'Monat', plural: 'Monaten' },
|
|
|
|
{ limit: 86400, singular: 'Tag', plural: 'Tagen' },
|
|
|
|
{ limit: 3600, singular: 'Stunde', plural: 'Stunden' },
|
|
|
|
{ limit: 60, singular: 'Minute', plural: 'Minuten' }
|
2023-05-19 14:58:02 +02:00
|
|
|
];
|
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// Loop through the intervals to find which one is the best fit.
|
2023-05-19 14:58:02 +02:00
|
|
|
for (let interval of intervals) {
|
|
|
|
if (seconds >= interval.limit) {
|
2023-11-23 20:44:42 +01:00
|
|
|
let amount = Math.floor(seconds / interval.limit);
|
|
|
|
let text;
|
|
|
|
if (amount !== 1) {
|
|
|
|
text = interval.plural;
|
|
|
|
} else {
|
|
|
|
text = interval.singular;
|
|
|
|
}
|
|
|
|
return `Vor ${amount} ${text}`;
|
2023-05-19 14:58:02 +02:00
|
|
|
}
|
2023-05-17 15:46:48 +02:00
|
|
|
}
|
2023-11-23 20:44:42 +01:00
|
|
|
let text = "Sekunde";
|
|
|
|
let amount = Math.floor(seconds);
|
|
|
|
if (amount !== 1) {
|
|
|
|
text += "n";
|
|
|
|
}
|
|
|
|
return `Vor ${amount} ${text}`;
|
2023-05-19 14:58:02 +02:00
|
|
|
};
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
let includeReplies;
|
2023-11-23 20:44:41 +01:00
|
|
|
// max post age in seconds
|
|
|
|
let maxAge;
|
2023-11-23 20:44:38 +01:00
|
|
|
// below times are in milliseconds
|
|
|
|
// duration for slide animations
|
|
|
|
let duration;
|
|
|
|
// refresh rate
|
|
|
|
let refresh;
|
2023-11-23 20:44:41 +01:00
|
|
|
// extra cards text
|
|
|
|
let extraCards;
|
2023-05-19 16:16:49 +02:00
|
|
|
|
|
|
|
// fetchConfig fetches the configuration from the config.json file
|
2023-05-19 14:58:02 +02:00
|
|
|
const fetchConfig = async function() {
|
|
|
|
try {
|
|
|
|
const config = await $.getJSON('config.json');
|
|
|
|
$('#navbar-brand').text(config.navbarBrandText);
|
2023-05-19 16:16:49 +02:00
|
|
|
$('.navbar').css('background-color', config.navbarColor);
|
|
|
|
includeReplies = config.includeReplies;
|
2023-11-23 20:44:41 +01:00
|
|
|
maxAge = config.maxAge;
|
2023-11-23 20:44:38 +01:00
|
|
|
duration = config.duration * 1000;
|
|
|
|
refresh = config.refreshDuration * 1000;
|
2023-11-23 20:44:41 +01:00
|
|
|
extraCards = config.extraCards;
|
2023-05-19 14:58:02 +02:00
|
|
|
return config.defaultServerUrl;
|
|
|
|
} catch (error) {
|
2023-11-16 16:14:06 +01:00
|
|
|
console.log("Error loading config.json:", error);
|
2023-11-23 20:48:46 +01:00
|
|
|
$('#navbar-brand').text("Netzbegrünung Mastowall - gruene.social");
|
2023-11-16 16:14:06 +01:00
|
|
|
$('.navbar').css('background-color', "#008939");
|
|
|
|
includeReplies = true;
|
2023-11-23 20:44:41 +01:00
|
|
|
maxAge = 60 * 60 * 24 * 7;
|
2023-11-23 20:44:38 +01:00
|
|
|
duration = 10000;
|
|
|
|
refresh = 30000;
|
2023-11-23 20:44:41 +01:00
|
|
|
extraCards = [
|
|
|
|
"<div><img src='sharepic.jpg' style='max-width: 100%;max-height: 100%'></div>"
|
|
|
|
];
|
2023-11-16 16:14:06 +01:00
|
|
|
return "https://gruene.social";
|
2023-05-19 14:58:02 +02:00
|
|
|
}
|
|
|
|
}
|
2023-05-18 02:43:37 +02:00
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// fetchPosts fetches posts from the server using the given hashtag
|
2023-05-19 14:58:02 +02:00
|
|
|
const fetchPosts = async function(serverUrl, hashtag) {
|
|
|
|
try {
|
|
|
|
const posts = await $.get(`${serverUrl}/api/v1/timelines/tag/${hashtag}?limit=20`);
|
|
|
|
return posts;
|
|
|
|
} catch (error) {
|
|
|
|
console.error(`Error loading posts for hashtag #${hashtag}:`, error);
|
|
|
|
}
|
|
|
|
};
|
2023-05-18 02:43:37 +02:00
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// updateTimesOnPage updates the time information displayed for each post
|
2023-05-19 14:58:02 +02:00
|
|
|
const updateTimesOnPage = function() {
|
2023-11-24 12:25:34 +01:00
|
|
|
$('.card-text a.time').each(function() {
|
|
|
|
const timeValue = $(this).attr('data-time');
|
|
|
|
if (timeValue === '') return;
|
|
|
|
const date = new Date(timeValue);
|
2023-05-19 14:58:02 +02:00
|
|
|
const newTimeAgo = timeAgo(secondsAgo(date));
|
2023-05-18 02:43:37 +02:00
|
|
|
$(this).text(newTimeAgo);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// displayPost creates and displays a post
|
2023-05-19 14:58:02 +02:00
|
|
|
const displayPost = function(post) {
|
2023-11-10 19:42:57 +01:00
|
|
|
if (existingPosts.includes(post.id) || (!includeReplies && post.in_reply_to_id !== null)) return 0;
|
2023-05-17 23:58:12 +02:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
existingPosts.push(post.id);
|
2023-05-17 23:58:12 +02:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
let cardHTML = `
|
|
|
|
<div class="col-sm-3">
|
|
|
|
<div class="card m-2 p-2">
|
|
|
|
<div class="d-flex align-items-center mb-2">
|
|
|
|
<img src="${post.account.avatar}" class="avatar-img rounded-circle mr-2">
|
2023-11-23 22:06:42 +01:00
|
|
|
<p class="m-0">${DOMPurify.sanitize(post.account.display_name)} <span class="user-name">@${DOMPurify.sanitize(post.account.acct)}</span></p>
|
2023-05-19 14:58:02 +02:00
|
|
|
</div>
|
|
|
|
${post.media_attachments[0] ? `<img src="${post.media_attachments[0].url}" class="card-img-top mb-2">` : ''}
|
2023-05-26 10:12:47 +02:00
|
|
|
<p class="card-text">${DOMPurify.sanitize(post.content)}</p>
|
|
|
|
${post.spoiler_text ? `<p class="card-text text-muted spoiler">${DOMPurify.sanitize(post.spoiler_text)}</p>` : ''}
|
2023-11-24 12:25:34 +01:00
|
|
|
<p class="card-text text-right"><small class="text-muted"><a class="time" href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a></small></p>
|
2023-05-19 14:58:02 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
|
|
|
|
let $card = $(cardHTML);
|
|
|
|
$('#wall').prepend($card);
|
|
|
|
$('.masonry-grid').masonry('prepended', $card);
|
2023-11-10 19:42:57 +01:00
|
|
|
return 1;
|
2023-05-19 14:58:02 +02:00
|
|
|
};
|
2023-05-17 23:58:12 +02:00
|
|
|
|
2023-11-23 20:44:41 +01:00
|
|
|
const processPosts = function(posts) {
|
2023-11-23 21:57:58 +01:00
|
|
|
posts = posts.filter((post) => {
|
|
|
|
return secondsAgo(new Date(post.created_at)) < maxAge && post.content.indexOf("nitter.") === -1
|
|
|
|
});
|
2023-11-23 20:44:41 +01:00
|
|
|
|
|
|
|
return posts;
|
|
|
|
};
|
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// updateWall displays all posts
|
2023-05-19 14:58:02 +02:00
|
|
|
const updateWall = function(posts) {
|
|
|
|
if (!posts || posts.length === 0) return;
|
2023-05-17 23:58:12 +02:00
|
|
|
|
2023-11-23 20:44:41 +01:00
|
|
|
posts = processPosts(posts);
|
|
|
|
|
2023-11-23 20:57:33 +01:00
|
|
|
posts.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
|
|
|
|
|
2023-11-10 19:42:57 +01:00
|
|
|
let ret = 0
|
|
|
|
posts.forEach(post => ret += displayPost(post));
|
|
|
|
$('.masonry-grid').masonry('layout');
|
|
|
|
return ret;
|
2023-11-10 17:16:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// updateCarousel
|
|
|
|
const updateCarousel = function(slides, posts) {
|
|
|
|
if (!posts || posts.length === 0) return;
|
|
|
|
|
2023-11-23 20:44:41 +01:00
|
|
|
posts = processPosts(posts);
|
2023-11-23 20:57:33 +01:00
|
|
|
|
|
|
|
posts.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
|
|
|
|
|
2023-11-10 17:16:31 +01:00
|
|
|
// remove slides in carousel
|
|
|
|
slides.innerHTML = "";
|
2023-11-10 19:42:57 +01:00
|
|
|
var newHTML = ` <!-- No Indicators -->`
|
2023-11-10 17:16:31 +01:00
|
|
|
newHTML += `<!-- the slides -->
|
|
|
|
<div class="carousel-inner">
|
2023-11-24 12:08:19 +01:00
|
|
|
`;
|
|
|
|
|
|
|
|
let existingCards = [];
|
|
|
|
|
2023-11-10 17:16:31 +01:00
|
|
|
for( let i = 0; i < posts.length; i++ ) {
|
|
|
|
let post = posts[i];
|
2023-11-24 12:08:19 +01:00
|
|
|
|
|
|
|
if (existingCards.includes(post.id) || (!includeReplies && post.in_reply_to_id !== null)) continue;
|
|
|
|
|
|
|
|
existingCards.push(post.id);
|
|
|
|
|
2023-11-16 14:45:16 +01:00
|
|
|
/*console.log( post.content )*/
|
2023-11-10 17:16:31 +01:00
|
|
|
if ( i == 0 ) {
|
2023-11-16 18:01:30 +01:00
|
|
|
newHTML += `<div class="carousel-item active" data-mdb-interval="${duration}" data-mdb-pause="false">`;
|
2023-11-10 17:16:31 +01:00
|
|
|
}
|
|
|
|
else {
|
2023-11-16 18:01:30 +01:00
|
|
|
newHTML += `<div class="carousel-item" data-mdb-interval="${duration}" data-mdb-pause="false">`;
|
2023-11-10 17:16:31 +01:00
|
|
|
}
|
2023-11-24 12:45:28 +01:00
|
|
|
const postContent = DOMPurify.sanitize(post.content);
|
2023-11-10 17:16:31 +01:00
|
|
|
newHTML += `
|
2023-11-10 19:42:57 +01:00
|
|
|
<div class="card-big">
|
|
|
|
<div class="d-flex align-items-center mb-4">
|
|
|
|
<img src="${post.account.avatar}" class="avatar-img-big rounded-circle mr-4">
|
2023-11-23 22:06:42 +01:00
|
|
|
<p class="avatar-name">${DOMPurify.sanitize(post.account.display_name)} <span class="user-name">@${DOMPurify.sanitize(post.account.acct)}</span></p>
|
2023-11-10 17:16:31 +01:00
|
|
|
</div>
|
2023-11-10 19:42:57 +01:00
|
|
|
<hr>
|
2023-11-16 14:45:16 +01:00
|
|
|
<div class="row align-items-center vertical-align-center">
|
2023-11-24 12:45:28 +01:00
|
|
|
<div class="${post.media_attachments[0] ? `col-md-6` : `col-md-12`}"><div class="card-text" ${strip(postContent).length > 800 ? `style="font-size: 0.9em;"`: ``}>${postContent}</div></div>
|
2023-11-16 12:18:48 +01:00
|
|
|
${post.media_attachments[0] ? `<div class="col-md-6"><img src="${post.media_attachments[0].url}" class="card-img-bottom" align="center"> </div>` : ''}
|
2023-11-10 17:16:31 +01:00
|
|
|
</div>
|
2023-11-10 19:42:57 +01:00
|
|
|
<hr>
|
2023-11-16 14:45:16 +01:00
|
|
|
<p class="card-text text-right">
|
2023-11-24 12:25:34 +01:00
|
|
|
<small class="text-muted"><a class="time" href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a>
|
2023-11-16 14:45:16 +01:00
|
|
|
${post.favourites_count ? `, <b>${post.favourites_count}</b> mal favorisiert` : '' }
|
2023-11-16 14:51:31 +01:00
|
|
|
${post.replies_count ? `, <b>${post.replies_count}</b> mal kommentiert` : '' }
|
2023-11-16 14:45:16 +01:00
|
|
|
${post.reblogs_count ? `, <b>${post.reblogs_count}</b> mal geteilt` : '' }
|
|
|
|
</small>
|
|
|
|
</p>
|
2023-11-10 19:42:57 +01:00
|
|
|
</div>
|
2023-11-10 17:16:31 +01:00
|
|
|
`;
|
|
|
|
newHTML += '</div>';
|
|
|
|
}
|
2023-11-23 20:44:41 +01:00
|
|
|
for( let i = 0; i < extraCards.length; i++ ) {
|
2023-11-23 21:06:54 +01:00
|
|
|
newHTML += `<div class="carousel-item" data-mdb-interval="${duration * 2}" data-mdb-pause="false">
|
2023-11-23 20:44:41 +01:00
|
|
|
<div className="card-big">
|
|
|
|
<div class="d-flex align-items-center mb-4">
|
|
|
|
${extraCards[i]}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
}
|
2023-11-10 17:16:31 +01:00
|
|
|
newHTML += '</div>'
|
|
|
|
document.getElementById("myCarousel").innerHTML = newHTML;
|
|
|
|
};
|
|
|
|
|
2023-11-10 19:42:57 +01:00
|
|
|
const showCarousel = function() {
|
|
|
|
// show popover
|
2023-11-16 16:14:06 +01:00
|
|
|
document.getElementById('popover').style.opacity = '1';
|
2023-11-10 19:42:57 +01:00
|
|
|
// Activate Carousel
|
|
|
|
$('#myCarousel').carousel("cycle");
|
|
|
|
}
|
|
|
|
|
2023-11-24 12:45:28 +01:00
|
|
|
const strip = function(html) {
|
|
|
|
let doc = new DOMParser().parseFromString(html, 'text/html');
|
|
|
|
return doc.body.textContent || "";
|
|
|
|
}
|
|
|
|
|
2023-11-10 19:42:57 +01:00
|
|
|
const hideCarousel = function() {
|
|
|
|
// show popover
|
|
|
|
document.getElementById('popover').style.opacity = '0';
|
|
|
|
// Activate Carousel
|
|
|
|
}
|
2023-11-10 17:16:31 +01:00
|
|
|
|
2023-06-05 12:23:01 +02:00
|
|
|
// hashtagsString returns a single string based on the given array of hashtags
|
|
|
|
const hashtagsString = function(hashtagsArray) {
|
|
|
|
return `${hashtagsArray.map(hashtag => `#${hashtag}`).join(' ')}`;
|
|
|
|
}
|
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// updateHashtagsOnPage updates the displayed hashtags
|
2023-05-19 14:58:02 +02:00
|
|
|
const updateHashtagsOnPage = function(hashtagsArray) {
|
2023-06-05 12:23:01 +02:00
|
|
|
$('#hashtag-display').text(hashtagsArray.length > 0 ? hashtagsString(hashtagsArray) : 'No hashtags set');
|
2023-05-19 14:58:02 +02:00
|
|
|
};
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-06-05 12:23:01 +02:00
|
|
|
// updateHashtagsOnPage updates the document title by appending the given array of hashtags
|
|
|
|
const updateHashtagsInTitle = function(hashtagsArray) {
|
|
|
|
const baseTitle = document.title;
|
|
|
|
document.title = `${baseTitle} | ${hashtagsString(hashtagsArray)}`;
|
|
|
|
}
|
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// handleHashtagDisplayClick handles the event when the hashtag display is clicked
|
2023-05-19 14:58:02 +02:00
|
|
|
const handleHashtagDisplayClick = function(serverUrl) {
|
|
|
|
$('#app-content').addClass('d-none');
|
|
|
|
$('#zero-state').removeClass('d-none');
|
2023-05-17 23:58:12 +02:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
const currentHashtags = getUrlParameter('hashtags').split(',');
|
2023-11-16 16:14:06 +01:00
|
|
|
if ( currentHashtags = null ) {
|
|
|
|
currentHasttags = "netzbegruenung,bdk23".split(',')
|
|
|
|
}
|
2023-05-19 14:58:02 +02:00
|
|
|
|
|
|
|
for (let i = 0; i < currentHashtags.length; i++) {
|
|
|
|
$(`#hashtag${i+1}`).val(currentHashtags[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#serverUrl').val(serverUrl);
|
|
|
|
};
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// handleHashtagFormSubmit handles the submission of the hashtag form
|
2023-05-19 14:58:02 +02:00
|
|
|
const handleHashtagFormSubmit = function(e, hashtagsArray) {
|
|
|
|
e.preventDefault();
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
let hashtags = [
|
|
|
|
$('#hashtag1').val(),
|
|
|
|
$('#hashtag2').val(),
|
|
|
|
$('#hashtag3').val()
|
|
|
|
];
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
hashtags = hashtags.filter(function(hashtag) {
|
|
|
|
return hashtag !== '' && /^[\w]+$/.test(hashtag);
|
2023-05-17 15:46:48 +02:00
|
|
|
});
|
2023-05-19 14:58:02 +02:00
|
|
|
|
|
|
|
let serverUrl = $('#serverUrl').val();
|
|
|
|
|
|
|
|
if (!/^https:\/\/[\w.\-]+\/?$/.test(serverUrl)) {
|
|
|
|
alert('Invalid server URL.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const newUrl = window.location.origin + window.location.pathname + `?hashtags=${hashtags.join(',')}&server=${serverUrl}`;
|
|
|
|
|
|
|
|
window.location.href = newUrl;
|
2023-05-17 15:46:48 +02:00
|
|
|
};
|
2023-05-17 02:13:01 +02:00
|
|
|
|
2023-05-19 16:16:49 +02:00
|
|
|
// On document ready, the script configures Masonry, handles events, fetches and displays posts
|
2023-05-19 14:58:02 +02:00
|
|
|
$(document).ready(async function() {
|
|
|
|
const defaultServerUrl = await fetchConfig();
|
2023-05-17 15:46:48 +02:00
|
|
|
$('.masonry-grid').masonry({
|
|
|
|
itemSelector: '.col-sm-3',
|
|
|
|
columnWidth: '.col-sm-3',
|
|
|
|
percentPosition: true
|
2023-05-17 02:13:01 +02:00
|
|
|
});
|
2023-05-17 15:46:48 +02:00
|
|
|
|
2023-05-18 10:49:55 +02:00
|
|
|
setInterval(function() {
|
|
|
|
$('.masonry-grid').masonry('layout');
|
2023-11-16 16:14:06 +01:00
|
|
|
}, refresh);
|
2023-11-10 17:16:31 +01:00
|
|
|
|
2023-11-16 16:14:06 +01:00
|
|
|
let hashtags = getUrlParameter('hashtags');
|
|
|
|
if ( hashtags == '' ) {
|
|
|
|
hashtags = "netzbegruenung,bdk23";
|
|
|
|
}
|
2023-05-19 14:58:02 +02:00
|
|
|
const hashtagsArray = hashtags ? hashtags.split(',') : [];
|
|
|
|
const serverUrl = getUrlParameter('server') || defaultServerUrl;
|
2023-05-18 09:48:01 +02:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
$('#hashtag-display').on('click', function() {
|
|
|
|
handleHashtagDisplayClick(serverUrl);
|
2023-05-18 09:48:01 +02:00
|
|
|
});
|
|
|
|
|
2023-11-10 17:16:31 +01:00
|
|
|
const slides = $('#myCarousel');
|
2023-11-10 19:42:57 +01:00
|
|
|
const popover = $('#popover');
|
2023-11-10 17:16:31 +01:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
if (hashtagsArray.length > 0 && hashtagsArray[0] !== '') {
|
2023-11-23 20:44:41 +01:00
|
|
|
let allPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag)));
|
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
updateWall(allPosts.flat());
|
2023-11-16 16:14:06 +01:00
|
|
|
setTimeout(function() {
|
|
|
|
$('.masonry-grid').masonry('layout');
|
2023-11-16 16:22:59 +01:00
|
|
|
}, 2000);
|
2023-11-16 16:14:06 +01:00
|
|
|
|
2023-11-10 19:59:46 +01:00
|
|
|
updateCarousel(slides, allPosts.flat());
|
2023-11-10 19:42:57 +01:00
|
|
|
|
|
|
|
setTimeout(async function() { showCarousel(); }, duration)
|
2023-05-19 14:58:02 +02:00
|
|
|
setInterval(async function() {
|
|
|
|
const newPosts = await Promise.all(hashtagsArray.map(hashtag => fetchPosts(serverUrl, hashtag)));
|
2023-11-10 19:42:57 +01:00
|
|
|
let updated = updateWall(newPosts.flat());
|
|
|
|
if ( updated > 0 ) {
|
|
|
|
hideCarousel()
|
2023-11-10 19:59:46 +01:00
|
|
|
updateCarousel(slides, newPosts.flat());
|
2023-11-10 19:42:57 +01:00
|
|
|
setTimeout(async function() { showCarousel(); }, duration)
|
|
|
|
}
|
|
|
|
}, refresh);
|
2023-05-18 02:43:37 +02:00
|
|
|
} else {
|
|
|
|
$('#zero-state').removeClass('d-none');
|
2023-11-10 20:35:20 +01:00
|
|
|
$('#popover').removeClass('popover');
|
2023-05-18 02:43:37 +02:00
|
|
|
$('#app-content').addClass('d-none');
|
|
|
|
}
|
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
updateHashtagsOnPage(hashtagsArray);
|
2023-06-05 12:23:01 +02:00
|
|
|
updateHashtagsInTitle(hashtagsArray);
|
2023-05-18 02:43:37 +02:00
|
|
|
|
2023-05-18 09:48:01 +02:00
|
|
|
$('#hashtag-form').on('submit', function(e) {
|
2023-05-19 14:58:02 +02:00
|
|
|
handleHashtagFormSubmit(e, hashtagsArray);
|
2023-05-18 09:48:01 +02:00
|
|
|
});
|
|
|
|
|
2023-11-10 17:16:31 +01:00
|
|
|
|
2023-05-19 14:58:02 +02:00
|
|
|
updateTimesOnPage();
|
|
|
|
setInterval(updateTimesOnPage, 60000);
|
2023-05-17 02:13:01 +02:00
|
|
|
});
|