Browse Source

tracking link actions in text mode

Bachir Soussi Chiadmi 5 years ago
parent
commit
c29d18cf86
6 changed files with 34 additions and 3 deletions
  1. 4 0
      assets/dist/main.css
  2. 0 0
      assets/dist/main.js
  3. 0 0
      assets/dist/main.js.map
  4. 2 0
      assets/main.js
  5. 5 0
      assets/main.scss
  6. 23 3
      assets/modules/ModeText.js

+ 4 - 0
assets/dist/main.css

@@ -883,6 +883,10 @@ main#content.mode-text section.enonce {
         color: inherit; }
       main#content.mode-text section.enonce div.text div.paragraph span.link.text:after {
         content: ':'; }
+      main#content.mode-text section.enonce div.text div.paragraph span.unknown-link {
+        font-weight: 600;
+        text-decoration: line-through;
+        color: inherit; }
       main#content.mode-text section.enonce div.text div.paragraph section.enonce, main#content.mode-text section.enonce div.text div.paragraph section.item {
         padding-left: 2em;
         border-left: 1px solid #999; }

File diff suppressed because it is too large
+ 0 - 0
assets/dist/main.js


File diff suppressed because it is too large
+ 0 - 0
assets/dist/main.js.map


+ 2 - 0
assets/main.js

@@ -33,7 +33,9 @@ var Layout = {
 		if(typeof _paq !== 'undefined'){
 		  _paq.push(['setCustomUrl', m.route.get()]);
 		  // _paq.push(['setDocumentTitle', e.title]);
+			_paq.push(['setGenerationTimeMs', 0]);
 		  _paq.push(['trackPageView']);
+			// _paq.push(['trackEvent', 'Audio', 'play', node.title]);
 		}
 
 		return [

+ 5 - 0
assets/main.scss

@@ -373,6 +373,11 @@ main#content.mode-text{
         span.link.text:after{
           content:':'
         }
+        span.unknown-link{
+          font-weight: 600;
+          text-decoration:line-through;
+          color: inherit;
+        }
         section.enonce, section.item{
           padding-left:2em;
           border-left: 1px solid #999;

+ 23 - 3
assets/modules/ModeText.js

@@ -39,10 +39,11 @@ var _Link = {
     if (!this.tid_known) {
       // console.log(`!! in ${this.id}, target id ${this.tid} is unkonwn !!`);
     }
+
     if(this.opened && this.tid_known){
       console.log('link vn.state', vn.state);
-      // traget object
 
+      // traget object
       this.tob = Object.assign({"nested":true},_dbs.data_byid[vn.attrs.lang][this.tid]);
       // this.tob = Object.assign({'lang':vn.attrs.lang}, this.tob);
       console.log('this.tob',this.tob);
@@ -56,6 +57,11 @@ var _Link = {
                 // e.preventDefault();
                 console.log('click close btn', this);
                 vn.state.opened = false;
+                // matomo
+            		if(typeof _paq !== 'undefined'){
+                  // console.log('Matomo text closed', vn.state.tob.breadcrumb);
+            			_paq.push(['trackEvent', 'Text', 'closed', vn.state.tob.breadcrumb]);
+            		}
                 // return false;
               }
             }),//, m('span', m.trust("🗙"))),
@@ -64,19 +70,33 @@ var _Link = {
               : m(_Item, this.tob)
           ]
         );
-    }else{
+    }else if(this.tid_known){
       // console.log(vn);
+      this.tob = _dbs.data_byid[vn.attrs.lang][this.tid];
+
       return m('a', {
           'class':'link',
           'href':'#'+this.tid,
           'rel':this.tid,
           onclick(e){
             e.preventDefault();
-            console.log('click', this);
+            // console.log('click open this', this);
+            console.log('click open vn', vn);
+
             vn.state.opened = true;
+            // matomo
+            if(typeof _paq !== 'undefined'){
+              // console.log('Matomo text opened', vn.state.tob.breadcrumb);
+              _paq.push(['trackEvent', 'Text', 'opened', vn.state.tob.breadcrumb]);
+            }
             return false;
           }
         }, vn.children);
+    }else{
+      // if target is unknown
+      return m('span', {
+        'class':'unknown-link'
+      }, vn.children);
     }
 
   }

Some files were not shown because too many files changed in this diff