New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

novicell-cookie-info

Package Overview
Dependencies
Maintainers
6
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

novicell-cookie-info - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

122

js/novicell.cookieinfo.js

@@ -12,19 +12,15 @@ 'use strict';

novicell.cookieInfo = novicell.cookieInfo || new function () {
var self = this;
this.init = function() {
var body = document.querySelector("body");
var body = document.querySelector('body');
var cookieInfo = document.querySelector('#js-cookie-info');
var cookieClose = document.querySelector('#js-cookie-info-close');
var cookieOpen = document.querySelector('#js-cookie-info-open');
var cookieAccept = document.querySelector('#js-cookie-info-accept');
var cookieDecline = document.querySelector('#js-cookie-info-decline');
if (cookieInfo) {
// If we have displayed it once, set cookie for one year
if (getCookie("cookieAccept") === "displayed") {
setCookie("cookieAccept", "accepted", 365);
}
// Check if the cookie info has been displayed, if not set session cookie
if (getCookie("cookieAccept") === "") {
setCookie("cookieAccept", "displayed");
// Check if the cookie info has been displayed, if not -> show popup
if (getCookie('cookieAccept') !== 'accepted') {
setTimeout(function() {

@@ -34,2 +30,5 @@ body.classList.add('cookie-info-show');

}
else {
cookieInfo.classList.add('cookie-info-accepted');
}

@@ -39,3 +38,3 @@ // Button eventlisteners

cookieOpen.addEventListener('click', function(e) {
showInfo();
self.showInfo();
});

@@ -46,41 +45,80 @@ }

cookieClose.addEventListener('click', function(e) {
hideInfo();
setCookie("cookieAccept", "accepted", 365);
self.hideInfo();
});
}
if(cookieAccept) {
cookieAccept.addEventListener('click', function(e) {
self.hideInfo();
setCookie('cookieAccept', 'accepted', 365);
cookieInfo.classList.add('cookie-info-accepted');
});
}
if(cookieDecline) {
cookieDecline.addEventListener('click', function(e) {
self.hideInfo();
self.declineCookieInfo();
});
}
}
};
}();
this.showInfo = function(){
var body = document.querySelector('body');
body.classList.add('cookie-info-show');
}
this.hideInfo = function(){
var body = document.querySelector('body');
body.classList.remove('cookie-info-show');
}
// Functions for opening an closing the cookie-info
function showInfo(){
var body = document.querySelector("body");
body.classList.add('cookie-info-show');
}
this.declineCookieInfo = function() {
deleteCookie('cookieAccept');
}
/* Private helper functions
*******************************/
function hideInfo(){
var body = document.querySelector("body");
body.classList.remove('cookie-info-show');
}
/**
* Get a cookie
* @param {String} cname, cookie name
* @return {String} String, cookie value
*/
function getCookie(cname) {
var name = cname + '=';
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' '){ c = c.substring(1); }
if (c.indexOf(name) === 0){ return c.substring(name.length,c.length); }
}
return '';
}
/**
* Set a cookie
* @param {String} cname, cookie name
* @param {String} cvalue, cookie value
* @param {Int} exdays, number of days before the cookie expires
*/
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 60 * 60 * 1000 * 24));
var expires = 'expires=' + d.toUTCString() + ';';
var path = 'path=/';
document.cookie = cname + '=' + cvalue + '; ' + expires + path;
}
/* Cookie helper functions
*******************************/
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' '){ c = c.substring(1); }
if (c.indexOf(name) === 0){ return c.substring(name.length,c.length); }
/**
* Delete a cookie
* @param {String} cname, cookie name
*/
function deleteCookie(cname) {
var d = new Date(); //Create an date object
d.setTime(d.getTime() - (1000*60*60*24)); //Set the time to the past. 1000 milliseonds = 1 second
var expires = 'expires=' + d.toGMTString(); //Compose the expirartion date
window.document.cookie = cname+'='+'; '+expires;//Set the cookie with name and the expiration date
}
return "";
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 60 * 60 * 1000 * 24));
var expires = "expires=" + d.toUTCString() + ";";
var path = "path=/";
document.cookie = cname + "=" + cvalue + "; " + expires + path;
}
}();
{
"name": "novicell-cookie-info",
"version": "1.1.0",
"version": "2.0.0",
"description": "Cookie information dialog used to show a short text about, the use of cookies for the website, due to european laws.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc