-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
5 additions
and
5 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 |
---|---|---|
@@ -1 +1 @@ | ||
/*! biscuitman.js 0.3.15 */let e,t,o;let{document:n,window:a,Object:i}=globalThis,s=n.documentElement,c="biscuitman",l={},r={key:"myconsent",global:"Consent",force:!1,enableMore:!0,sections:["essential"],title:"Your privacy matters",message:"We use cookies",settings:"Settings",reject:"Reject All",accept:"Accept All",save:"Save My Settings",settingsTitle:"My Consent Settings",info:"",more:"Show more",noCookies:"No cookies to display",acceptNonEU:!1},d=document.createElement("div"),u=e=>d.classList.toggle("bm-hide",!e),m=()=>{let{consentTime:e,...o}=v();for(let[n,a]of(e||(o=i.fromEntries(t.sections.slice(1).map(e=>[e,!1]))),i.entries(o)))s.classList.toggle(`bm-${n}`,a),s.classList.toggle(`bm-no-${n}`,!a)};function p(e){let t=e.target.dataset.id;switch(g("button",{id:t}),t){case"accept":S(!0);break;case"close":o.close();break;case"settings":$();break;case"save":S();break;case"reject":S(!1)}}function f(){g("close")}function b(e){t.force&&e.preventDefault()}function $(){g("open"),o.showModal()}function g(e,t){let o=`${c}:${e}`,a={...void 0!==t&&t,time:+new Date};n.dispatchEvent(new CustomEvent(o,a)),console.debug(o,a),l[o]&&l[o].forEach(e=>e(a))}let v=()=>a[t.global]||{};function h(e){a[t.global]=e,m()}let k=e=>!!v()[e];function E(e,t){for(let o in e)e[o]&&!1===t[o]&&g("revoke",{section:o})}function y(){try{return JSON.parse(localStorage.getItem(t.key))}catch(e){return console.error(e),localStorage.removeItem(t.key),{}}}function T(){let e=i.fromEntries(i.entries(localStorage)),o=i.fromEntries(n.cookie.split("; ").map(e=>e.split("="))),{consentTime:a,...s}=y()||t.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[a,c]of i.entries(s)){if(c)continue;let s=i.keys(t[`${a}Cookies`]||{});for(let t of(s.filter(e=>e.endsWith("*")).map(t=>{i.keys({...o,...e}).map(e=>{e.startsWith(t.slice(0,-1))&&s.push(e)})}),s)){if(o[t]){let e=`${t}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;n.cookie=e,n.cookie=`${e}domain=${location.hostname};`,n.cookie=`${e}domain=.${location.hostname};`,g("delete",{cookie:t})}e[t]&&(localStorage.removeItem(t),g("delete",{localStorage:t}))}}}function S(e){let n=void 0===e,a={consentTime:+new Date};t.sections.forEach(t=>{if("essential"===t)return!1;let o=d.querySelector(`[data-s=${t}]`),i=n?o.checked:e;a[t]=i,n||(o.checked=e)}),E(v(),a),h(a),localStorage.setItem(t.key,JSON.stringify(a)),g("save",{data:a}),T(),C(),o.close(),u(!1)}function C(){n.querySelectorAll("script[data-consent]").forEach(e=>{if(!v()[e.dataset.consent])return!1;let t=n.createElement("script");for(let{name:o,value:n}of e.attributes)o.startsWith("data-")||"type"===o||t.setAttribute(o,n);t.setAttribute("type",e.dataset.type||"text/javascript"),e.src||(t.textContent=e.textContent),e.parentNode.replaceChild(t,e),g("inject",{el:e,...e.id&&{id:e.id}}),e.src&&""!==e.textContent.trim()&&t.addEventListener("load",()=>{let o=n.createElement("script");o.textContent=e.textContent,e.id&&(o.id=e.id+"-after"),t.insertAdjacentElement("afterend",o),g("inject",{el:o,parent:e,...o.id&&{id:o.id}})})})}export default{create:function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e)return e;t={...r,...s};let m=a.bmInvalidate=()=>{g("invalidate",{data:v()}),E({}),S(!1),h({}),localStorage.removeItem(t.key),u(!0)},j=a.bmUpdate=()=>{g("update",{data:v()}),$()};return h(y()||{}),function(){let e=Intl.DateTimeFormat().resolvedOptions().timeZone,o=/^(GMT|UTC)$/.test(e)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(e);t.acceptNonEU&&!o&&(S(!0),u(!1))}(),function(){d.classList.add("biscuitman"),d.innerHTML=`<article> <b>${t.title}</b><p>${t.message}</p><nav><button data-id="accept">${t.accept}</button><button data-id="settings">${t.settings}</button><button data-id="reject">${t.reject}</button></nav></article><dialog><div class="bm-dialog"><b>${t.settingsTitle}</b><button data-id="close"${t.force?" disabled":""}>\xd7</button><div class="bm-sections"><p><span>${t.message}</span></p><p>${t.info.split("\n").map((e,o,n)=>`<span>${e}</span>${n.length>1&&t.enableMore&&0==o?`<a class="more" href="javascript:void(0)">${t.more}</a>`:""}`).join("")}</p>${t.sections.map(e=>{let o=v()[e],n="essential"===e,a=n?"disabled":"",s=n?"checked":"";void 0!==o&&(s=o?"checked":"");let l=t[`${e}Cookies`];return`<section><details><summary><b>${t[`${e}Title`]}</b><label for="${c}_${e}" class="${a} ${s}"><input type="checkbox" id="${c}_${e}" ${a} ${s} data-s="${e}"/></label><p>${t[`${e}Message`]}</p></summary>${l?i.entries(l).map(e=>{let[t,o]=e;return`<dl><dt>${t}</dt><dd>${o}</dd></dl>`}).join(""):`<dl><dd>${t.noCookies}</dd></dl>`}</details></section>`}).join("")}</div><nav><button data-id="accept">${t.accept}</button><button data-id="save">${t.save}</button><button data-id="reject">${t.reject}</button></nav></div></dialog>`.replaceAll("{link}",`<a href="${t.linkURL}">${t.linkText}</a>`),d.querySelectorAll("button").forEach(e=>e.addEventListener("click",p)),(o=d.querySelector("dialog")).addEventListener("close",f),o.addEventListener("cancel",b);let e=d.querySelector(".more");e&&e.addEventListener("click",e.remove),d.querySelectorAll("[data-s]").forEach(e=>e.addEventListener("change",t=>{e.parentElement.classList.toggle("checked",t.target.checked)})),n.body.appendChild(d)}(),T(),a[t.global].consentTime?(u(!1),C()):t.force&&$(),e={consent:k,invalidate:m,update:j,on:(t,o)=>{let n=`${c}:${t}`;return l[n]||(l[n]=[]),l[n].push(o),e},off:(e,t)=>{let o=`${c}:${e}`;l[o]&&(l[o]=l[o].filter(e=>e!==t))}}}}; | ||
/*! biscuitman.js 0.3.15 */let e,t,o;let{document:n,window:a,Object:i}=globalThis,s=n.documentElement,c="biscuitman",l={},r={key:"myconsent",global:"Consent",force:!1,enableMore:!0,sections:["essential"],title:"Your privacy matters",message:"We use cookies",settings:"Settings",reject:"Reject All",accept:"Accept All",save:"Save My Settings",settingsTitle:"My Consent Settings",info:"",more:"Show more",noCookies:"No cookies to display",acceptNonEU:!1},d=document.createElement("div"),u=e=>s.classList.toggle("bm-hide",!e),m=()=>{let{consentTime:e,...o}=v();for(let[n,a]of(e||(o=i.fromEntries(t.sections.slice(1).map(e=>[e,!1]))),i.entries(o)))s.classList.toggle(`bm-${n}`,a),s.classList.toggle(`bm-no-${n}`,!a)};function p(e){let t=e.target.dataset.id;switch(g("button",{id:t}),t){case"accept":S(!0);break;case"close":o.close();break;case"settings":$();break;case"save":S();break;case"reject":S(!1)}}function f(){g("close")}function b(e){t.force&&e.preventDefault()}function $(){g("open"),o.showModal()}function g(e,t){let o=`${c}:${e}`,a={...void 0!==t&&t,time:+new Date};n.dispatchEvent(new CustomEvent(o,a)),console.debug(o,a),l[o]&&l[o].forEach(e=>e(a))}let v=()=>a[t.global]||{};function h(e){a[t.global]=e,m()}let k=e=>!!v()[e];function E(e,t){for(let o in e)e[o]&&!1===t[o]&&g("revoke",{section:o})}function y(){try{return JSON.parse(localStorage.getItem(t.key))}catch(e){return console.error(e),localStorage.removeItem(t.key),{}}}function T(){let e=i.fromEntries(i.entries(localStorage)),o=i.fromEntries(n.cookie.split("; ").map(e=>e.split("="))),{consentTime:a,...s}=y()||t.sections.slice(1).reduce((e,t)=>(e[t]=!1,{consentTime:void 0,...e}),{});for(let[a,c]of i.entries(s)){if(c)continue;let s=i.keys(t[`${a}Cookies`]||{});for(let t of(s.filter(e=>e.endsWith("*")).map(t=>{i.keys({...o,...e}).map(e=>{e.startsWith(t.slice(0,-1))&&s.push(e)})}),s)){if(o[t]){let e=`${t}=;expires=Thu, 01 Jan 1970 00:00:01 UTC;path=/;`;n.cookie=e,n.cookie=`${e}domain=${location.hostname};`,n.cookie=`${e}domain=.${location.hostname};`,g("delete",{cookie:t})}e[t]&&(localStorage.removeItem(t),g("delete",{localStorage:t}))}}}function S(e){let n=void 0===e,a={consentTime:+new Date};t.sections.forEach(t=>{if("essential"===t)return!1;let o=d.querySelector(`[data-s=${t}]`),i=n?o.checked:e;a[t]=i,n||(o.checked=e)}),E(v(),a),h(a),localStorage.setItem(t.key,JSON.stringify(a)),g("save",{data:a}),T(),C(),o.close(),u(!1)}function C(){n.querySelectorAll("script[data-consent]").forEach(e=>{if(!v()[e.dataset.consent])return!1;let t=n.createElement("script");for(let{name:o,value:n}of e.attributes)o.startsWith("data-")||"type"===o||t.setAttribute(o,n);t.setAttribute("type",e.dataset.type||"text/javascript"),e.src||(t.textContent=e.textContent),e.parentNode.replaceChild(t,e),g("inject",{el:e,...e.id&&{id:e.id}}),e.src&&""!==e.textContent.trim()&&t.addEventListener("load",()=>{let o=n.createElement("script");o.textContent=e.textContent,e.id&&(o.id=e.id+"-after"),t.insertAdjacentElement("afterend",o),g("inject",{el:o,parent:e,...o.id&&{id:o.id}})})})}export default{create:function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e)return e;t={...r,...s};let m=a.bmInvalidate=()=>{g("invalidate",{data:v()}),E({}),S(!1),h({}),localStorage.removeItem(t.key),u(!0)},j=a.bmUpdate=()=>{g("update",{data:v()}),$()};return h(y()||{}),function(){let e=Intl.DateTimeFormat().resolvedOptions().timeZone,o=/^(GMT|UTC)$/.test(e)||/(Europe|BST|CEST|CET|EET|IST|WEST|WET|GMT-1|GMT-2|UTC+1|UTC+2|UTC+3)/.test(e);t.acceptNonEU&&!o&&(S(!0),u(!1))}(),function(){d.classList.add("biscuitman"),d.innerHTML=`<article> <b>${t.title}</b><p>${t.message}</p><nav><button data-id="accept">${t.accept}</button><button data-id="settings">${t.settings}</button><button data-id="reject">${t.reject}</button></nav></article><dialog><div class="bm-dialog"><b>${t.settingsTitle}</b><button data-id="close"${t.force?" disabled":""}>\xd7</button><div class="bm-sections"><p><span>${t.message}</span></p><p>${t.info.split("\n").map((e,o,n)=>`<span>${e}</span>${n.length>1&&t.enableMore&&0==o?`<a class="more" href="javascript:void(0)">${t.more}</a>`:""}`).join("")}</p>${t.sections.map(e=>{let o=v()[e],n="essential"===e,a=n?"disabled":"",s=n?"checked":"";void 0!==o&&(s=o?"checked":"");let l=t[`${e}Cookies`];return`<section><details><summary><b>${t[`${e}Title`]}</b><label for="${c}_${e}" class="${a} ${s}"><input type="checkbox" id="${c}_${e}" ${a} ${s} data-s="${e}"/></label><p>${t[`${e}Message`]}</p></summary>${l?i.entries(l).map(e=>{let[t,o]=e;return`<dl><dt>${t}</dt><dd>${o}</dd></dl>`}).join(""):`<dl><dd>${t.noCookies}</dd></dl>`}</details></section>`}).join("")}</div><nav><button data-id="accept">${t.accept}</button><button data-id="save">${t.save}</button><button data-id="reject">${t.reject}</button></nav></div></dialog>`.replaceAll("{link}",`<a href="${t.linkURL}">${t.linkText}</a>`),d.querySelectorAll("button").forEach(e=>e.addEventListener("click",p)),(o=d.querySelector("dialog")).addEventListener("close",f),o.addEventListener("cancel",b);let e=d.querySelector(".more");e&&e.addEventListener("click",e.remove),d.querySelectorAll("[data-s]").forEach(e=>e.addEventListener("change",t=>{e.parentElement.classList.toggle("checked",t.target.checked)})),n.body.appendChild(d)}(),T(),a[t.global].consentTime?(u(!1),C()):t.force&&$(),e={consent:k,invalidate:m,update:j,on:(t,o)=>{let n=`${c}:${t}`;return l[n]||(l[n]=[]),l[n].push(o),e},off:(e,t)=>{let o=`${c}:${e}`;l[o]&&(l[o]=l[o].filter(e=>e!==t))}}}}; |
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
Oops, something went wrong.