MAPG-172 add cookie consent DIV and JS handler

This commit is contained in:
Bence Pőcze 2020-06-24 21:57:34 +02:00
parent 251bf1be3d
commit e8c246f002
2 changed files with 33 additions and 0 deletions

View File

@ -14,5 +14,30 @@
<script src="<?= $jsFile ?>"></script> <script src="<?= $jsFile ?>"></script>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<?php if (!isset($_COOKIE['COOKIES_CONSENT'])): ?>
<script>
(function () {
MapGuesser = {
cookiesAgreed: false,
agreeCookies: function () {
if (MapGuesser.cookiesAgreed) {
return;
}
var expirationDate = new Date(new Date().getTime() + 20 * 365 * 24 * 60 * 60 * 1000).toUTCString();
document.cookie = 'COOKIES_CONSENT=1; expires=' + expirationDate + '; path=/';
MapGuesser.cookiesAgreed = true;
document.getElementById('cookiesNotice').style.display = 'none';
}
};
window.onclick = function () {
MapGuesser.agreeCookies();
};
})();
</script>
<?php endif; ?>
</body> </body>
</html> </html>

View File

@ -22,6 +22,14 @@
<link rel="icon" type="image/png" sizes="16x16" href="<?= $_ENV['STATIC_ROOT'] ?>/img/favicon/16x16.png?rev=<?= REVISION ?>"> <link rel="icon" type="image/png" sizes="16x16" href="<?= $_ENV['STATIC_ROOT'] ?>/img/favicon/16x16.png?rev=<?= REVISION ?>">
</head> </head>
<body> <body>
<?php if (!isset($_COOKIE['COOKIES_CONSENT'])): ?>
<div id="cookiesNotice">
<p class="small">
<?= $_ENV['APP_NAME'] ?> uses cookies to improve user experience. By using the app or clicking I agree, you consent to our use of cookies.
</p>
<button id="agreeCookies" class="small marginTop">I agree</button>
</div>
<?php endif; ?>
<div id="loading"> <div id="loading">
<img src="<?= $_ENV['STATIC_ROOT'] ?>/img/loading.svg?rev=<?= REVISION ?>" width="64" height="64"> <img src="<?= $_ENV['STATIC_ROOT'] ?>/img/loading.svg?rev=<?= REVISION ?>" width="64" height="64">
</div> </div>