Make duration and refresh easily configurable

Also increase duration to 10 seconds per post
This commit is contained in:
Max L. 2023-11-23 20:44:38 +01:00
parent 7edce5ab0f
commit eb85222ea3
No known key found for this signature in database
GPG key ID: 2F963B95632B8467
2 changed files with 11 additions and 6 deletions

View file

@ -2,5 +2,7 @@
"navbarBrandText": "Netzbegrünung Mastowall",
"defaultServerUrl": "https://gruene.social",
"navbarColor": "#008939",
"duration": 10,
"refreshDuration": 30,
"includeReplies": true
}

View file

@ -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";
}
}