pub / newsplanet

Planet-Style Newsfeed generated with perlanet
git clone https://src.jayvii.de/pub/newsplanet.git
Home | Log | Files | Exports | Refs | README | RSS

commit 38f306549fd802fbb7cbe1ea6750584f73d52303
parent 08c69d7864c88ce9b7643688b5b58ca0022f5349
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Sun,  2 Jun 2024 18:43:11 +0200

do not set cookie for initial load

Diffstat:
Mtemplate.html | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/template.html b/template.html @@ -30,18 +30,17 @@ </style> <script> // Toggle Theme function - function toggleTheme(set_mode = null) { + function toggleTheme(set_mode = null, set_cookie = false) { // Set Mode and mark in session storage if (set_mode === 0) { document.querySelector("body").classList = ["list"]; } else { document.querySelector("body").classList = ["list dark"]; } - if (document.cookie == "") { + if (document.cookie == "" && set_cookie) { var set_cookie = confirm( "Do you want to save this decision with a cookie?" ); - } if (set_cookie) { document.cookie="dark-mode=" + set_mode + ";SameSite=Strict"; @@ -78,7 +77,7 @@ <path d="M6.18,15.64A2.18,2.18 0 0,1 8.36,17.82C8.36,19 7.38,20 6.18,20C5,20 4,19 4,17.82A2.18,2.18 0 0,1 6.18,15.64M4,4.44A15.56,15.56 0 0,1 19.56,20H16.73A12.73,12.73 0 0,0 4,7.27V4.44M4,10.1A9.9,9.9 0 0,1 13.9,20H11.07A7.07,7.07 0 0,0 4,12.93V10.1Z" /> </svg> </a> - <a href="#" onclick="toggleTheme(set_mode = 1 - sessionStorage.getItem('dark-mode'));"> + <a href="#" onclick="toggleTheme(set_mode = 1 - sessionStorage.getItem('dark-mode'), set_cookie = true);"> <!-- Copyright: 2023, Pictogrammers License: Apache-2.0 <https://www.apache.org/licenses/LICENSE-2.0> Info: https://pictogrammers.com/docs/general/license/