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

cookie-consent-js

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie-consent-js - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

examples/cookie-consent-bootstrap-example.html

2

package.json
{
"name": "cookie-consent-js",
"version": "1.2.1",
"version": "1.2.2",
"description": "A simple dialog and framework to handle the German and EU law (may 2020) about cookies in a website",

@@ -5,0 +5,0 @@ "main": "src/cookie-consent.js",

# cookie-consent-js
A simple dialog and framework to handle the German and EU law (may 2020) about cookies in a website
- [Demo page](https://shaack.com/projekte/cookie-consent-js/index.html)
- [Demo pages in plain HTML or with Bootstrap 4](https://shaack.com/projekte/cookie-consent-js/index.html)
- [npm package](https://www.npmjs.com/package/cookie-consent-js)

@@ -9,16 +9,42 @@

### Include the js and css
Follow these easy steps to integrate the cookie settings in your page.
### 1. Install cookie-consent-js in your project with `npm i cookie-consent-js`
Alternatively you can download the [git repository](https://github.com/shaack/cookie-consent-js).
### 2. Include `cookie-consent.css`
```html
<link rel="stylesheet" href="./src/cookie-consent.css"/>
<script src="./src/cookie-consent.js"></script>
<link rel="stylesheet" href="/node_modules/cookie-consent-js/src/cookie-consent.css"/>
```
This should be done before any bootstrap or other frameworks css. You can
overwrite styling in your projects css, take a look at [cookie-consent.scss](https://github.com/shaack/cookie-consent-js/blob/master/src/cookie-consent.scss).
### Initialize the script
### 3. Include `cookie-consent.js`
```html
<script src="/node_modules/cookie-consent-js/src/cookie-consent.js"></script>
```
In your `<head>` or at the bottom of your `<body>`.
### 4. Initialize the Script
```js
var cookieConsent = new CookieConsent(props)
var cookieConsent = new CookieConsent({privacyPolicyUrl: "/privacy-policy.html"})
```
In `props` you should at least define `privacyPolicyUrl`.
See below "Configuration properties".
### 5. Disable "autoShowModal" in your privacy policy page
```js
var cookieConsent = new CookieConsent({autoShowModal: false, privacyPolicyUrl: "/privacy-policy.html"})
```
The settings dialog is linking to the privacy policy. To enable the user to read the policy, you
should disable autoShowModal there.
### 6. Enable "Cookie settings" in your service navigation
```html
<a href="javascript:cookieConsent.reset()">Cookie settings</a>
```
So the user can anytime reconfigure, if he wants tracking or not.
...done! [Contact me](https://shaack.com), if you have questions.
## API

@@ -37,3 +63,3 @@

Use this to allow the user to reconfigure the cookie settings, for example, in your
service navigation as "cookie settings".
service navigation as "Cookie settings".

@@ -45,3 +71,3 @@ #### Read the status

Returns `true` if the user did accept tracking cookies.
Use this function to disable tracking. Suround tracking code, like the Google Analytics code with
Use this function to disable tracking. Surround tracking code, like the Google Analytics code with
```js

@@ -67,4 +93,4 @@ if(cookieConsent.trackingAllowed()) {

this.props = {
buttonPrimaryClass: "button button-accept-all", // bootstrap: set to "btn btn-primary"
buttonSecondaryClass: "button button-accept-necessary", // bootstrap: set to "btn btn-secondary"
buttonPrimaryClass: "btn btn-primary", // bootstrap: set to "btn btn-primary"
buttonSecondaryClass: "btn btn-outline-primary", // bootstrap: set to "btn btn-secondary"
privacyPolicyUrl: "privacy-policy.html",

@@ -106,1 +132,5 @@ autoShowModal: true, // disable autoShowModal on the privacy policy page, to make that page readable

See `./src/cookie-consent.scss` and overwrite values as you need in your projects stylesheet.
## Disclaimer
Please read the [LICENSE](./LICENSE).

@@ -11,4 +11,4 @@ /**

this.props = {
buttonPrimaryClass: "button button-accept-all", // bootstrap: set to "btn btn-primary"
buttonSecondaryClass: "button button-accept-necessary", // bootstrap: set to "btn btn-secondary"
buttonPrimaryClass: "btn btn-primary", // the "accept all" buttons class, only used for styling
buttonSecondaryClass: "btn btn-secondary", // the "accept necessary" buttons class, only used for styling
privacyPolicyUrl: "privacy-policy.html",

@@ -57,3 +57,3 @@ autoShowModal: true, // disable autoShowModal on the privacy policy page, to make that page readable

'</div>'
this.modalContent = this.modalContent.replace(/--header--/, "<h3>" + _t.title + "</h3>")
this.modalContent = this.modalContent.replace(/--header--/, "<h3 class=\"modal-title\">" + _t.title + "</h3>")
this.modalContent = this.modalContent.replace(/--body--/,

@@ -60,0 +60,0 @@ _t.body.replace(/--privacy-policy--/, linkPrivacyPolicy)

Sorry, the diff of this file is not supported yet

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