Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pietsch <michael@mi-pietsch.de>2018-05-30 03:27:21 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2018-05-30 03:27:21 +0300
commit5524432854db0f2b613df291a5276237de84aff4 (patch)
treea5fdede6f9b420cac7c0c54954de312972a1fd1a /plugins/CoreAdminHome
parenta36f26979a7e104d05b5b6310c0315b18ed5eb5f (diff)
On opt-out page move js to separate file to allow not specifying inline-script CSP (#12873)
* on opt-out page move js to separate file to fix inline-script (CSP) * Compatibility of separate optOutJs with tracker-proxy * remove destinction between proxy and normal request * revert unwanted changes of /tmp/.gitkeep and created .htaccess * In optout form, clear new window closed check interval after new window is closed. Otherwise, if reload takes more than 1s, the interval will run again and try another reload, cancelling the pending one. Which results in no reload occuring.
Diffstat (limited to 'plugins/CoreAdminHome')
-rw-r--r--plugins/CoreAdminHome/OptOutManager.php5
-rw-r--r--plugins/CoreAdminHome/javascripts/optOut.js22
-rw-r--r--plugins/CoreAdminHome/templates/optOut.twig19
3 files changed, 26 insertions, 20 deletions
diff --git a/plugins/CoreAdminHome/OptOutManager.php b/plugins/CoreAdminHome/OptOutManager.php
index 9b2a378ad6..bd854c367f 100644
--- a/plugins/CoreAdminHome/OptOutManager.php
+++ b/plugins/CoreAdminHome/OptOutManager.php
@@ -198,10 +198,13 @@ class OptOutManager
'language' => $lang,
'setCookieInNewWindow' => 1
), false);
-
+
$this->addStylesheet($this->optOutStyling());
$this->view = new View("@CoreAdminHome/optOut");
+
+ $this->addJavaScript('plugins/CoreAdminHome/javascripts/optOut.js', $false);
+
$this->view->setXFrameOptions('allow');
$this->view->dntFound = $dntFound;
$this->view->trackVisits = $trackVisits;
diff --git a/plugins/CoreAdminHome/javascripts/optOut.js b/plugins/CoreAdminHome/javascripts/optOut.js
new file mode 100644
index 0000000000..a1d7a8e11c
--- /dev/null
+++ b/plugins/CoreAdminHome/javascripts/optOut.js
@@ -0,0 +1,22 @@
+function submitForm(e, form) {
+ if (e.preventDefault) { // IE8 and below do not support preventDefault
+ e.preventDefault();
+ }
+
+ var now = Date.now ? Date.now() : (+(new Date())), // Date.now does not exist in < IE8
+ newWindow = window.open(form.action + '&time=' + now);
+
+ var interval = setInterval(function () {
+ if (newWindow.closed) {
+ window.location.reload();
+ clearInterval(interval);
+ }
+ }, 1000);
+ return false;
+}
+
+document.addEventListener('DOMContentLoaded', function() {
+ var trackVisitsCheckbox = document.getElementById('trackVisits');
+ if (typeof trackVisitsCheckbox === "undefined") trackVisitsCheckbox.addEventListener('click', function(event) { submitForm(event, this.form); });
+});
+
diff --git a/plugins/CoreAdminHome/templates/optOut.twig b/plugins/CoreAdminHome/templates/optOut.twig
index 777f6bef3b..e4c77bcb98 100644
--- a/plugins/CoreAdminHome/templates/optOut.twig
+++ b/plugins/CoreAdminHome/templates/optOut.twig
@@ -9,25 +9,6 @@
<meta http-equiv="refresh" content="0; url={{ reloadUrl }}&amp;nonce={{ nonce }}" />
{% endif %}
- <script>
- function submitForm(e, form) {
- if (e.preventDefault) { // IE8 and below do not support preventDefault
- e.preventDefault();
- }
-
- var now = Date.now ? Date.now() : (+(new Date())), // Date.now does not exist in < IE8
- newWindow = window.open(form.action + '&time=' + now);
-
- setInterval(function () {
- if (newWindow.closed) {
- window.location.reload();
- }
- }, 1000);
-
- return false;
- }
- </script>
-
{% if stylesheets.external|length > 0 %}
{% for style in stylesheets.external %}
<link href="{{ style|raw }}" rel="stylesheet" type="text/css">