From 2ce432034eb35f763182de03fb7b42d2a07afc4b Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 15 Sep 2020 20:03:52 -0400 Subject: Webcards update from local git server --- webcards/scripts/cookie.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'webcards/scripts/cookie.js') diff --git a/webcards/scripts/cookie.js b/webcards/scripts/cookie.js index 2eb5977..d614af7 100644 --- a/webcards/scripts/cookie.js +++ b/webcards/scripts/cookie.js @@ -1,8 +1,7 @@ -function CookieManager() { -} +'use strict'; -CookieManager.prototype = { - getCookie: function(name){ +class Cookies { + static getCookie(name){ let cookies = document.cookie.split(";"); for(let i in cookies) { let cname = cookies[i].trim().split("=")[0]; @@ -11,9 +10,9 @@ CookieManager.prototype = { } } return ""; - }, + } - setCookie: function(name, value, data={}) { + static setCookie(name, value, data = {}) { let extra = ""; for(let key in data) @@ -22,18 +21,16 @@ CookieManager.prototype = { } document.cookie = name + "=" + value + extra; - }, + } - setYearCookie: function(name, value) { + static setYearCookie(name, value) { var date = new Date(Date.now()); date.setFullYear(date.getFullYear() + 1); - this.setCookie(name, value, {expires: date.toUTCString()}); - }, + Cookies.setCookie(name, value, {expires: date.toUTCString()}); + } - removeCookie: function(name) { + static removeCookie(name) { var date = new Date(0); - this.setCookie(name, "", {expires: date.toUTCString()}); + Cookies.setCookie(name, "", {expires: date.toUTCString()}); } -}; - -var Cookies = new CookieManager(); \ No newline at end of file +} -- cgit v1.2.3