From 6fa9efcc74a9c36f9e2178ee5427eafb8d470d99 Mon Sep 17 00:00:00 2001 From: Frankie B Date: Mon, 22 Jan 2024 01:16:42 +0000 Subject: Get scheme cookie server-side instead of client-side on page load --- public/js/schemeSwap.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 public/js/schemeSwap.js (limited to 'public/js/schemeSwap.js') diff --git a/public/js/schemeSwap.js b/public/js/schemeSwap.js new file mode 100644 index 0000000..de5a6b2 --- /dev/null +++ b/public/js/schemeSwap.js @@ -0,0 +1,53 @@ +/** + * Retrieves a cookies value + * @param {string} cname Cookie name + * @returns {string} Cookie value + */ +function getCookie(cname) { + let name = cname + "="; + let decodedCookie = decodeURIComponent(document.cookie); + let ca = decodedCookie.split(';'); + for(let i = 0; i