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
+25 -27
View File
@@ -18,15 +18,15 @@ var _Ui = require('./ui.js');
var _Link = {
tid:"",
opened:false,
oninit: function(vn){
oninit(vn){
// console.log("INIT LINK : vn", vn);
// define target id
this.tid = vn.attrs.href;
},
onbeforeupdate: function(vn){
onbeforeupdate(vn){
this.tid = vn.attrs.href;
},
view: function(vn){
view(vn){
this.tid_known = typeof _dbs.data_byid[_dbs.lang][this.tid] === 'undefined' ? false : true;
if (!this.tid_known) {
console.log('!! target id '+this.tid+' unkonwn !!');
@@ -47,7 +47,7 @@ var _Link = {
'class':'link',
'href':'#'+this.tid,
'rel':this.tid,
onclick:function(e){
onclick(e){
e.preventDefault();
console.log('click', this);
vn.state.opened = true;
@@ -128,7 +128,7 @@ var _Text = {
texthtml:"",
textdom:null,
textchilds:[],
parsetext: function(){
parsetext(){
// console.log('parsetext', this);
// !! we need to convert markdown to html here because parseTextDom() is recursive through nodes tree
// convert markdown to html
@@ -143,16 +143,16 @@ var _Text = {
console.log(this.textchilds);
}
},
oninit: function(vn){
oninit(vn){
this.id = vn.attrs.id;
this.text = vn.attrs.text || "";
this.parsetext();
},
onbeforeupdate: function(vn,old){
onbeforeupdate(vn,old){
this.text = vn.attrs.text;
this.parsetext();
},
view: function(vn){
view(vn){
// console.log('_Text :: view : '+vn.attrs.slug, vn);
return m('div',
{'class':'text'},
@@ -172,7 +172,7 @@ var _Item = {
part:null,
type:null,
nested:false,
oninit: function(vn){
oninit(vn){
// console.log('vn.attrs', vn.attrs);
this.id = vn.attrs.id;
this.type = vn.attrs.type;
@@ -180,12 +180,12 @@ var _Item = {
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("section", {
'id':this.id,
'class':'item'+(this.nested ? ' nested':'')
@@ -194,7 +194,7 @@ var _Item = {
// create title node
m("h3", {
// 'ref':vn.attrs.href,
onclick: function(e){
onclick(e){
vn.state.active = vn.state.active ? 0 : 1;
}
}, m.trust(markdown.renderInline(this.type))),
@@ -217,7 +217,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;
@@ -226,7 +226,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;
@@ -234,7 +234,7 @@ 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 m("section", {
'id' :this.id,
@@ -246,9 +246,7 @@ var _Enonce = {
// create text node
m(_Text, {'text':this.text, 'id':this.id}),
// addd children
this.childs.map(function(c){
return m(_Item, c)
})
this.childs.map(c => { return m(_Item, c); })
])
}
}
@@ -259,17 +257,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,
@@ -279,7 +277,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.type);
// var title = e.title || '';
switch (e.type) {
@@ -309,16 +307,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))));
}
}
@@ -330,7 +328,7 @@ var _Intro = {
// / / / __/> </ /_
// /_/ \___/_/|_|\__/
module.exports = {
// oninit : function(vn){
// oninit(vn){
// this.lang = vn.attrs.lang;
// },
oncreate(vn){
@@ -341,7 +339,7 @@ module.exports = {
console.log('_ModeText view', vn.attrs.lang);
return [
m(_Header),
m('main', {id:"content", 'class':'mode-text'}, _dbs.data[vn.attrs.lang].map(function(p){
m('main', {id:"content", 'class':'mode-text'}, _dbs.data[vn.attrs.lang].map((p) => {
console.log("MAP _dbs", p);
if(p.id == 'intro'){
return m(_Intro,p);