Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ Until then please have a look at the following code:

```html
<script type="text/javascript">

function ownvideo_callback() {
// alert("Callback ausgeführt");
}

var _2ClickIframePrivacyConfig = {
enableCookies: true,
useSessionCookie: true,
CustomTypes: Array(
{
type: 'ownvideo',
class: 'privacy-ownvideo',
type: 'ownvideo',
class: 'privacy-ownvideo',
callback: 'ownvideo_callback',
description: 'Please enter a text to show before loading the content<br />'
}
)
Expand Down
42 changes: 36 additions & 6 deletions src/2ClickIframePrivacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@

var config = {
enableCookies: true,
useSessionCookie: true
useSessionCookie: true,
cookieNamespace: '_2ClickIPEnable-',
showContentLabel: 'Inhalt anzeigen',
rememberChoiceLabel: 'Auswahl merken',
privacyPolicyLabel: 'Datenschutzerklärung',
privacyPolicyUrl: false
};

this.types = new Array(
{
type: 'video',
Expand Down Expand Up @@ -49,9 +55,12 @@
wrapper.className = 'privacy-msg '+selclass+'-msg';
wrapper.style.width = el.clientWidth+'px';
wrapper.style.height = el.clientHeight+'px';
wrapper.innerHTML = text +'<a href="#foo" onclick="_2ClickIframePrivacy.EnableContent(\''+ type +'\', \''+ selclass +'\'); return false;">Inhalt anzeigen</a>';
wrapper.innerHTML = text +'<a href="#foo" onclick="_2ClickIframePrivacy.EnableContent(\''+ type +'\', \''+ selclass +'\'); return false;">'+config.showContentLabel+'</a>';
if(config.enableCookies){
wrapper.innerHTML = wrapper.innerHTML + '<br /><input type="checkbox" name="remind-\''+ selclass +'\'" /> <label>Auswahl merken</label>';
wrapper.innerHTML = wrapper.innerHTML + '<br /><input type="checkbox" name="remind-\''+ selclass +'\'" /> <label>'+config.rememberChoiceLabel+'</label>';
}
if(config.privacyPolicyUrl){
wrapper.innerHTML = wrapper.innerHTML + '<br /><a href="'+config.privacyPolicyUrl+'">'+config.privacyPolicyLabel+'</a>';
}
wrapper.innerHTML = '<p>' + wrapper.innerHTML + '</p>';
wrapper.appendChild(el);
Expand All @@ -73,10 +82,10 @@

if(remind){
if(config.useSessionCookie){
setSessionCookie('_2ClickIPEnable-'+type, '1');
setSessionCookie(config.cookieNamespace+type, '1');
}
else{
setCookie('_2ClickIPEnable-'+type, '1', 30);
setCookie(config.cookieNamespace+type, '1', 30);
}
}
}
Expand All @@ -101,6 +110,12 @@
for (i = 0; i < x.length; i++) {
x[i].src = x[i].getAttribute("data-src");
}

for (i = 0; i < this.types.length; i++) {
if(this.types[i].type == type && this.types[i].callback) {
window[this.types[i].callback]();
}
}
}

this.init = function (Userconfig) {
Expand All @@ -111,6 +126,21 @@
if (typeof Userconfig.useSessionCookie !== 'undefined') {
config.useSessionCookie = Userconfig.useSessionCookie;
}
if (typeof Userconfig.cookieNamespace !== 'undefined') {
config.cookieNamespace = Userconfig.cookieNamespace;
}
if (typeof Userconfig.privacyPolicyUrl !== 'undefined') {
config.privacyPolicyUrl = Userconfig.privacyPolicyUrl;
}
if (typeof Userconfig.showContentLabel !== 'undefined') {
config.showContentLabel = Userconfig.showContentLabel;
}
if (typeof Userconfig.rememberChoiceLabel !== 'undefined') {
config.rememberChoiceLabel = Userconfig.rememberChoiceLabel;
}
if (typeof Userconfig.privacyPolicyLabel !== 'undefined') {
config.privacyPolicyLabel = Userconfig.privacyPolicyLabel;
}

if (Array.isArray(Userconfig.CustomTypes)) {
this.types = Userconfig.CustomTypes;
Expand All @@ -119,7 +149,7 @@
for (i = 0; i < this.types.length; i++) {
var selector = document.getElementsByClassName(this.types[i].class);
var x;
if(!getCookie('_2ClickIPEnable-'+this.types[i].type)){
if(!getCookie(config.cookieNamespace+this.types[i].type)){
for (x = 0; x < selector.length; x++) {
wrap(selector[x], document.createElement('div'), this.types[i].type, this.types[i].class, this.types[i].description);
}
Expand Down