npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pod-point/cookie-notice.js

v2.0.1

Published

Snippet to display the Pod Point EU cookie notice banner

Downloads

2,760

Readme

cookie-notice.js

npm Build Status

Package to display the Pod Point EU cookie notice banner.

Installation as a Dependency

npm install --save @pod-point/cookie-notice.js

Usage

Import and use the module from npm:

import cookieNotice from '@pod-point/cookie-notice.js';

cookieNotice.init();

This will use the default locale en for the copy of the notice, as well as the main call to action button.

You can also decide to use a translated version as long, as it's supported, by passing the locale to the init() method:

cookieNotice.init({
    locale: 'no',
});

If the locale is not found, it will always fallback to the default one.

Advanced Usage

You can also optionally use the exported methods to check the status of the cookie manually:

const hasCookie = cookieNotice.hasCookie();
if (!hasCookie) {
    cookieNotice.setCookie();
}

Overwrite Notice and/or Button text

We can overwrite the translations by passing the desired values through the init() configuration arguments:

cookieNotice.init({
    notice: 'Some different notice text in English.',
    button: 'The button text',
});

If only one of the two possible overwrites is given, it will default to the translated version of the current locale. This can be combined with the locale configuration parameter. If no locale is given, it will default to English as usual.

Installation as a Snippet

You can also include this straight away in any HTML page by including the following snippet:

<script>
(function(p,o,d,e,v){
v=p.createElement(o);e=p.getElementsByTagName(o)[0];v.async=1;v.src=d;e.parentNode.insertBefore(v,e)
})(document,'script','//cdn.pod-point.com/cookie-notice/2.0.1/bundle.min.js');
</script>

Advanced Usage

This will use the default locale en. If you want to use another supported locale like no, declare it globally before loading the snippet like so:

<script>
(function(p,o,d,e,v){
window['cookie-notice.locale']='no';v=p.createElement(o);e=p.getElementsByTagName(o)[0];v.async=1;v.src=d;e.parentNode.insertBefore(v,e)
})(document,'script','//cdn.pod-point.com/cookie-notice/2.0.1/bundle.min.js');
</script>

Overwrite Notice and/or Button text

We can overwrite the translations by passing the desired values through the window object too:

<script>
(function(p,o,d,e,v){
window['cookie-notice.button']='Click!';v=p.createElement(o);e=p.getElementsByTagName(o)[0];v.async=1;v.src=d;e.parentNode.insertBefore(v,e)
})(document,'script','//cdn.pod-point.com/cookie-notice/2.0.0/bundle.min.js');
</script>

All three configuration options can be combined and used in parallele. It will behave exactly the same way as when using init().

Internationalization (i18n)

Supported languages

  • en - English default
  • no - Norwegian

Support a new language

  1. Create a new translation file within src/lang like src/lang/fr.js for example.
  2. Make sure it follow the same format as the English one en.js.
  3. Make sure you load it through src/lang/index.js, just like any other language.
  4. That's it, you can now use init({ locale: 'fr' }) from a JavaScript file or window['cookie-notice.locale']='fr'; from an HTML file including the snippet.

Deployment

To publish a new version to NPM and our CDN run the following commands:

npm version [major|minor|patch]
git push

Once your PR is merged, create a new Release from Github with the same tag name (major, minor, patch).

Whenever a tagged commit gets created with a new version, Travis CI will make sure to distribute the updated files to both our S3 CDN and the NPM repository.