started to use ES6 coding standard

This commit is contained in:
Bachir Soussi Chiadmi
2018-02-10 17:08:56 +01:00
parent d834e2db12
commit eb28a86406
8 changed files with 68 additions and 72 deletions
+28 -30
View File
@@ -25,7 +25,7 @@ var _Dot = {
links:null,
parents:[],
lang:_dbs.lang,
setuptext:function(vn){
setuptext(vn){
// console.log('setuptext', vn);
// construct text
@@ -40,7 +40,7 @@ var _Dot = {
this.summary = markdown.renderInline(this.summary) + " …";
},
oninit: function(vn){
oninit(vn){
this.id = vn.attrs.id;
this.type = vn.attrs.type;
@@ -60,28 +60,28 @@ var _Dot = {
}
},
oncreate: function(vn){
oncreate(vn){
if(this.active){
vn.dom.classList.remove('disabled');
}else{
vn.dom.classList.add('disabled');
}
},
onbeforeupdate: function(vn){
onbeforeupdate(vn){
// console.log('onbeforeupdate');
if(this.lang != _dbs.lang){
this.lang = _dbs.lang;
this.setuptext(vn);
}
},
view: function(vn){
view(vn){
if (this.active && this.opened) {
// full view of dot with linked dots
// console.log('_Dot view '+this.id+' parents :',this.parents);
var dot_content = [
// links to
this.links.to.length
? m('nav', {'class':'links to'}, this.links.to.map(function(id){
? m('nav', {'class':'links to'}, this.links.to.map(id => {
// console.log(id);
if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
return m(_Dot, {
@@ -104,7 +104,7 @@ var _Dot = {
// full text
m('section', {
'class':'text',
onmouseover: function(e){
onmouseover(e){
e.preventDefault();
if(e.target.nodeName == "A" ){
// console.log("over e.target", e.target);
@@ -119,7 +119,7 @@ var _Dot = {
}
}
},
onclick:function(e){
onclick(e){
e.preventDefault();
if(e.target.nodeName == "A" ){
// console.log("over e.target", e.target);
@@ -132,7 +132,7 @@ var _Dot = {
}, m.trust(this.rendered_text)),
// links from
this.links.from.length
? m('nav', {'class':'links from'}, this.links.from.map(function(id){
? m('nav', {'class':'links from'}, this.links.from.map(id => {
// retrun a dot
return m(_Dot, {
"id":id,
@@ -154,7 +154,7 @@ var _Dot = {
m('span', {'class':'bullet'}, m.trust('•')),
m('p', {
'class':'summary',
onclick:function(e){
onclick(e){
// TODO: animate openening (text and links separatly)
vn.state.opened = true;
}
@@ -169,7 +169,7 @@ var _Dot = {
dot_content
);
},
onupdate: function(vn){
onupdate(vn){
// console.log('_Dot : onupdate', vn);
if(this.active){
if (this.opened){
@@ -213,7 +213,7 @@ var _Child = {
type:null,
// nested:false,
text:'',
oninit: function(vn){
oninit(vn){
// console.log('vn.attrs', vn.attrs);
this.id = vn.attrs.id;
this.type = vn.attrs.type;
@@ -221,12 +221,12 @@ var _Child = {
this.text = vn.attrs.text;
// this.nested = vn.attrs.nested || false;
},
onbeforeupdate: function(vn, old){
onbeforeupdate(vn, old){
// this.nested = vn.attrs.nested || false;
this.type = vn.attrs.type;
this.text = vn.attrs.text;
},
view: function(vn){
view(vn){
return m(_Dot, {"id":this.id, 'text':this.text, 'type':this.type});
}
};
@@ -243,7 +243,7 @@ var _Enonce = {
text:null,
// nested:false,
childs:[],
oninit:function(vn){
oninit(vn){
// // console.log('Enonce on init', vn);
this.partid = vn.attrs.partid;
this.id = vn.attrs.id;
@@ -252,7 +252,7 @@ var _Enonce = {
this.childs = vn.attrs.childs || [];
// this.nested = vn.attrs.nested || false;
},
onbeforeupdate:function(vn, old) {
onbeforeupdate(vn, old) {
// console.log(vn.attrs.childs);
this.title = vn.attrs.title || "";
this.text = vn.attrs.text;
@@ -260,15 +260,13 @@ var _Enonce = {
// this.nested = vn.attrs.nested || false;
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
},
view: function(vn){
view(vn){
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
return [
// create dot
m(_Dot, {"id":this.id, 'text':this.text,'type':this.title}),
// addd children
this.childs.map(function(c){
return m(_Child, c);
})
this.childs.map(c => { return m(_Child, c); })
]
}
}
@@ -280,17 +278,17 @@ var _Enonce = {
// / ____/ /_/ / / / /_
// /_/ \__,_/_/ \__/
var _Part = {
oninit: function(vn){
oninit(vn){
this.id = vn.attrs.id;
this.title = vn.attrs.title || "";
this.enonces = vn.attrs.enonces;
},
onbeforeupdate: function(vn, old){
onbeforeupdate(vn, old){
// console.log('_Part, onbeforeupdate old',old);
this.title = vn.attrs.title || "";
this.enonces = vn.attrs.enonces;
},
view: function(vn){
view(vn){
// console.log(vn.attrs.enonces);
return m("section", {
'id' :this.id,
@@ -300,7 +298,7 @@ var _Part = {
// create title node
m("h1", {'class':'part-title', 'part':this.id}, m.trust(markdown.renderInline(this.title))),
// create text node
this.enonces.map(function(e){
this.enonces.map(e => {
// console.log(e.text);
// return m(_Enonce, Object.assign({"partid":this.id},e))
switch (e.type) {
@@ -328,16 +326,16 @@ var _Part = {
// _/ // / / / /_/ / / /_/ /
// /___/_/ /_/\__/_/ \____/
var _Intro = {
oninit : function(vn){
oninit(vn){
console.log('_Intro : oninit : vn', vn);
this.id = vn.attrs.id;
this.text = vn.attrs.text || '';
},
onbeforeupdate : function(vn, old){
onbeforeupdate(vn, old){
this.id = vn.attrs.id;
this.text = vn.attrs.text || '';
},
view : function(vn){
view(vn){
return m("section", {'class':'intro'}, m("p",m.trust(markdown.renderInline(this.text))));
}
}
@@ -349,15 +347,15 @@ var _Intro = {
// / /___/ /_/ / / / / / / / __/ /__/ /_/ / /_/ / / / (__ )
// \____/\____/_/ /_/_/ /_/\___/\___/\__/_/\____/_/ /_/____/
module.exports = {
oncreate: function(vn){
oncreate(vn){
document.body.classList.add('mode-connections');
_Ui.init();
},
view: function(vn){
view(vn){
console.log('_ModeConnections view', vn.attrs.lang);
return [
m(_Header),
m('main', {id:"content", 'class':'mode-connections'}, _dbs.data[vn.attrs.lang].map(function(p){
m('main', {id:"content", 'class':'mode-connections'}, _dbs.data[vn.attrs.lang].map(p => {
if(p.id == 'intro'){
return m(_Intro,p);
}else{