diff --git a/script.js b/script.js index 99132a9..b46564a 100644 --- a/script.js +++ b/script.js @@ -81,6 +81,25 @@ function decodeWords(encodedWords) { const words = decodeWords(encodedWords); +// Helper functions to handle cookies +function setCookie(name, value, days) { + const date = new Date(); + date.setTime(date.getTime() + (days*24*60*60*1000)); + const expires = "expires=" + date.toUTCString(); + document.cookie = name + "=" + value + ";" + expires + ";path=/"; +} + +function getCookie(name) { + const nameEQ = name + "="; + const ca = document.cookie.split(';'); + for(let i = 0; i < ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') c = c.substring(1); + if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); + } + return null; +} + function getWordOfTheDay() { const startDate = new Date("2024-01-01"); // Starting date of your word list const today = new Date();