.. include:: ../Includes.txt
.. _javascript-api:
JavaScript API
==============
:file:`cookieman.js` exposes these methods:
cookieman.showOnce()
^^^^^^^^^^^^^^^^^^^^
.. rst-class:: dl-parameters
cookieman.showOnce()
:sep:`|` :aspect:`Data type:` void
:sep:`|`
Shows the confirmation modal when consent has not been saved yet.
It is automatically called on each page from :file:`cookieman-init.js` (with an aditional condition, see :ref:`when-is-it-shown`)
cookieman.show()
^^^^^^^^^^^^^^^^
.. rst-class:: dl-parameters
cookieman.show()
:sep:`|` :aspect:`Data type:` void
:sep:`|`
Shows the confirmation modal.
You can also use the attribute `data-cookieman-show` on any element to show the modal when clicked.
.. code-block:: HTML
cookieman.hide()
^^^^^^^^^^^^^^^^
.. rst-class:: dl-parameters
cookieman.hide()
:sep:`|` :aspect:`Data type:` void
:sep:`|`
Hides the confirmation modal.
cookieman.consent(groupKey)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. rst-class:: dl-parameters
cookieman.consent(groupKey)
:sep:`|`
Adds the given group (e.g. 'marketing') to the consented groups, updates the CookieConsent cookie
and injects all items given each corresponding trackingObject's `inject` section.
This is meant as a programmatic way to implement banners before showing content from external sources such as YouTube
videos, Google Maps, facebook posts, ... – clicking the "yes, show the content"-button would call this function and a
`