|
1 | 1 | {% extends "base.html" %} |
2 | 2 |
|
3 | 3 | {% block analytics %} |
| 4 | +<!-- Microsoft Clarity with Consent Mode --> |
4 | 5 | <script type="text/javascript"> |
5 | | - (function(c,l,a,r,i,t,y){ |
6 | | - c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; |
7 | | - t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; |
8 | | - y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); |
9 | | - })(window, document, "clarity", "script", "5pd40fk720"); |
| 6 | + (function () { |
| 7 | + // Determine the current consent state before loading Clarity |
| 8 | + var storedConsent = null; |
| 9 | + try { |
| 10 | + storedConsent = window.localStorage && window.localStorage.getItem("clarity_consent"); |
| 11 | + } catch (e) { |
| 12 | + // If localStorage is unavailable (e.g., privacy mode), fall back to denied |
| 13 | + storedConsent = null; |
| 14 | + } |
| 15 | + |
| 16 | + // Default to "denied" when there is no prior explicit "granted" choice |
| 17 | + var defaultConsent = storedConsent === "granted" ? "granted" : "denied"; |
| 18 | + |
| 19 | + (function (c, l, a, r, i, t, y) { |
| 20 | + c[a] = c[a] || function () { |
| 21 | + (c[a].q = c[a].q || []).push(arguments); |
| 22 | + }; |
| 23 | + |
| 24 | + // Set consentv2 state before loading the Clarity script so it honors consent immediately |
| 25 | + c[a]("consentv2", { |
| 26 | + ad_Storage: defaultConsent, |
| 27 | + analytics_Storage: defaultConsent |
| 28 | + }); |
| 29 | + |
| 30 | + t = l.createElement(r); |
| 31 | + t.async = 1; |
| 32 | + t.src = "https://www.clarity.ms/tag/" + i; |
| 33 | + y = l.getElementsByTagName(r)[0]; |
| 34 | + y.parentNode.insertBefore(t, y); |
| 35 | + })(window, document, "clarity", "script", "5pd40fk720"); |
| 36 | + })(); |
| 37 | +</script> |
| 38 | + |
| 39 | +<!-- Cookie consent banner --> |
| 40 | +<style> |
| 41 | + #cookie-consent-banner { |
| 42 | + position: fixed; |
| 43 | + bottom: 0; |
| 44 | + left: 0; |
| 45 | + right: 0; |
| 46 | + background: var(--md-default-bg-color, #fff); |
| 47 | + border-top: 1px solid var(--md-default-fg-color--lightest, #e0e0e0); |
| 48 | + padding: 1rem 1.5rem; |
| 49 | + display: flex; |
| 50 | + flex-wrap: wrap; |
| 51 | + align-items: center; |
| 52 | + justify-content: center; |
| 53 | + gap: 1rem; |
| 54 | + z-index: 9999; |
| 55 | + box-shadow: 0 -2px 8px rgba(0,0,0,0.1); |
| 56 | + font-size: 0.82rem; |
| 57 | + } |
| 58 | + #cookie-consent-banner p { |
| 59 | + margin: 0; |
| 60 | + flex: 1 1 300px; |
| 61 | + color: var(--md-default-fg-color, #333); |
| 62 | + } |
| 63 | + #cookie-consent-banner a { |
| 64 | + color: var(--md-accent-fg-color, #448aff); |
| 65 | + } |
| 66 | + #cookie-consent-banner .consent-buttons { |
| 67 | + display: flex; |
| 68 | + gap: 0.5rem; |
| 69 | + flex-shrink: 0; |
| 70 | + } |
| 71 | + #cookie-consent-banner button { |
| 72 | + padding: 0.4rem 1.2rem; |
| 73 | + border: none; |
| 74 | + border-radius: 4px; |
| 75 | + cursor: pointer; |
| 76 | + font-size: 0.82rem; |
| 77 | + font-weight: 500; |
| 78 | + } |
| 79 | + #cookie-consent-accept { |
| 80 | + background: var(--md-primary-fg-color, #4051b5); |
| 81 | + color: var(--md-primary-bg-color, #fff); |
| 82 | + } |
| 83 | + #cookie-consent-decline { |
| 84 | + background: var(--md-default-fg-color--lightest, #e0e0e0); |
| 85 | + color: var(--md-default-fg-color, #333); |
| 86 | + } |
| 87 | +</style> |
| 88 | +<script type="text/javascript"> |
| 89 | + (function() { |
| 90 | + if (localStorage.getItem("clarity_consent")) return; |
| 91 | + |
| 92 | + var banner = document.createElement("div"); |
| 93 | + banner.id = "cookie-consent-banner"; |
| 94 | + banner.setAttribute("role", "dialog"); |
| 95 | + banner.setAttribute("aria-label", "Cookie consent"); |
| 96 | + banner.innerHTML = |
| 97 | + '<p>This site uses cookies via Microsoft Clarity to understand how you use our documentation. ' + |
| 98 | + '<a href="https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-cookies" ' + |
| 99 | + 'target="_blank" rel="noopener">Learn more</a></p>' + |
| 100 | + '<div class="consent-buttons">' + |
| 101 | + '<button id="cookie-consent-decline">Decline</button>' + |
| 102 | + '<button id="cookie-consent-accept">Accept</button>' + |
| 103 | + '</div>'; |
| 104 | + |
| 105 | + document.addEventListener("DOMContentLoaded", function() { |
| 106 | + document.body.appendChild(banner); |
| 107 | + |
| 108 | + document.getElementById("cookie-consent-accept").addEventListener("click", function() { |
| 109 | + localStorage.setItem("clarity_consent", "granted"); |
| 110 | + window.clarity("consentv2", { |
| 111 | + ad_Storage: "granted", |
| 112 | + analytics_Storage: "granted" |
| 113 | + }); |
| 114 | + banner.remove(); |
| 115 | + }); |
| 116 | + |
| 117 | + document.getElementById("cookie-consent-decline").addEventListener("click", function() { |
| 118 | + localStorage.setItem("clarity_consent", "denied"); |
| 119 | + window.clarity("consentv2", { |
| 120 | + ad_Storage: "denied", |
| 121 | + analytics_Storage: "denied" |
| 122 | + }); |
| 123 | + banner.remove(); |
| 124 | + }); |
| 125 | + }); |
| 126 | + })(); |
10 | 127 | </script> |
11 | 128 | {% endblock %} |
12 | 129 |
|
|
0 commit comments