diff options
author | Kyle Gunger <corechg@gmail.com> | 2020-09-15 20:03:52 -0400 |
---|---|---|
committer | Kyle Gunger <corechg@gmail.com> | 2020-09-15 20:03:52 -0400 |
commit | 2ce432034eb35f763182de03fb7b42d2a07afc4b (patch) | |
tree | e57d7bc40d12c32c79f1f16ba669a5426ae80525 /webcards/scripts/cookie.js | |
parent | 20201f77b5cf5cbb1c70b1cc51c4108d620a3202 (diff) |
Webcards update from local git server
Diffstat (limited to 'webcards/scripts/cookie.js')
-rw-r--r-- | webcards/scripts/cookie.js | 27 |
1 files changed, 12 insertions, 15 deletions
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 +} |