diff --git a/config.json b/config.json
index 251cbb0..7c8a82d 100644
--- a/config.json
+++ b/config.json
@@ -1,12 +1,6 @@
{
- "navbarBrandText": "Netzbegrünung Mastowall - gruene.social",
+ "navbarBrandText": "Netzbegrünung Mastowall",
"defaultServerUrl": "https://gruene.social",
"navbarColor": "#008939",
- "duration": 10,
- "refreshDuration": 30,
- "maxAge": 604800,
- "extraCards": [
- ""
- ],
"includeReplies": true
}
diff --git a/script.js b/script.js
index b87dded..af74d3b 100644
--- a/script.js
+++ b/script.js
@@ -1,6 +1,12 @@
// The existingPosts array is used to track already displayed posts
let existingPosts = [];
+// below times are in milliseconds
+// duration for slide animations
+let duration = 5000;
+// refresh rate
+let refresh = 30000;
+
// getUrlParameter helps to fetch URL parameters
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
@@ -17,44 +23,23 @@ const secondsAgo = date => Math.floor((new Date() - date) / 1000);
const timeAgo = function(seconds) {
// An array of intervals for years, months, days, hours, and minutes.
const intervals = [
- { 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' }
+ { limit: 31536000, text: 'Jahren' },
+ { limit: 2592000, text: 'Monaten' },
+ { limit: 86400, text: 'Tagen' },
+ { limit: 3600, text: 'Stunden' },
+ { limit: 60, text: 'Minuten' }
];
// Loop through the intervals to find which one is the best fit.
for (let interval of intervals) {
if (seconds >= interval.limit) {
- let amount = Math.floor(seconds / interval.limit);
- let text;
- if (amount !== 1) {
- text = interval.plural;
- } else {
- text = interval.singular;
- }
- return `Vor ${amount} ${text}`;
+ return "Vor " + Math.floor(seconds / interval.limit) + ` ${interval.text}`;
}
}
- let text = "Sekunde";
- let amount = Math.floor(seconds);
- if (amount !== 1) {
- text += "n";
- }
- return `Vor ${amount} ${text}`;
+ return "Vor " + Math.floor(seconds) + " Sekunden";
};
let includeReplies;
-// max post age in seconds
-let maxAge;
-// below times are in milliseconds
-// duration for slide animations
-let duration;
-// refresh rate
-let refresh;
-// extra cards text
-let extraCards;
// fetchConfig fetches the configuration from the config.json file
const fetchConfig = async function() {
@@ -63,22 +48,12 @@ const fetchConfig = async function() {
$('#navbar-brand').text(config.navbarBrandText);
$('.navbar').css('background-color', config.navbarColor);
includeReplies = config.includeReplies;
- maxAge = config.maxAge;
- duration = config.duration * 1000;
- refresh = config.refreshDuration * 1000;
- extraCards = config.extraCards;
return config.defaultServerUrl;
} catch (error) {
console.log("Error loading config.json:", error);
- $('#navbar-brand').text("Netzbegrünung Mastowall - gruene.social");
+ $('#navbar-brand').text("Netzbegrünung Mastowall");
$('.navbar').css('background-color', "#008939");
includeReplies = true;
- maxAge = 60 * 60 * 24 * 7;
- duration = 10000;
- refresh = 30000;
- extraCards = [
- "
${DOMPurify.sanitize(post.account.display_name)} @${DOMPurify.sanitize(post.account.acct)}
+${DOMPurify.sanitize(post.account.display_name)}
${DOMPurify.sanitize(post.content)}
@@ -129,22 +104,11 @@ const displayPost = function(post) { return 1; }; -const processPosts = function(posts) { - posts = posts.filter((post) => { - return secondsAgo(new Date(post.created_at)) < maxAge && post.content.indexOf("nitter.") === -1 - }); - - return posts; -}; - // updateWall displays all posts const updateWall = function(posts) { if (!posts || posts.length === 0) return; - posts = processPosts(posts); - posts.sort((a, b) => new Date(a.created_at) - new Date(b.created_at)); - let ret = 0 posts.forEach(post => ret += displayPost(post)); $('.masonry-grid').masonry('layout'); @@ -156,10 +120,8 @@ const updateWall = function(posts) { const updateCarousel = function(slides, posts) { if (!posts || posts.length === 0) return; - posts = processPosts(posts); - posts.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); - + // remove slides in carousel slides.innerHTML = ""; var newHTML = ` ` @@ -179,7 +141,7 @@ const updateCarousel = function(slides, posts) {${DOMPurify.sanitize(post.account.display_name)} @${DOMPurify.sanitize(post.account.acct)}
+${DOMPurify.sanitize(post.account.display_name)}