Browse Source

started to use ES6 coding standard

Bachir Soussi Chiadmi 6 years ago
parent
commit
eb28a86406

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


+ 1 - 1
assets/main.js

@@ -45,7 +45,7 @@ function init(){
 // /_/  |_/ .___/ .___/
 //       /_/   /_/
 // var _App = {
-//   view: function(){
+//   view(){
 //     console.log('_App view', _lang);
 //     return [
 //       m('header', [

+ 28 - 30
assets/modules/ModeConnections.js

@@ -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{

+ 25 - 27
assets/modules/ModeText.js

@@ -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);

+ 5 - 5
assets/modules/dbs.js

@@ -34,13 +34,13 @@ module.exports = {
   loaded_dbs:0,
   data_byid:[],
   data_strct:{},
-  load: function(callback) {
+  load(callback) {
     // load all dbs, when all loaded call main app callback function
     for (var i = 0; i < this.langs.length; i++) {
       this.loadJSON(this.langs[i].lc, '/assets/jsondb/'+this.langs[i].db, callback)
     }
   },
-  loadJSON: function(lc, file, callback){
+  loadJSON(lc, file, callback){
 
     var xobj = new XMLHttpRequest();
     xobj.overrideMimeType("application/json");
@@ -65,7 +65,7 @@ module.exports = {
     xobj.open('GET', file, true);
     xobj.send(null);
   },
-  onJSONLoaded: function(lc, json, callback){
+  onJSONLoaded(lc, json, callback){
     console.log('onDBLoaded '+lc);
     this.data[lc] = JSON.parse(json);
     this.loaded_dbs ++;
@@ -76,7 +76,7 @@ module.exports = {
     }
 
   },
-  parseByID: function(callback){
+  parseByID(callback){
     for(l in this.data){
       // console.log('l', l);
       this.data_byid[l] = {};
@@ -97,7 +97,7 @@ module.exports = {
     // console.log('this.data_byid', this.data_byid);
     this.parseStrct(callback);
   },
-  parseStrct: function(callback){
+  parseStrct(callback){
 
     var id, item, obj, links_match, link, tid;
     for (id in this.data_byid[this.langs[0].lc]) {

+ 1 - 1
assets/modules/footer.js

@@ -8,7 +8,7 @@ var m = require('mithril');
 //  / __/ /_/ / /_/ / /_/  __/ /
 // /_/  \____/\____/\__/\___/_/
 module.exports = {
-  view: function(vn){
+  view(vn){
     return m('footer', [
       m('p', m.trust('© 2017 <a href="./">Ethica Spinoza</a>'))
     ]);

+ 6 - 6
assets/modules/header.js

@@ -11,7 +11,7 @@ var markdown =  require('markdown-it')()
 //  / __  /  __/ /_/ / /_/ /  __/ /
 // /_/ /_/\___/\__,_/\__,_/\___/_/
 module.exports = {
-  view: function(vn){
+  view(vn){
     return m('header', [
       m('hgroup', [
         m('h1', 'Ethica'),
@@ -35,7 +35,7 @@ module.exports = {
 //  / ____/ /_/ / /  / /_(__  )  / / / / / /  __/ / / / /_/ /
 // /_/    \__,_/_/   \__/____/  /_/ /_/ /_/\___/_/ /_/\__,_/
 var _PartsNav = {
-  view: function(vn){
+  view(vn){
     var lang = m.route.param('lang');
     console.log('partsmenu', lang);
     return m('nav', {id:'parts-nav'}, [
@@ -60,7 +60,7 @@ var _PartsNav = {
 //  / _, _/ /_/ / /_/ / /_/  __/  / / / / / /  __/ / / / /_/ /
 // /_/ |_|\____/\__,_/\__/\___/  /_/ /_/ /_/\___/_/ /_/\__,_/
 var _RouteMenu = {
-  view: function(){
+  view(){
     var lang = m.route.param('lang');
     var path = m.route.get().match(/^(\/[^\/]+)(\/[^\/|#]+)(.*)$/);
     console.log('Route menu Path', path);
@@ -90,21 +90,21 @@ var _RouteMenu = {
 // /_____/\__,_/_/ /_/\__, /_/  /_/\___/_/ /_/\__,_/
 //                   /____/
 var _LangMenu = {
-  view: function(){
+  view(){
     var path = m.route.get().match(/^\/[^\/]+(.+)$/);
     // console.log('Lang menu Path', path);
     // create ul dom
     return m('nav', {id:'languages'}, [
       // TODO: replaced labels with localized content
       m('h3', 'languages'),
-      m('ul', _dbs.langs.map(function(lang){
+      m('ul', _dbs.langs.map(lang => {
         // create li dom for each lank link
         return m('li',
           // create a dom
           m('a', {
             'lang':lang.lc,
             'href':'/'+lang.lc+path[1]
-            // onclick:function(e){
+            // onclick(e){
             //   e.preventDefault();
             //   // console.log('click lang', e);
             //   var lang = e.target.getAttribute('lang');

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