tracking link actions in text mode

This commit is contained in:
2018-11-04 13:15:23 +01:00
parent d46b38afe6
commit c29d18cf86
6 changed files with 36 additions and 5 deletions
+23 -3
View File
@@ -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);
}
}