Explicitly check whether cookies has been set
diff --git a/emfforms/index.html b/emfforms/index.html
index a566200..a903381 100644
--- a/emfforms/index.html
+++ b/emfforms/index.html
@@ -444,19 +444,24 @@
<!-- End Google Tag Manager -->
<script>
(function(w) {
- w.cookieconsent.init(function() {
+ if (hasCookie("eclipse_cookieconsent_status")) {
if (getCookie("eclipse_cookieconsent_status", "allow")) {
- $.getScript(
- "https://platform.twitter.com/widgets.js",
- function () { createTimeline() }
- );
+ $.getScript(
+ "https://platform.twitter.com/widgets.js",
+ function() { createTimeline() }
+ );
}
- });
- if (getCookie("eclipse_cookieconsent_status", "allow")) {
- $.getScript(
- "https://platform.twitter.com/widgets.js",
- function() { createTimeline() }
- );
+ } else {
+ w.cookieconsent.init(function () {
+ if (getCookie("eclipse_cookieconsent_status", "allow")) {
+ $.getScript(
+ "https://platform.twitter.com/widgets.js",
+ function () {
+ createTimeline()
+ }
+ );
+ }
+ });
}
})(window)
</script>
diff --git a/public/javascripts/common.js b/public/javascripts/common.js
index a92d15a..1804270 100644
--- a/public/javascripts/common.js
+++ b/public/javascripts/common.js
@@ -6,7 +6,11 @@
return cookieValues.reduce(function (acc, val) { return acc && val === expected }, true);
}
-var getCookies = function(name){
+function hasCookie(name) {
+ return getCookies(name).length > 0;
+}
+
+function getCookies(name){
var pairs = document.cookie.split(";");
var cookies = [];
for (var i = 0; i < pairs.length; i++){