diff --git a/package.json b/package.json index 4b9eb3c85..70ee6c393 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "clipboard": "^1.7.1", "compiler-opt-info": "0.0.4", "compression": "^1.7.1", + "cookieconsent": "^3.0.6", "cross-env": "^5.1.3", "denodeify": "^1.2.1", "es6-promise": "^4.1.1", diff --git a/static/cookies.html b/static/cookies.html index fbf1e2d2a..f7cec5d92 100644 --- a/static/cookies.html +++ b/static/cookies.html @@ -45,6 +45,5 @@ we make use of your browser's localStorage, where we place:

and you can set most browsers to prevent them from being placed. If you do this, however, you may have to manually adjust some preferences every time you visit a site and some services and functionalities may not work.

-

You can easily accept or reject the use of cookies and related technologies on this site by choosing one of the following options:

diff --git a/static/explorer.css b/static/explorer.css index d90f1163e..864472fcd 100644 --- a/static/explorer.css +++ b/static/explorer.css @@ -1,3 +1,5 @@ +@import url("~cookieconsent/build/cookieconsent.min.css"); + /* TEMP HACK: https://github.com/Microsoft/monaco-editor/issues/349 */ .quick-open-tree .row { margin-left: 0; diff --git a/static/main.js b/static/main.js index 1bd84b7a4..244bfa581 100644 --- a/static/main.js +++ b/static/main.js @@ -27,6 +27,7 @@ require("monaco-loader")().then(function () { require('bootstrap'); require('bootstrap-slider'); + require('cookieconsent'); var analytics = require('analytics'); var sharing = require('sharing'); @@ -76,6 +77,70 @@ require("monaco-loader")().then(function () { }); } + function setupButtons() { + var alertSystem = new Alert(); + + window.cookieconsent.initialise({ + palette: { + popup: { + background: "#eaf7f7", + text: "#5c7291" + }, + button: { + background: "#56cbdb", + text: "#ffffff" + } + }, + theme: "edgeless", + type: "opt-in", + content: { + href: "#", + message: "Compiler Explorer uses cookies & related technologies to provide a better service.", + dismiss: 'Do NOT allow cookies', + header: 'This is amazing, isnt it?' + }, + law: { + regionalLaw: false + }, + location: { + services: [] + }, + cookie: { + domain: '.localhost:10240' + }, + elements: { + messagelink: '' + + '{{message}} {{link}}', + link: '' + + '{{link}}' + }, + // fn(status, old) + onStatusChange: function () { + // The user selected an option, act accordingly + } + }); + + $('#ui-reset').click(function () { + local.remove('gl'); + window.location.reload(); + }); + $('#thanks-to').click(function () { + alertSystem.alert("Special thanks to", $(require('./thanks.html'))); + }); + $('#changes').click(function () { + alertSystem.alert("Changelog", $(require('./changelog.html'))); + }); + var openCookiePolicy = function () { + alertSystem.alert("Cookies & related technologies policy", $(require('./cookies.html'))); + }; + $('#cookies').click(openCookiePolicy); + $('.cookies').click(openCookiePolicy); + $('#privacy').click(function () { + alertSystem.alert("Privacy policy", $(require('./privacy.html'))); + }); + } + function start() { analytics.initialise(); @@ -105,7 +170,8 @@ require("monaco-loader")().then(function () { }); var hashPart = null; - var linkablePopups = ['#thanks-to', '#changes', '#cookies', '#setting']; + // Which buttons act as a linkable popup + var linkablePopups = ['#thanks-to', '#changes', '#cookies', '#setting', '#privacy']; if (linkablePopups.indexOf(window.location.hash) > -1) { hashPart = window.location.hash; window.location.hash = ""; @@ -178,32 +244,15 @@ require("monaco-loader")().then(function () { }); } - var alertSystem = new Alert(); - setupAdd($('#add-diff'), function () { return Components.getDiff(); }); setupAdd($('#add-editor'), function () { return Components.getEditor(); }); - $('#ui-reset').click(function () { - local.remove('gl'); - window.location.reload(); - }); - $('#thanks-to').click(function () { - alertSystem.alert("Special thanks to", $(require('./thanks.html'))); - }); - $('#changes').click(function () { - alertSystem.alert("Changelog", $(require('./changelog.html'))); - }); - $('#cookies').click(function () { - alertSystem.ask("Cookies & related technologies", $(require('./cookies.html')), { - yesHtml: 'I consent', - yesClass: 'consent-cookie-yes', - noHtml: 'I DO NOT consent', - noClass: 'consent-cookie-no' - }); - }); + + setupButtons(); + if (hashPart) { var element = $(hashPart); if (element) element.click(); diff --git a/static/privacy.html b/static/privacy.html new file mode 100644 index 000000000..c9d3b79b0 --- /dev/null +++ b/static/privacy.html @@ -0,0 +1,25 @@ + + + + +

What data do we store?

+

None. We're not on the business of collecting user data.

+

What do you collect?

+ +

What don't you store?

+ +

I don't trust you

+

The page code is hosted on GitHub, both the client/server code + and the behind the scenes code that powers it

+ + diff --git a/views/index.pug b/views/index.pug index 83556012a..5b6755c5c 100644 --- a/views/index.pug +++ b/views/index.pug @@ -63,20 +63,14 @@ html(lang="en") li#changes: a(href="#") Changelog if sharingEnabled li#socialshare + li.dropdown + a.dropdown-toggle(href="#" data-toggle="dropdown") Policies#[b.caret] + ul.dropdown-menu.menu-other + li#cookies: a(href="#") Cookie policy + li#privacy: a(href="#") Privacy policy #root - .navbar-fixed-bottom - .container-fluid - p - | This page uses cookie/localStorage technology to store your page state, including code, editor settings and window layout. - a#cookies(href="#") - | Find out more on how we use cookie/localStorage technology and how you can change your settings - a(href="#") - | I consent - a(href="#") - | I DO NOT consent - include templates.pug diff --git a/yarn.lock b/yarn.lock index ceb2bf4f3..e7def5291 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1033,6 +1033,10 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" +cookieconsent@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/cookieconsent/-/cookieconsent-3.0.6.tgz#147afa3e594e7b1a7826e49cb322aa0beee7b987" + cookiejar@2.0.x: version "2.0.6" resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.0.6.tgz#0abf356ad00d1c5a219d88d44518046dd026acfe"