Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4602522

Browse files
committedMay 9, 2024
No longer request cookies if the user has refused
1 parent da86ac7 commit 4602522

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
 

‎docs/templates/js/functions.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
let isCookiesAccepted = getCookie("cookies-accepted") === "true";
2-
31
// <> Cookies
2+
3+
// Returns whether the user has accepted the cookies or not, or undefined if the user hasn't chosen yet
4+
function isCookiesAccepted() {
5+
const cookie = getCookie("cookies-accepted");
6+
if (!cookie) {
7+
return undefined;
8+
}
9+
return Boolean(cookie);
10+
}
11+
412
function setCookie(cname, cvalue, exdays, force = false) {
5-
if (!isCookiesAccepted && !force)
13+
if (!isCookiesAccepted() && !force)
614
return;
715

816
const d = new Date();
@@ -37,7 +45,7 @@ function getCookie(cname) {
3745
* @param {double} exdays time in days
3846
*/
3947
function setStorageItem(item, value, exdays, force = false) {
40-
if (!isCookiesAccepted && !force)
48+
if (!isCookiesAccepted() && !force)
4149
return;
4250

4351
const d = new Date();

0 commit comments

Comments
 (0)
Please sign in to comment.