-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:AKVorrat/dearmep-website
- Loading branch information
Showing
8 changed files
with
108 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const wrappers = document.querySelectorAll('.gdpr-iframe-wrapper'); | ||
if (wrappers !== null) { | ||
const consents = loadConsents(); | ||
for (let i = 0; i < wrappers.length; i++) { | ||
let iframe = wrappers[i].children[0]; | ||
let consent = wrappers[i].getAttribute("consent"); | ||
if (consent in consents) { | ||
iframe.setAttribute('src', iframe.getAttribute('data-src')); | ||
wrappers[i].children[1].remove(); | ||
} else { | ||
let consentElements = wrappers[i].children[1].children; | ||
consentElements[consentElements.length -1].addEventListener("click", function(e) { | ||
const wrapper = e.target.parentElement.parentElement; | ||
all = wrapper.children[1].children[0].children[0].checked; | ||
consent = wrapper.getAttribute("consent"); | ||
if(all === true) { | ||
let consents = loadConsents(); | ||
consents[consent] = true; | ||
saveConsents(consents); | ||
loadIframes(consent); | ||
} else { | ||
let iframe = wrapper.children[0]; | ||
iframe.setAttribute('src', iframe.getAttribute('data-src')); | ||
wrapper.children[1].remove(); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
function loadConsents() { | ||
let consents = localStorage.getItem("gdpr-iframe-consents"); | ||
if (consents === null) { | ||
consents = {}; | ||
} else { | ||
consents = JSON.parse(consents); | ||
} | ||
return consents; | ||
} | ||
|
||
function saveConsents(consents) { | ||
localStorage.setItem("gdpr-iframe-consents", JSON.stringify(consents)); | ||
} | ||
|
||
function loadIframes(consent) { | ||
const wrappers = document.querySelectorAll('.gdpr-iframe-wrapper[consent="' + consent + '"]'); | ||
for (let i = 0; i < wrappers.length; i++) { | ||
let iframe = wrappers[i].children[0]; | ||
iframe.setAttribute('src', iframe.getAttribute('data-src')); | ||
if (wrappers[i].children.length > 1) { | ||
wrappers[i].children[1].remove(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.gdpr-iframe-wrapper { | ||
position: relative; | ||
width: 100%; | ||
|
||
.gdpr-iframe-consent { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
padding: 1em; | ||
background: #f2f2f2; | ||
color: var(--bs-body-color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{ $src := .Get "src" }} | ||
{{ $domain := (urls.Parse $src).Host }} | ||
{{ $width := .Get "width" }} | ||
{{ $height := .Get "height" }} | ||
{{ $style := .Get "style" }} | ||
{{ $class := .Get "class" }} | ||
<div class="gdpr-iframe-wrapper" consent="{{ $domain }}"> | ||
<iframe data-src="{{ $src }}" width="{{ $width }}" height="{{ $height }}" style="{{ $style }}" class="{{ $class }}"></iframe> | ||
<div class="gdpr-iframe-consent"> | ||
<div class="form-check"> | ||
<input class="form-check-input" type="checkbox" value="" id="flexCheckChecked" checked> | ||
<label class="form-check-label" for="flexCheckChecked"> | ||
Remember consent for {{ $domain }}. | ||
</label> | ||
</div> | ||
Click the button to load an iframe from {{ $domain }}. Thereby, you consent to their data protection policy<br /> | ||
<Button class="btn btn-primary">Load iframe</button> | ||
</div> | ||
</div> |