From eb85222ea31b223c2d37f6910d5444dbda9d46b5 Mon Sep 17 00:00:00 2001 From: Max L Date: Thu, 23 Nov 2023 20:44:38 +0100 Subject: [PATCH] Make duration and refresh easily configurable Also increase duration to 10 seconds per post --- config.json | 2 ++ script.js | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.json b/config.json index 7c8a82d..7bb5272 100644 --- a/config.json +++ b/config.json @@ -2,5 +2,7 @@ "navbarBrandText": "Netzbegrünung Mastowall", "defaultServerUrl": "https://gruene.social", "navbarColor": "#008939", + "duration": 10, + "refreshDuration": 30, "includeReplies": true } diff --git a/script.js b/script.js index af74d3b..fa3874a 100644 --- a/script.js +++ b/script.js @@ -1,12 +1,6 @@ // 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(/[\]]/, '\\]'); @@ -40,6 +34,11 @@ const timeAgo = function(seconds) { }; let includeReplies; +// below times are in milliseconds +// duration for slide animations +let duration; +// refresh rate +let refresh; // fetchConfig fetches the configuration from the config.json file const fetchConfig = async function() { @@ -48,12 +47,16 @@ const fetchConfig = async function() { $('#navbar-brand').text(config.navbarBrandText); $('.navbar').css('background-color', config.navbarColor); includeReplies = config.includeReplies; + duration = config.duration * 1000; + refresh = config.refreshDuration * 1000; return config.defaultServerUrl; } catch (error) { console.log("Error loading config.json:", error); $('#navbar-brand').text("Netzbegrünung Mastowall"); $('.navbar').css('background-color', "#008939"); includeReplies = true; + duration = 10000; + refresh = 30000; return "https://gruene.social"; } }