[MediaWiki-commits] [Gerrit] analytics/wikistats2[master]: Add central notice component and detect adblock

2017-11-21 Thread Fdans (Code Review)
Fdans has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383798 )

Change subject: Add central notice component and detect adblock
..


Add central notice component and detect adblock

Adblockers prevent wikistats from reaching AQS. This change adds an
ad test to see if there is an adblocker and warns the user about it.

Bug: T177491
Change-Id: I817dad5edd07682cfb1808384d3b9455a559d35b
---
M src/App.vue
A src/components/CentralNotice.vue
M src/store/index.js
3 files changed, 80 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Fdans: Looks good to me, approved



diff --git a/src/App.vue b/src/App.vue
index 2d3f91f..91e4167 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,5 +1,6 @@
 
 
+
 
 
 
@@ -19,6 +20,7 @@
 
 
 import TopNav from './components/TopNav';
+import CentralNotice from './components/CentralNotice';
 import TopicExplorer from './components/TopicExplorer';
 import SiteLanguage from './components/SiteLanguage';
 import BottomFooter from './components/BottomFooter';
@@ -35,6 +37,26 @@
 BottomFooter,
 Dashboard,
 Detail,
+CentralNotice
+},
+mounted () {
+this.isAdblockerOn() && this.warnAdBlocker();
+},
+
+methods: {
+isAdblockerOn () {
+let adTest = document.createElement('div');
+adTest.innerHTML = ' ';
+adTest.className = 'adsbox';
+$(this.$el).append(adTest);
+return adTest.offsetHeight === 0;
+},
+warnAdBlocker () {
+this.$store.state.centralNotice = {
+message: 'Your ad blocker is preventing Wikistats from 
reaching the server. Disable it to be able to see all metrics correctly.',
+level: 'error'
+}
+}
 },
 data () {
 return {
diff --git a/src/components/CentralNotice.vue b/src/components/CentralNotice.vue
new file mode 100644
index 000..bd5d462
--- /dev/null
+++ b/src/components/CentralNotice.vue
@@ -0,0 +1,57 @@
+
+