diff options
| author | Colleen <[email protected]> | 2023-01-17 04:57:45 -0400 |
|---|---|---|
| committer | Colleen <[email protected]> | 2023-01-17 04:57:45 -0400 |
| commit | c3b1e540fb7e5a595d7b43860a43dbcea5a5ba1d (patch) | |
| tree | 14e5107a2fd4e6bb6d8e60ab085eed45bf8d556a /common/common.js | |
| parent | 629087c403d9112fb3a859cc6064557b3980b274 (diff) | |
| download | raylib.com-c3b1e540fb7e5a595d7b43860a43dbcea5a5ba1d.tar.gz raylib.com-c3b1e540fb7e5a595d7b43860a43dbcea5a5ba1d.zip | |
Updated style; Added tracking acknowledgement banner.
Diffstat (limited to 'common/common.js')
| -rw-r--r-- | common/common.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/common/common.js b/common/common.js new file mode 100644 index 0000000..d79f659 --- /dev/null +++ b/common/common.js @@ -0,0 +1,36 @@ +/* Cookies */ +// Source: https://www.w3schools.com/js/js_cookies.asp +function getCookie(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 ""; +} + +/* Analytics */ +if(getCookie("confirmed_analytics") !== "true") { + document.body.innerHTML += + "<div id='analytics-banner'>\ + <p><strong>NOTE: </strong>This website uses Google Analytics to collect visitor statistics.</p>\ + <button id='analytics-confirm'><strong>I UNDERSTAND</strong></button>\ + </div>"; + + const div_analyticsBanner = document.getElementById("analytics-banner"); + const btn_analyticsConfirm = document.getElementById("analytics-confirm"); + + btn_analyticsConfirm.onclick = function() { + div_analyticsBanner.setAttribute("confirmed", "true"); + document.cookie += "confirmed_analytics=true;"; + }; +}
\ No newline at end of file |
