Cookie consent approval

Change-Id: If4302e8bc58038fdbfb8c40052db65dd48bc591a
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
diff --git a/cookieconsent.php b/cookieconsent.php
new file mode 100644
index 0000000..1aae434
--- /dev/null
+++ b/cookieconsent.php
@@ -0,0 +1,16 @@
+<?php
+function hasCookieConsent() {
+  return isset($_COOKIE['eclipse_cookieconsent_status'])
+   && $_COOKIE['eclipse_cookieconsent_status'] === 'allow';
+}
+?>
+<script defer>
+setTimeout(function () {
+  var cookieButtons = document.querySelectorAll('.cc-compliance .cc-btn')
+  for (var i=0; i<cookieButtons.length; i++) {
+    cookieButtons[i].addEventListener("click", function () {
+      location.reload()
+    });
+  }
+}, 1000)
+</script>
diff --git a/credits.php b/credits.php
index bb4628d..64de574 100644
--- a/credits.php
+++ b/credits.php
@@ -4,6 +4,9 @@
 <head>
   <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
   <?php include 'cdn.php';?>
+  <link rel="stylesheet" type="text/css" href="//www.eclipse.org/eclipse.org-common/themes/solstice/public/stylesheets/vendor/cookieconsent/cookieconsent.min.css" />
+  <script src="//www.eclipse.org/eclipse.org-common/themes/solstice/public/javascript/vendor/cookieconsent/default.min.js"></script>
+  <?php include 'cookieconsent.php'?>
   <script src="js/materialize.min.js"></script>
   <script src="js/ui-helper.js" defer></script>
   <link href="css/style.css" rel="stylesheet" type="text/css">
diff --git a/documentation.php b/documentation.php
index c9f03fa..ed43ca3 100644
--- a/documentation.php
+++ b/documentation.php
@@ -6,6 +6,9 @@
   <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
   <link href="https://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet">
   <?php include 'cdn.php';?>
+  <link rel="stylesheet" type="text/css" href="//www.eclipse.org/eclipse.org-common/themes/solstice/public/stylesheets/vendor/cookieconsent/cookieconsent.min.css" />
+  <script src="//www.eclipse.org/eclipse.org-common/themes/solstice/public/javascript/vendor/cookieconsent/default.min.js"></script>
+  <?php include 'cookieconsent.php'?>
   <script src="js/materialize.min.js"></script>
   <script src="js/ui-helper.js" defer></script>
   <link href="css/style.css" rel="stylesheet" type="text/css" />
diff --git a/getting-started.php b/getting-started.php
index 7dcfc94..20a097e 100644
--- a/getting-started.php
+++ b/getting-started.php
@@ -6,6 +6,9 @@
   <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
   <link href="https://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet">
   <?php include 'cdn.php'; ?>
+  <link rel="stylesheet" type="text/css" href="//www.eclipse.org/eclipse.org-common/themes/solstice/public/stylesheets/vendor/cookieconsent/cookieconsent.min.css" />
+  <script src="//www.eclipse.org/eclipse.org-common/themes/solstice/public/javascript/vendor/cookieconsent/default.min.js"></script>
+  <?php include 'cookieconsent.php'?>
   <script src="js/materialize.min.js"></script>
   <script src="js/ui-helper.js" defer></script>
   <link href="css/style.css" rel="stylesheet" type="text/css" />
diff --git a/index.php b/index.php
index 2fadf46..6fc1e04 100644
--- a/index.php
+++ b/index.php
@@ -8,9 +8,16 @@
   <?php include 'cdn.php';?>
   <script src="js/ui-helper.js" defer></script>
   <link href="css/style.css" rel="stylesheet" type="text/css" />
+  <link rel="stylesheet" type="text/css" href="//www.eclipse.org/eclipse.org-common/themes/solstice/public/stylesheets/vendor/cookieconsent/cookieconsent.min.css" />
+  <script src="//www.eclipse.org/eclipse.org-common/themes/solstice/public/javascript/vendor/cookieconsent/default.min.js"></script>
+  <?php include 'cookieconsent.php'?>
   <meta charset="UTF-8"/>
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-  <?php include 'analytics.php';?>
+  <?php
+  if (hasCookieConsent()) {
+    include 'analytics.php';
+  }
+  ?>
   <!-- Marquee -->
   <script src="js/jquery.marquee.min.js"></script>
   <link href="css/style.css" rel="stylesheet" defer></defer>
@@ -31,7 +38,6 @@
   <meta name="author" content="Eclipse Kapua" />
 </head>
 <body>
-  <?php include 'twitter.php';?>
   <?php include 'navbar.php';?>
   <div class="main-content" id="main-content">
     <section id="project-overview">
@@ -71,12 +77,11 @@
             <li><img src="<?= $cdn_url ?>img/contribute_code.svg"></img> <a href="https://github.com/eclipse/kapua" target="_blank">Contribute Code</a></li>
           </ul>
         </div>
-        <div class="tweets">
-        <div class="twitter-feed"> <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/search?q=%40eclipsekura%20-RT%20OR%20%23eclipsekapua%20-RT" data-widget-id="786273082092630024">Tweets about @eclipsekura -RT OR #eclipsekapua -RT</a>
-            <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
-           </div>
-      </div>
-    </div>
+        <?php
+        if (hasCookieConsent()) {
+          include('twitter.php');
+        }
+        ?>
     </section>
     <section id="involved-parties">
       <h3>Who is Involved</h3>
diff --git a/twitter.php b/twitter.php
index f702eda..052aa86 100644
--- a/twitter.php
+++ b/twitter.php
@@ -14,3 +14,8 @@
 
   return t;
 }(document, "script", "twitter-wjs"));</script>
+<div class="tweets">
+<div class="twitter-feed"> <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/search?q=%40eclipsekura%20-RT%20OR%20%23eclipsekapua%20-RT" data-widget-id="786273082092630024">Tweets about @eclipsekura -RT OR #eclipsekapua -RT</a>
+    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
+   </div>
+</div>