| Total Complexity | 7 |
| Complexity/F | 1.4 |
| Lines of Code | 36 |
| Function Count | 5 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | export function getOptions (optionContainer) { |
||
|
|
|||
| 2 | return { |
||
| 3 | expireDays: 7, |
||
| 4 | cookieName: 'cookies_accepted' |
||
| 5 | } |
||
| 6 | } |
||
| 7 | |||
| 8 | export function acceptCookies ($container, cookieName, expireDays) { |
||
| 9 | return function (e) { |
||
| 10 | const date = new Date() |
||
| 11 | date.setTime(date.getTime() + (expireDays * 24 * 60 * 60 * 1000)) |
||
| 12 | document.cookie = cookieName + '=true; expires=' + date.toGMTString() |
||
| 13 | $container.remove() |
||
| 14 | } |
||
| 15 | } |
||
| 16 | |||
| 17 | export function checkCookies ($container, cookieName) { |
||
| 18 | const cookiesAccepted = getCookieValue(cookieName) |
||
| 19 | |||
| 20 | if (!cookiesAccepted) { |
||
| 21 | $container.addClass('cookieNotification-isVisible') |
||
| 22 | } else { |
||
| 23 | $container.remove() |
||
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | function getCookieValue (cookie) { |
||
| 28 | const value = '; ' + document.cookie |
||
| 29 | const parts = value.split('; ' + cookie + '=') |
||
| 30 | |||
| 31 | if (parts.length === 2) { |
||
| 32 | return parts.pop().split(';').shift() |
||
| 33 | } else { |
||
| 34 | return false |
||
| 35 | } |
||
| 36 | } |
||
| 37 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.