Skip to content

Commit

Permalink
Update: Store GDPR confirm in localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Mar 22, 2022
1 parent 5acfe50 commit 895184a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions Resources/Private/Assets/Helper/iFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function getPaddingTop(node, fallback = '56.25%') {
}

function write(link, playClass, type) {
if (checkGdpr(link)) {
if (checkGdpr(link, type)) {
const IFRAME = markup(link);
const IMAGE = getImage(link);
if (!IFRAME) {
Expand All @@ -83,14 +83,19 @@ function write(link, playClass, type) {
}
}

function checkGdpr(element) {
function checkGdpr(element, type) {
const GDPR = element.dataset.gdpr;

if (!GDPR) {
return true;
}
if (GDPR && confirm(GDPR)) {

const LOCAL_STORAGE = window.localStorage;
const STORAGE_KEY = `jonnittoprettyembed_gdpr_${type}`;

if (LOCAL_STORAGE[STORAGE_KEY] === 'true' || confirm(GDPR)) {
element.removeAttribute('data-gdpr');
LOCAL_STORAGE[STORAGE_KEY] = 'true';
return true;
}
return false;
Expand All @@ -113,7 +118,7 @@ function lightbox(type) {
const HTML = markup(this);
if (HTML) {
event.preventDefault();
if (checkGdpr(this)) {
if (checkGdpr(this, type)) {
const PADDING_TOP = getPaddingTop(this);
lightboxHelper.get([type, 'iframe'], PADDING_TOP).innerHTML = HTML;
lightboxHelper.show(() => {
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/Scripts/Main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 895184a

Please sign in to comment.