Skip to content
This repository was archived by the owner on Aug 14, 2023. It is now read-only.

Hotfix/cookie message #42

Merged
merged 2 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions sites/all/modules/itk/itk_siteimprove/js/itk-siteimprove.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@

Drupal.behaviors.itkSiteimprove = {
attach: function (context, settings) {
var key = settings.itk_siteimprove.key;

let key = settings.itk_siteimprove.key;
if (key) {
(function () {
var sz = document.createElement('script');
sz.type = 'text/javascript';
sz.async = true;
sz.src = '//ssl.siteimprove.com/js/siteanalyze_' + key + '.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(sz, s);
})();
window.addEventListener('CookieInformationConsentGiven', function (event) {
if (CookieInformation.getConsentGivenFor('cookie_cat_statistic')) {
(function () {
let sz = document.createElement('script');
sz.type = 'text/javascript';
sz.async = true;
sz.src = '//ssl.siteimprove.com/js/siteanalyze_' + key + '.js';
let s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(sz, s);
})();
}
}, false);
}
}
};
Expand Down
19 changes: 19 additions & 0 deletions sites/all/themes/osto_web/templates/html.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php print $doctype; ?>
<html lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>"<?php print $rdf->version . $rdf->namespaces; ?>>
<head<?php print $rdf->profile; ?>>
<script id="CookieConsent" src="https://policy.app.cookieinformation.com/uc.js" data-culture="DA" type="text/javascript"></script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this JS not have been added in itk_siteimprove_init() hook (which is activated on every page call) with add_js or in an hook_preprocess in itk_siteimprove so it is contained in the module.

This is an hidden dependency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://policy.app.cookieinformation.com/uc.js is not related in any way to siteimprove. It just adds cookie consent banner

<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body<?php print $attributes;?>>
<div id="skip-link">
<a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
</div>
<?php print $page_top; ?>
<?php print $page; ?>
<?php print $page_bottom; ?>
</body>
</html>