// YouTube embed - Consent/Index.html function t3sbVideo(videoId, params, id, consent=false) { var playerElement = document.getElementById('v'+id), div = document.createElement('div'), iframe = document.createElement('iframe'); div.setAttribute('data-id', videoId); playerElement.appendChild(div); if (consent) { iframe.setAttribute('src','https://www.youtube-nocookie.com/embed/' + div.dataset.id + params); } else { iframe.setAttribute('data-src','https://www.youtube-nocookie.com/embed/' + div.dataset.id + params); } iframe.setAttribute('id','iframe-' + id); iframe.setAttribute('class','h-100 w-100'); iframe.setAttribute('allowfullscreen', '1'); iframe.setAttribute('allow','accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'); div.replaceWith(iframe); } function t3sbConsent(cuid, cookieExpire) { document.getElementById(cuid).onclick = function() { let ytvideo = document.getElementById('iframe-'+this.id); let videoContent = document.getElementById('v'+this.id); let videoOverlay = videoContent.getElementsByClassName('video-overlay')[0]; videoOverlay.remove(); ytvideo.src = ytvideo.getAttribute('data-src'); ytvideo.parentNode.parentNode.style.backgroundImage = ''; //ytvideo.parentNode.firstChild.remove(); let name = 'contentconsent_' + this.id, value = 'allow', days = cookieExpire; t3sbSetCookie(name, value, days); }; } function t3sbVideoThumbnails(ratio) { document.querySelectorAll('.video-thumbnail').forEach( vthumb => { if (vthumb) { let thumbWidth = vthumb.clientWidth, thumbHeight = vthumb.clientWidth * ratio; if (vthumb.clientHeight > thumbHeight) { vthumb.style.maxHeight = thumbHeight+'px'; } else { vthumb.style.minHeight = thumbHeight+'px'; } }; }); }
function t3sbSetCookie(cname,cvalue,exdays) { const d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); let expires = 'expires=' + d.toGMTString(); document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/'; } function t3sbGetCookie(cname) { let name = cname + '='; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i < ca.length; i++) { let c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ''; }
// YouTube embeds thumbnails {ratio} - Consent/Index.html t3sbVideoThumbnails('{settings.consent.autoSize}');
// YouTube embed (v{settings.consent.contentByUid}) - Consent/Index.html t3sbVideo('{ytuid}', '{params-> f:format.raw()}', {settings.consent.contentByUid}, true);
// YouTube embed (v{settings.consent.contentByUid}) - Consent/Index.html t3sbVideo('{ytuid}', '{params-> f:format.raw()}', {settings.consent.contentByUid}); t3sbConsent({settings.consent.contentByUid}, {settings.cookieExpire});
{settings.consent.text -> f:format.html()}
{settings.consent.button -> f:format.raw()}
A YouTube video is expected here!