changed parts name
This commit is contained in:
Vendored
+313
-433
@@ -1585,128 +1585,7 @@ else window.m = m
|
||||
/* 2 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
|
||||
// _
|
||||
// (_)________ ____
|
||||
// / / ___/ __ \/ __ \
|
||||
// / (__ ) /_/ / / / /
|
||||
// __/ /____/\____/_/ /_/
|
||||
// /___/
|
||||
|
||||
module.exports = {
|
||||
lang:'fr',
|
||||
langs:[
|
||||
{'lc':'fr', 'label':'fr', 'db':'2-Appuhn-FR-ethicadb.json'},
|
||||
{'lc':'bra', 'label':'bra', 'db':'ethica-bresilen.json'}
|
||||
],
|
||||
data:[],
|
||||
loaded_dbs:0,
|
||||
data_byid:[],
|
||||
data_strct:{},
|
||||
load: function(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){
|
||||
|
||||
var xobj = new XMLHttpRequest();
|
||||
xobj.overrideMimeType("application/json");
|
||||
// TODO: load and unzip gziped json
|
||||
// xobj.setRequestHeader('Accept-Encoding', 'gzip');
|
||||
xobj.onreadystatechange = function () {
|
||||
// console.log('onreadystatechange', xobj.readyState);
|
||||
switch(xobj.readyState){
|
||||
case 3:
|
||||
console.log('loading');
|
||||
break;
|
||||
case 4:
|
||||
if (xobj.status === 200) {
|
||||
this.onJSONLoaded(lc, xobj.responseText, callback);
|
||||
} else {
|
||||
console.log("Status de la réponse: %d (%s)", xobj.status, xobj.statusText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
xobj.open('GET', file, true);
|
||||
xobj.send(null);
|
||||
},
|
||||
onJSONLoaded: function(lc, json, callback){
|
||||
console.log('onDBLoaded');
|
||||
this.data[lc] = JSON.parse(json);
|
||||
this.loaded_dbs ++;
|
||||
//
|
||||
if (this.loaded_dbs == this.langs.length) {
|
||||
this.parseByID(callback);
|
||||
}
|
||||
|
||||
},
|
||||
parseByID: function(callback){
|
||||
for(l in this.data){
|
||||
// console.log('l', l);
|
||||
this.data_byid[l] = {};
|
||||
for (p in this.data[l]) {
|
||||
// console.log(this.data[l][p]);
|
||||
for (e in this.data[l][p].enonces) {
|
||||
// console.log('e',e);
|
||||
this.data_byid[l][this.data[l][p].enonces[e].id] = this.data[l][p].enonces[e];
|
||||
for (c in this.data[l][p].enonces[e].childs){
|
||||
// console.log(_db[p][e][c]);
|
||||
this.data_byid[l][this.data[l][p].enonces[e].childs[c].id] = this.data[l][p].enonces[e].childs[c];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log('this.data_byid', this.data_byid);
|
||||
this.parseStrct(callback);
|
||||
},
|
||||
parseStrct: function(callback){
|
||||
|
||||
var id, item, obj, links_match, link, tid;
|
||||
for (id in this.data_byid[this.langs[0].lc]) {
|
||||
item = this.data_byid[this.langs[0].lc][id];
|
||||
// console.log(item);
|
||||
obj = {
|
||||
'to':[],
|
||||
'from':[],
|
||||
};
|
||||
// get links
|
||||
links_match = item.text.match(/\[[^\]]+\]\([^\)]+\)/g);
|
||||
// console.log(links_match);
|
||||
// if links exist on text
|
||||
if(links_match){
|
||||
for(link of links_match){
|
||||
// console.log(link);
|
||||
// get the target id
|
||||
tid = link.match(/\((.+)\)/)[1];
|
||||
// avoid duplicates
|
||||
if (obj.to.indexOf(tid) == -1)
|
||||
obj.to.push(tid);
|
||||
|
||||
// add id to "from" links in target
|
||||
// if target exists
|
||||
if(typeof this.data_strct[tid] !== 'undefined'){
|
||||
// avoid duplicates
|
||||
if (this.data_strct[tid].from.indexOf(tid) == -1)
|
||||
this.data_strct[tid].from.push(id);
|
||||
}else{
|
||||
// if targets does not exists, the db has an issue, warn about that
|
||||
console.log('!! warning : '+tid+' target id does not exists');
|
||||
}
|
||||
}
|
||||
}
|
||||
// add the item links to the main links listings
|
||||
this.data_strct[id] = obj;
|
||||
}
|
||||
// console.log('data_strct',this.data_strct);
|
||||
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("Module parse failed: /mnt/Data/bach/Sites/ethica-spinoza.net/static.ethica-spinoza.net/assets/modules/dbs.js Unexpected token (15:4)\nYou may need an appropriate loader to handle this file type.\n| {'lc':'fr', 'label':'fr', 'db':'2-Appuhn-FR-ethicadb.json'},\n| {'lc':'bra', 'label':'bra', 'db':'ethica-bresilen.json'}\n| {'lc':'en', 'label':'en', 'db':'2-Appuhn-FR-ethicadb.json'},\n| ],\n| data:[],");
|
||||
|
||||
/***/ }),
|
||||
/* 3 */
|
||||
@@ -2357,8 +2236,8 @@ var _RouteMenu = {
|
||||
view: function(){
|
||||
// create ul dom
|
||||
return m('ul', {id:"routes"}, [
|
||||
m('li', m('a', {'href':'#!/inline'}, "inline")),
|
||||
m('li', m('a', {'href':'#!/tree'}, "tree")),
|
||||
m('li', m('a', {'href':'#!/dots'}, "dots")),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -3147,17 +3026,17 @@ var m = __webpack_require__(1);
|
||||
|
||||
// var _helpers = require('modules/helpers');
|
||||
var _dbs = __webpack_require__(2);
|
||||
var _Inline = __webpack_require__(86);
|
||||
var _Tree = __webpack_require__(22);
|
||||
var _Dots = __webpack_require__(21);
|
||||
|
||||
function init(){
|
||||
_dbs.load(function(){
|
||||
console.log("Init _dbs.data", _dbs.data);
|
||||
console.log("Init _dbs.data_byid", _dbs.data_byid);
|
||||
console.log("Init _dbs.data_strct", _dbs.data_strct);
|
||||
m.route(document.body, "/tree", {
|
||||
m.route(document.body, "/inline", {
|
||||
"/inline": _Inline,
|
||||
"/tree": _Tree,
|
||||
"/dots": _Dots,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -3202,7 +3081,8 @@ init()
|
||||
// removed by extract-text-webpack-plugin
|
||||
|
||||
/***/ }),
|
||||
/* 21 */
|
||||
/* 21 */,
|
||||
/* 22 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
@@ -3524,10 +3404,10 @@ var _Part = {
|
||||
// /_____/\____/\__/____/
|
||||
module.exports = {
|
||||
view: function(){
|
||||
// console.log('_Dots view', _dbs.lang);
|
||||
// console.log('_Tree view', _dbs.lang);
|
||||
return [
|
||||
m(_Header),
|
||||
m('main', {id:"content", 'class':'dots'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
m('main', {id:"content", 'class':'tree'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
return m(_Part,p);
|
||||
})
|
||||
),
|
||||
@@ -3549,310 +3429,6 @@ module.exports = {
|
||||
// }
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 22 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
var m = __webpack_require__(1);
|
||||
|
||||
// https://github.com/markdown-it/markdown-it
|
||||
var markdown = __webpack_require__(10)()
|
||||
.use(__webpack_require__(9));
|
||||
|
||||
var _dbs = __webpack_require__(2);
|
||||
var _Header = __webpack_require__(8);
|
||||
var _Footer = __webpack_require__(7);
|
||||
|
||||
// __ _ __
|
||||
// / / (_)___ / /__
|
||||
// / / / / __ \/ //_/
|
||||
// / /___/ / / / / ,<
|
||||
// /_____/_/_/ /_/_/|_|
|
||||
var _Link = {
|
||||
tid:"",
|
||||
opened:false,
|
||||
oninit: function(vn){
|
||||
// console.log("INIT LINK : vn", vn);
|
||||
// define target id
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
onbeforeupdate: function(vn){
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
view: function(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 !!');
|
||||
}
|
||||
if(this.opened && this.tid_known){
|
||||
// console.log('this.tid', vn.state);
|
||||
return m('div', {'class':'opened-link'},
|
||||
[
|
||||
m('span', {'class':"link text"}, vn.children),
|
||||
typeof _dbs.data_byid[_dbs.lang][this.tid].childs != "undefined"
|
||||
? m(_Enonce, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
: m(_Item, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
]
|
||||
);
|
||||
}else{
|
||||
// console.log(vn);
|
||||
return m('a', {
|
||||
'class':'link',
|
||||
'href':'#'+this.tid,
|
||||
'rel':this.tid,
|
||||
onclick:function(e){
|
||||
e.preventDefault();
|
||||
console.log('click', this);
|
||||
vn.state.opened = true;
|
||||
return false;
|
||||
}
|
||||
}, vn.children); // c'est quoi ce vn.children ?
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ______ __
|
||||
// /_ __/__ _ __/ /_
|
||||
// / / / _ \| |/_/ __/
|
||||
// / / / __/> </ /_
|
||||
// /_/ \___/_/|_|\__/
|
||||
|
||||
// recusive function to record information of all subnodes
|
||||
function parseTextDom(nodes){
|
||||
var list = [];
|
||||
// loop through childNodes
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var n = {};
|
||||
if(typeof nodes[i].localName != "undefined"){
|
||||
n.tag=nodes[i].localName;
|
||||
if (n.tag == 'p') {
|
||||
// replace p by div as we will insert other div in them
|
||||
n.tag = 'div';
|
||||
n.attrs = {'class':'paragraph'};
|
||||
}
|
||||
if (n.tag == 'a') {
|
||||
// record the href attribute for cross reference
|
||||
n.attrs = {'href':nodes[i].attributes.href.value};
|
||||
}
|
||||
if(nodes[i].childNodes.length){
|
||||
// again parse node's childs
|
||||
n.childs = parseTextDom(nodes[i].childNodes);
|
||||
}
|
||||
}else if (nodes[i].textContent.length > 1){
|
||||
// if node has no localName it is probably a #text node
|
||||
// we record it if it's not empty
|
||||
n.tag='#text';
|
||||
n.text=nodes[i].textContent;
|
||||
}
|
||||
// add the node to the list if it has a tag
|
||||
if(typeof n.tag != "undefined")
|
||||
list.push(n);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// recusive fucntion to generate mithril object from information recorded with parseTextDom()
|
||||
function populateTextDom(n,i){
|
||||
// console.log('populateTextDom : '+i,n);
|
||||
return n.tag == "#text"
|
||||
? m.trust(n.text)
|
||||
: m(
|
||||
n.tag != 'a' ? n.tag : _Link,
|
||||
typeof n.attrs != "undefined" ? n.attrs : {},
|
||||
typeof n.childs != "undefined"
|
||||
? n.childs.map(populateTextDom)
|
||||
: typeof n.text != "undefined"
|
||||
? m.trust(n.text)
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
var _Text = {
|
||||
id:null,
|
||||
text:"",
|
||||
texthtml:"",
|
||||
textdom:null,
|
||||
textchilds:[],
|
||||
parsetext: function(){
|
||||
// console.log('parsetext', this);
|
||||
// !! we need to convert markdown to html here because parseTextDom() is recursive through nodes tree
|
||||
// convert markdown to html
|
||||
this.texthtml = markdown.render(this.text)
|
||||
// TODO: fixe number link text disapear [3](1d3) ( in 104d )
|
||||
// TODO: fixe parenthèse disparait _(par les Défin. [test 3](1d3) et [test 5](1d5))_ ( in 104d )
|
||||
// parse html string to virtual dom
|
||||
this.textdom = new DOMParser().parseFromString(this.texthtml, "text/html");
|
||||
// get the text nodes (avoid html document extra)
|
||||
this.textchilds = parseTextDom(this.textdom.getElementsByTagName('body')[0].childNodes);
|
||||
},
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
},
|
||||
onbeforeupdate: function(vn,old){
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log('_Text :: view : '+vn.attrs.slug, vn);
|
||||
return m('div',
|
||||
{'class':'text'},
|
||||
// loop through childNodes list generated by parseTextDom() in init
|
||||
this.textchilds.map(populateTextDom)
|
||||
); // /m.div.text
|
||||
} // view:
|
||||
}
|
||||
|
||||
// ______
|
||||
// / _/ /____ ____ ___
|
||||
// / // __/ _ \/ __ `__ \
|
||||
// _/ // /_/ __/ / / / / /
|
||||
// /___/\__/\___/_/ /_/ /_/
|
||||
var _Item = {
|
||||
id:null,
|
||||
part:null,
|
||||
type:null,
|
||||
nested:false,
|
||||
oninit: function(vn){
|
||||
// console.log('vn.attrs', vn.attrs);
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
// vn.state.part = vn.state.slug.match(/^(\d)(.+)/)[1];
|
||||
this.text = vn.attrs.text;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
this.nested = vn.attrs.nested || false;
|
||||
this.type = vn.attrs.type;
|
||||
this.text = vn.attrs.text;
|
||||
},
|
||||
view: function(vn){
|
||||
return m("section", {
|
||||
'id':this.id,
|
||||
'class':'item'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h3", {
|
||||
// 'ref':vn.attrs.href,
|
||||
onclick: function(e){
|
||||
vn.state.active = vn.state.active ? 0 : 1;
|
||||
}
|
||||
}, this.type),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id})
|
||||
]
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
// ______
|
||||
// / ____/___ ____ ____ ________
|
||||
// / __/ / __ \/ __ \/ __ \/ ___/ _ \
|
||||
// / /___/ / / / /_/ / / / / /__/ __/
|
||||
// /_____/_/ /_/\____/_/ /_/\___/\___/
|
||||
var _Enonce = {
|
||||
partid:null,
|
||||
id:null,
|
||||
title:null,
|
||||
text:null,
|
||||
nested:false,
|
||||
childs:[],
|
||||
oninit:function(vn){
|
||||
// // console.log('Enonce on init', vn);
|
||||
this.partid = vn.attrs.partid;
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate:function(vn, old) {
|
||||
// console.log(vn.attrs.childs);
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
|
||||
},
|
||||
view: function(vn){
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'enonce'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h2", {}, this.title),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id}),
|
||||
// addd children
|
||||
this.childs.map(function(c){
|
||||
return m(_Item, c)
|
||||
})
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
// ____ __
|
||||
// / __ \____ ______/ /_
|
||||
// / /_/ / __ `/ ___/ __/
|
||||
// / ____/ /_/ / / / /_
|
||||
// /_/ \__,_/_/ \__/
|
||||
var _Part = {
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
// console.log('_Part, onbeforeupdate old',old);
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log(vn.attrs.enonces);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'part'
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h1", {'class':'part'}, m.trust(markdown.renderInline(this.title))),
|
||||
// create text node
|
||||
this.enonces.map(function(e){
|
||||
// console.log(e.text);
|
||||
return m(_Enonce, Object.assign({"partid":this.id},e))
|
||||
})
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ______
|
||||
// /_ __/_______ ___
|
||||
// / / / ___/ _ \/ _ \
|
||||
// / / / / / __/ __/
|
||||
// /_/ /_/ \___/\___/
|
||||
module.exports = {
|
||||
view: function(){
|
||||
console.log('_Tree view', _dbs.lang);
|
||||
return [
|
||||
m(_Header),
|
||||
m('main', {id:"content", 'class':'tree'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
// console.log("MAP _dbs", p);
|
||||
return m(_Part,p);
|
||||
})
|
||||
),
|
||||
m(_Footer)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 23 */
|
||||
/***/ (function(module, exports) {
|
||||
@@ -13569,6 +13145,310 @@ __webpack_require__(19);
|
||||
module.exports = __webpack_require__(20);
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 86 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
var m = __webpack_require__(1);
|
||||
|
||||
// https://github.com/markdown-it/markdown-it
|
||||
var markdown = __webpack_require__(10)()
|
||||
.use(__webpack_require__(9));
|
||||
|
||||
var _dbs = __webpack_require__(2);
|
||||
var _Header = __webpack_require__(8);
|
||||
var _Footer = __webpack_require__(7);
|
||||
|
||||
// __ _ __
|
||||
// / / (_)___ / /__
|
||||
// / / / / __ \/ //_/
|
||||
// / /___/ / / / / ,<
|
||||
// /_____/_/_/ /_/_/|_|
|
||||
var _Link = {
|
||||
tid:"",
|
||||
opened:false,
|
||||
oninit: function(vn){
|
||||
// console.log("INIT LINK : vn", vn);
|
||||
// define target id
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
onbeforeupdate: function(vn){
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
view: function(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 !!');
|
||||
}
|
||||
if(this.opened && this.tid_known){
|
||||
// console.log('this.tid', vn.state);
|
||||
return m('div', {'class':'opened-link'},
|
||||
[
|
||||
m('span', {'class':"link text"}, vn.children),
|
||||
typeof _dbs.data_byid[_dbs.lang][this.tid].childs != "undefined"
|
||||
? m(_Enonce, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
: m(_Item, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
]
|
||||
);
|
||||
}else{
|
||||
// console.log(vn);
|
||||
return m('a', {
|
||||
'class':'link',
|
||||
'href':'#'+this.tid,
|
||||
'rel':this.tid,
|
||||
onclick:function(e){
|
||||
e.preventDefault();
|
||||
console.log('click', this);
|
||||
vn.state.opened = true;
|
||||
return false;
|
||||
}
|
||||
}, vn.children); // c'est quoi ce vn.children ?
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ______ __
|
||||
// /_ __/__ _ __/ /_
|
||||
// / / / _ \| |/_/ __/
|
||||
// / / / __/> </ /_
|
||||
// /_/ \___/_/|_|\__/
|
||||
|
||||
// recusive function to record information of all subnodes
|
||||
function parseTextDom(nodes){
|
||||
var list = [];
|
||||
// loop through childNodes
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var n = {};
|
||||
if(typeof nodes[i].localName != "undefined"){
|
||||
n.tag=nodes[i].localName;
|
||||
if (n.tag == 'p') {
|
||||
// replace p by div as we will insert other div in them
|
||||
n.tag = 'div';
|
||||
n.attrs = {'class':'paragraph'};
|
||||
}
|
||||
if (n.tag == 'a') {
|
||||
// record the href attribute for cross reference
|
||||
n.attrs = {'href':nodes[i].attributes.href.value};
|
||||
}
|
||||
if(nodes[i].childNodes.length){
|
||||
// again parse node's childs
|
||||
n.childs = parseTextDom(nodes[i].childNodes);
|
||||
}
|
||||
}else if (nodes[i].textContent.length > 1){
|
||||
// if node has no localName it is probably a #text node
|
||||
// we record it if it's not empty
|
||||
n.tag='#text';
|
||||
n.text=nodes[i].textContent;
|
||||
}
|
||||
// add the node to the list if it has a tag
|
||||
if(typeof n.tag != "undefined")
|
||||
list.push(n);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// recusive fucntion to generate mithril object from information recorded with parseTextDom()
|
||||
function populateTextDom(n,i){
|
||||
// console.log('populateTextDom : '+i,n);
|
||||
return n.tag == "#text"
|
||||
? m.trust(n.text)
|
||||
: m(
|
||||
n.tag != 'a' ? n.tag : _Link,
|
||||
typeof n.attrs != "undefined" ? n.attrs : {},
|
||||
typeof n.childs != "undefined"
|
||||
? n.childs.map(populateTextDom)
|
||||
: typeof n.text != "undefined"
|
||||
? m.trust(n.text)
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
var _Text = {
|
||||
id:null,
|
||||
text:"",
|
||||
texthtml:"",
|
||||
textdom:null,
|
||||
textchilds:[],
|
||||
parsetext: function(){
|
||||
// console.log('parsetext', this);
|
||||
// !! we need to convert markdown to html here because parseTextDom() is recursive through nodes tree
|
||||
// convert markdown to html
|
||||
this.texthtml = markdown.render(this.text)
|
||||
// TODO: fixe number link text disapear [3](1d3) ( in 104d )
|
||||
// TODO: fixe parenthèse disparait _(par les Défin. [test 3](1d3) et [test 5](1d5))_ ( in 104d )
|
||||
// parse html string to virtual dom
|
||||
this.textdom = new DOMParser().parseFromString(this.texthtml, "text/html");
|
||||
// get the text nodes (avoid html document extra)
|
||||
this.textchilds = parseTextDom(this.textdom.getElementsByTagName('body')[0].childNodes);
|
||||
},
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
},
|
||||
onbeforeupdate: function(vn,old){
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log('_Text :: view : '+vn.attrs.slug, vn);
|
||||
return m('div',
|
||||
{'class':'text'},
|
||||
// loop through childNodes list generated by parseTextDom() in init
|
||||
this.textchilds.map(populateTextDom)
|
||||
); // /m.div.text
|
||||
} // view:
|
||||
}
|
||||
|
||||
// ______
|
||||
// / _/ /____ ____ ___
|
||||
// / // __/ _ \/ __ `__ \
|
||||
// _/ // /_/ __/ / / / / /
|
||||
// /___/\__/\___/_/ /_/ /_/
|
||||
var _Item = {
|
||||
id:null,
|
||||
part:null,
|
||||
type:null,
|
||||
nested:false,
|
||||
oninit: function(vn){
|
||||
// console.log('vn.attrs', vn.attrs);
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
// vn.state.part = vn.state.slug.match(/^(\d)(.+)/)[1];
|
||||
this.text = vn.attrs.text;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
this.nested = vn.attrs.nested || false;
|
||||
this.type = vn.attrs.type;
|
||||
this.text = vn.attrs.text;
|
||||
},
|
||||
view: function(vn){
|
||||
return m("section", {
|
||||
'id':this.id,
|
||||
'class':'item'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h3", {
|
||||
// 'ref':vn.attrs.href,
|
||||
onclick: function(e){
|
||||
vn.state.active = vn.state.active ? 0 : 1;
|
||||
}
|
||||
}, this.type),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id})
|
||||
]
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
// ______
|
||||
// / ____/___ ____ ____ ________
|
||||
// / __/ / __ \/ __ \/ __ \/ ___/ _ \
|
||||
// / /___/ / / / /_/ / / / / /__/ __/
|
||||
// /_____/_/ /_/\____/_/ /_/\___/\___/
|
||||
var _Enonce = {
|
||||
partid:null,
|
||||
id:null,
|
||||
title:null,
|
||||
text:null,
|
||||
nested:false,
|
||||
childs:[],
|
||||
oninit:function(vn){
|
||||
// // console.log('Enonce on init', vn);
|
||||
this.partid = vn.attrs.partid;
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate:function(vn, old) {
|
||||
// console.log(vn.attrs.childs);
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
|
||||
},
|
||||
view: function(vn){
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'enonce'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h2", {}, this.title),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id}),
|
||||
// addd children
|
||||
this.childs.map(function(c){
|
||||
return m(_Item, c)
|
||||
})
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
// ____ __
|
||||
// / __ \____ ______/ /_
|
||||
// / /_/ / __ `/ ___/ __/
|
||||
// / ____/ /_/ / / / /_
|
||||
// /_/ \__,_/_/ \__/
|
||||
var _Part = {
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
// console.log('_Part, onbeforeupdate old',old);
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log(vn.attrs.enonces);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'part'
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h1", {'class':'part'}, m.trust(markdown.renderInline(this.title))),
|
||||
// create text node
|
||||
this.enonces.map(function(e){
|
||||
// console.log(e.text);
|
||||
return m(_Enonce, Object.assign({"partid":this.id},e))
|
||||
})
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ______
|
||||
// /_ __/_______ ___
|
||||
// / / / ___/ _ \/ _ \
|
||||
// / / / / / __/ __/
|
||||
// /_/ /_/ \___/\___/
|
||||
module.exports = {
|
||||
view: function(){
|
||||
console.log('_Inline view', _dbs.lang);
|
||||
return [
|
||||
m(_Header),
|
||||
m('main', {id:"content", 'class':'inline'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
// console.log("MAP _dbs", p);
|
||||
return m(_Part,p);
|
||||
})
|
||||
),
|
||||
m(_Footer)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
//# sourceMappingURL=main.js.map
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+3
-3
@@ -19,17 +19,17 @@ var m = require('mithril');
|
||||
|
||||
// var _helpers = require('modules/helpers');
|
||||
var _dbs = require('./modules/dbs');
|
||||
var _Inline = require('./modules/inline');
|
||||
var _Tree = require('./modules/tree');
|
||||
var _Dots = require('./modules/dots');
|
||||
|
||||
function init(){
|
||||
_dbs.load(function(){
|
||||
console.log("Init _dbs.data", _dbs.data);
|
||||
console.log("Init _dbs.data_byid", _dbs.data_byid);
|
||||
console.log("Init _dbs.data_strct", _dbs.data_strct);
|
||||
m.route(document.body, "/tree", {
|
||||
m.route(document.body, "/inline", {
|
||||
"/inline": _Inline,
|
||||
"/tree": _Tree,
|
||||
"/dots": _Dots,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
+10
-11
@@ -94,11 +94,11 @@ h1.part{
|
||||
// margin: 1em 0;
|
||||
}
|
||||
|
||||
// ______
|
||||
// /_ __/_______ ___
|
||||
// / / / ___/ _ \/ _ \
|
||||
// / / / / / __/ __/
|
||||
// /_/ /_/ \___/\___/
|
||||
// ____ __ _
|
||||
// / _/___ / / (_)___ ___
|
||||
// / // __ \/ / / / __ \/ _ \
|
||||
// _/ // / / / /___/ / / / / __/
|
||||
// /___/_/ /_/_____/_/_/ /_/\___/
|
||||
section.enonce{
|
||||
width:450px;
|
||||
margin: 1em 0 1em $margin_left;
|
||||
@@ -150,12 +150,11 @@ section.enonce{
|
||||
}
|
||||
}
|
||||
|
||||
// ____ __
|
||||
// / __ \____ / /______
|
||||
// / / / / __ \/ __/ ___/
|
||||
// / /_/ / /_/ / /_(__ )
|
||||
// /_____/\____/\__/____/
|
||||
|
||||
// ______
|
||||
// /_ __/_______ ___
|
||||
// / / / ___/ _ \/ _ \
|
||||
// / / / / / __/ __/
|
||||
// /_/ /_/ \___/\___/
|
||||
h1.part{
|
||||
margin:1em 0 0 $margin_left+($bullet_w/2);
|
||||
}
|
||||
|
||||
@@ -1,342 +0,0 @@
|
||||
|
||||
var m = require('mithril');
|
||||
|
||||
// https://github.com/markdown-it/markdown-it
|
||||
var markdown = require('markdown-it')()
|
||||
.use(require('markdown-it-footnote'));
|
||||
|
||||
var _dbs = require('./dbs');
|
||||
var _Header = require('./header');
|
||||
var _Footer = require('./footer');
|
||||
|
||||
// var _lang = require('../main.js')._langs;
|
||||
|
||||
// ____ __
|
||||
// / __ \____ / /_
|
||||
// / / / / __ \/ __/
|
||||
// / /_/ / /_/ / /_
|
||||
// /_____/\____/\__/
|
||||
var _Dot = {
|
||||
id:null,
|
||||
type:'',
|
||||
text:'',
|
||||
summary:'',
|
||||
active:true,
|
||||
opened:false,
|
||||
links:null,
|
||||
parents:[],
|
||||
lang:_dbs.lang,
|
||||
setuptext:function(vn){
|
||||
// console.log('setuptext', vn);
|
||||
|
||||
// construct text
|
||||
this.text = markdown.render(vn.attrs.text);
|
||||
|
||||
// construct summary
|
||||
// TODO: summary needs more work (strip tags, markdown render)
|
||||
this.summary = vn.attrs.text.match('([^ ]*[ ]{0,1}){1,6}')[0];
|
||||
this.summary = this.summary.trim().replace(/_([^_]+)$/g, "_$1_");
|
||||
this.summary = this.summary.replace(/\[([^\]]+)$/g, "$1");
|
||||
this.summary = markdown.renderInline(this.summary) + " …";
|
||||
|
||||
},
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
|
||||
this.setuptext(vn);
|
||||
|
||||
if(typeof vn.attrs.active !== 'undefined')
|
||||
this.active = vn.attrs.active;
|
||||
|
||||
// links
|
||||
this.links = _dbs.data_strct[this.id];
|
||||
// console.log(this.links);
|
||||
|
||||
// parents memorize where do we come from to avoid duplicates and looping nav
|
||||
if(vn.attrs.parents){
|
||||
this.parents = this.parents.concat(vn.attrs.parents);
|
||||
// console.log('_Dot init '+this.id+' parents :',this.parents);
|
||||
}
|
||||
|
||||
},
|
||||
oncreate: function(vn){
|
||||
if(this.active){
|
||||
vn.dom.classList.remove('disabled');
|
||||
}else{
|
||||
vn.dom.classList.add('disabled');
|
||||
}
|
||||
},
|
||||
onbeforeupdate: function(vn){
|
||||
// console.log('onbeforeupdate');
|
||||
if(this.lang != _dbs.lang){
|
||||
this.lang = _dbs.lang;
|
||||
this.setuptext(vn);
|
||||
}
|
||||
},
|
||||
view: function(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){
|
||||
// console.log(id);
|
||||
if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
|
||||
return m(_Dot, {
|
||||
"id":id,
|
||||
'text':_dbs.data_byid[_dbs.lang][id].text,
|
||||
'type':'',
|
||||
// passe the memory of crossed dots plus the current one
|
||||
'parents':vn.state.parents.concat([vn.state.id]),
|
||||
// activate link only if not in parents (already went through it)
|
||||
'active':vn.state.parents.indexOf(id) == -1 ? true:false
|
||||
});
|
||||
}
|
||||
})
|
||||
)
|
||||
: null,
|
||||
// id
|
||||
m('span', {'class':'id'}, this.id), // this.type+' '+
|
||||
// bullet
|
||||
m('span', {'class':'bullet'}, m.trust('⚫')),
|
||||
// full text
|
||||
m('section', {
|
||||
'class':'text',
|
||||
onmouseover: function(e){
|
||||
e.preventDefault();
|
||||
if(e.target.nodeName == "A" ){
|
||||
// console.log("over e.target", e.target);
|
||||
// console.log('over vn', vn);
|
||||
var id = e.target.getAttribute("href");
|
||||
// add highlight class
|
||||
vn.dom.querySelector('nav.links>div[uid="'+id+'"]').classList.add('highlight');
|
||||
}else{
|
||||
// remove all hilight class
|
||||
for (link of vn.dom.querySelectorAll('nav.links>div.dot')) {
|
||||
link.classList.remove('highlight');
|
||||
}
|
||||
}
|
||||
},
|
||||
onclick:function(e){
|
||||
e.preventDefault();
|
||||
if(e.target.nodeName == "A" ){
|
||||
// console.log("over e.target", e.target);
|
||||
// console.log('over vn', vn);
|
||||
var id = e.target.getAttribute("href");
|
||||
// add highlight class
|
||||
vn.dom.querySelector('nav.links>div[uid="'+id+'"]>.summary').click();
|
||||
}
|
||||
}
|
||||
}, m.trust(this.text)),
|
||||
// links from
|
||||
this.links.from.length
|
||||
? m('nav', {'class':'links from'}, this.links.from.map(function(id){
|
||||
// retrun a dot
|
||||
return m(_Dot, {
|
||||
"id":id,
|
||||
'text':_dbs.data_byid[_dbs.lang][id].text,
|
||||
'type':'',
|
||||
// passe the memory of crossed dots plus the current one
|
||||
'parents':vn.state.parents.concat([vn.state.id]),
|
||||
// activate link only if not in parents (already went through it)
|
||||
'active':vn.state.parents.indexOf(id) == -1 ? true:false
|
||||
});
|
||||
})
|
||||
)
|
||||
: null
|
||||
];
|
||||
}else{
|
||||
// preview dot
|
||||
var dot_content = [
|
||||
m('span', {'class':'id'}, this.id), // this.type+' '+
|
||||
m('span', {'class':'bullet'}, m.trust('•')),
|
||||
m('p', {
|
||||
'class':'summary',
|
||||
onclick:function(e){
|
||||
// TODO: animate openening (text and links separatly)
|
||||
vn.state.opened = true;
|
||||
}
|
||||
}, m.trust(this.summary))
|
||||
];
|
||||
}
|
||||
|
||||
return m('div',{
|
||||
'uid':this.id,
|
||||
'class':'dot'
|
||||
},
|
||||
dot_content
|
||||
);
|
||||
},
|
||||
onupdate: function(vn){
|
||||
// console.log('_Dot : onupdate', vn);
|
||||
if(this.active){
|
||||
if (this.opened){
|
||||
vn.dom.classList.add('opened');
|
||||
if(this.links.to.length)
|
||||
vn.dom.classList.add('to-links');
|
||||
if(this.links.from.length)
|
||||
vn.dom.classList.add('from-links');
|
||||
}else{
|
||||
vn.dom.classList.remove('opened');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
down vote
|
||||
Here's full list of black dotlikes from unicode
|
||||
|
||||
● - ● - Black Circle
|
||||
⏺ - ⏺ - Black Circle for Record
|
||||
⚫ - ⚫ - Medium Black Circle
|
||||
⬤ - ⬤ - Black Large Circle
|
||||
⧭ - ⧭ - Black Circle with Down Arrow
|
||||
🞄 - 🞄 - Black Slightly Small Circle
|
||||
• - • - Bullet
|
||||
∙ - ∙ - Bullet Operator
|
||||
⋅ - ⋅ - Dot Operator
|
||||
🌑 - 🌑 - New Moon Symbol
|
||||
*/
|
||||
|
||||
|
||||
// _______ _ __ __
|
||||
// / ___/ / (_) /__/ /
|
||||
// / /__/ _ \/ / / _ /
|
||||
// \___/_//_/_/_/\_,_/
|
||||
var _Child = {
|
||||
id:null,
|
||||
part:null,
|
||||
type:null,
|
||||
// nested:false,
|
||||
text:'',
|
||||
oninit: function(vn){
|
||||
// console.log('vn.attrs', vn.attrs);
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
// vn.state.part = vn.state.slug.match(/^(\d)(.+)/)[1];
|
||||
this.text = vn.attrs.text;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
this.type = vn.attrs.type;
|
||||
this.text = vn.attrs.text;
|
||||
},
|
||||
view: function(vn){
|
||||
return m(_Dot, {"id":this.id, 'text':this.text, 'type':this.type});
|
||||
}
|
||||
};
|
||||
|
||||
// ______
|
||||
// / ____/___ ____ ____ ________
|
||||
// / __/ / __ \/ __ \/ __ \/ ___/ _ \
|
||||
// / /___/ / / / /_/ / / / / /__/ __/
|
||||
// /_____/_/ /_/\____/_/ /_/\___/\___/
|
||||
var _Enonce = {
|
||||
partid:null,
|
||||
id:null,
|
||||
title:null,
|
||||
text:null,
|
||||
// nested:false,
|
||||
childs:[],
|
||||
oninit:function(vn){
|
||||
// // console.log('Enonce on init', vn);
|
||||
this.partid = vn.attrs.partid;
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate:function(vn, old) {
|
||||
// console.log(vn.attrs.childs);
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
|
||||
},
|
||||
view: function(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);
|
||||
})
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ____ __
|
||||
// / __ \____ ______/ /_
|
||||
// / /_/ / __ `/ ___/ __/
|
||||
// / ____/ /_/ / / / /_
|
||||
// /_/ \__,_/_/ \__/
|
||||
var _Part = {
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
// console.log('_Part, onbeforeupdate old',old);
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log(vn.attrs.enonces);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'part'
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h1", {'class':'part'}, m.trust(markdown.renderInline(this.title))),
|
||||
// create text node
|
||||
this.enonces.map(function(e){
|
||||
// console.log(e.text);
|
||||
return m(_Enonce, Object.assign({"partid":this.id},e))
|
||||
})
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ____ __
|
||||
// / __ \____ / /______
|
||||
// / / / / __ \/ __/ ___/
|
||||
// / /_/ / /_/ / /_(__ )
|
||||
// /_____/\____/\__/____/
|
||||
module.exports = {
|
||||
view: function(){
|
||||
// console.log('_Dots view', _dbs.lang);
|
||||
return [
|
||||
m(_Header),
|
||||
m('main', {id:"content", 'class':'dots'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
return m(_Part,p);
|
||||
})
|
||||
),
|
||||
m(_Footer)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// function(){
|
||||
// switch(_dbs.lang){
|
||||
// case 'fr':
|
||||
// return "Hello dots !";
|
||||
// break;
|
||||
// case 'bra':
|
||||
// return '"Hola dots !"'
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
@@ -25,8 +25,8 @@ var _RouteMenu = {
|
||||
view: function(){
|
||||
// create ul dom
|
||||
return m('ul', {id:"routes"}, [
|
||||
m('li', m('a', {'href':'#!/inline'}, "inline")),
|
||||
m('li', m('a', {'href':'#!/tree'}, "tree")),
|
||||
m('li', m('a', {'href':'#!/dots'}, "dots")),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
|
||||
var m = require('mithril');
|
||||
|
||||
// https://github.com/markdown-it/markdown-it
|
||||
var markdown = require('markdown-it')()
|
||||
.use(require('markdown-it-footnote'));
|
||||
|
||||
var _dbs = require('./dbs');
|
||||
var _Header = require('./header');
|
||||
var _Footer = require('./footer');
|
||||
|
||||
// __ _ __
|
||||
// / / (_)___ / /__
|
||||
// / / / / __ \/ //_/
|
||||
// / /___/ / / / / ,<
|
||||
// /_____/_/_/ /_/_/|_|
|
||||
var _Link = {
|
||||
tid:"",
|
||||
opened:false,
|
||||
oninit: function(vn){
|
||||
// console.log("INIT LINK : vn", vn);
|
||||
// define target id
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
onbeforeupdate: function(vn){
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
view: function(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 !!');
|
||||
}
|
||||
if(this.opened && this.tid_known){
|
||||
// console.log('this.tid', vn.state);
|
||||
return m('div', {'class':'opened-link'},
|
||||
[
|
||||
m('span', {'class':"link text"}, vn.children),
|
||||
typeof _dbs.data_byid[_dbs.lang][this.tid].childs != "undefined"
|
||||
? m(_Enonce, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
: m(_Item, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
]
|
||||
);
|
||||
}else{
|
||||
// console.log(vn);
|
||||
return m('a', {
|
||||
'class':'link',
|
||||
'href':'#'+this.tid,
|
||||
'rel':this.tid,
|
||||
onclick:function(e){
|
||||
e.preventDefault();
|
||||
console.log('click', this);
|
||||
vn.state.opened = true;
|
||||
return false;
|
||||
}
|
||||
}, vn.children); // c'est quoi ce vn.children ?
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ______ __
|
||||
// /_ __/__ _ __/ /_
|
||||
// / / / _ \| |/_/ __/
|
||||
// / / / __/> </ /_
|
||||
// /_/ \___/_/|_|\__/
|
||||
|
||||
// recusive function to record information of all subnodes
|
||||
function parseTextDom(nodes){
|
||||
var list = [];
|
||||
// loop through childNodes
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var n = {};
|
||||
if(typeof nodes[i].localName != "undefined"){
|
||||
n.tag=nodes[i].localName;
|
||||
if (n.tag == 'p') {
|
||||
// replace p by div as we will insert other div in them
|
||||
n.tag = 'div';
|
||||
n.attrs = {'class':'paragraph'};
|
||||
}
|
||||
if (n.tag == 'a') {
|
||||
// record the href attribute for cross reference
|
||||
n.attrs = {'href':nodes[i].attributes.href.value};
|
||||
}
|
||||
if(nodes[i].childNodes.length){
|
||||
// again parse node's childs
|
||||
n.childs = parseTextDom(nodes[i].childNodes);
|
||||
}
|
||||
}else if (nodes[i].textContent.length > 1){
|
||||
// if node has no localName it is probably a #text node
|
||||
// we record it if it's not empty
|
||||
n.tag='#text';
|
||||
n.text=nodes[i].textContent;
|
||||
}
|
||||
// add the node to the list if it has a tag
|
||||
if(typeof n.tag != "undefined")
|
||||
list.push(n);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// recusive fucntion to generate mithril object from information recorded with parseTextDom()
|
||||
function populateTextDom(n,i){
|
||||
// console.log('populateTextDom : '+i,n);
|
||||
return n.tag == "#text"
|
||||
? m.trust(n.text)
|
||||
: m(
|
||||
n.tag != 'a' ? n.tag : _Link,
|
||||
typeof n.attrs != "undefined" ? n.attrs : {},
|
||||
typeof n.childs != "undefined"
|
||||
? n.childs.map(populateTextDom)
|
||||
: typeof n.text != "undefined"
|
||||
? m.trust(n.text)
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
var _Text = {
|
||||
id:null,
|
||||
text:"",
|
||||
texthtml:"",
|
||||
textdom:null,
|
||||
textchilds:[],
|
||||
parsetext: function(){
|
||||
// console.log('parsetext', this);
|
||||
// !! we need to convert markdown to html here because parseTextDom() is recursive through nodes tree
|
||||
// convert markdown to html
|
||||
this.texthtml = markdown.render(this.text)
|
||||
// TODO: fixe number link text disapear [3](1d3) ( in 104d )
|
||||
// TODO: fixe parenthèse disparait _(par les Défin. [test 3](1d3) et [test 5](1d5))_ ( in 104d )
|
||||
// parse html string to virtual dom
|
||||
this.textdom = new DOMParser().parseFromString(this.texthtml, "text/html");
|
||||
// get the text nodes (avoid html document extra)
|
||||
this.textchilds = parseTextDom(this.textdom.getElementsByTagName('body')[0].childNodes);
|
||||
},
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
},
|
||||
onbeforeupdate: function(vn,old){
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log('_Text :: view : '+vn.attrs.slug, vn);
|
||||
return m('div',
|
||||
{'class':'text'},
|
||||
// loop through childNodes list generated by parseTextDom() in init
|
||||
this.textchilds.map(populateTextDom)
|
||||
); // /m.div.text
|
||||
} // view:
|
||||
}
|
||||
|
||||
// ______
|
||||
// / _/ /____ ____ ___
|
||||
// / // __/ _ \/ __ `__ \
|
||||
// _/ // /_/ __/ / / / / /
|
||||
// /___/\__/\___/_/ /_/ /_/
|
||||
var _Item = {
|
||||
id:null,
|
||||
part:null,
|
||||
type:null,
|
||||
nested:false,
|
||||
oninit: function(vn){
|
||||
// console.log('vn.attrs', vn.attrs);
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
// vn.state.part = vn.state.slug.match(/^(\d)(.+)/)[1];
|
||||
this.text = vn.attrs.text;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
this.nested = vn.attrs.nested || false;
|
||||
this.type = vn.attrs.type;
|
||||
this.text = vn.attrs.text;
|
||||
},
|
||||
view: function(vn){
|
||||
return m("section", {
|
||||
'id':this.id,
|
||||
'class':'item'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h3", {
|
||||
// 'ref':vn.attrs.href,
|
||||
onclick: function(e){
|
||||
vn.state.active = vn.state.active ? 0 : 1;
|
||||
}
|
||||
}, this.type),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id})
|
||||
]
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
// ______
|
||||
// / ____/___ ____ ____ ________
|
||||
// / __/ / __ \/ __ \/ __ \/ ___/ _ \
|
||||
// / /___/ / / / /_/ / / / / /__/ __/
|
||||
// /_____/_/ /_/\____/_/ /_/\___/\___/
|
||||
var _Enonce = {
|
||||
partid:null,
|
||||
id:null,
|
||||
title:null,
|
||||
text:null,
|
||||
nested:false,
|
||||
childs:[],
|
||||
oninit:function(vn){
|
||||
// // console.log('Enonce on init', vn);
|
||||
this.partid = vn.attrs.partid;
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate:function(vn, old) {
|
||||
// console.log(vn.attrs.childs);
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
|
||||
},
|
||||
view: function(vn){
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'enonce'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h2", {}, this.title),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id}),
|
||||
// addd children
|
||||
this.childs.map(function(c){
|
||||
return m(_Item, c)
|
||||
})
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
// ____ __
|
||||
// / __ \____ ______/ /_
|
||||
// / /_/ / __ `/ ___/ __/
|
||||
// / ____/ /_/ / / / /_
|
||||
// /_/ \__,_/_/ \__/
|
||||
var _Part = {
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
// console.log('_Part, onbeforeupdate old',old);
|
||||
this.title = vn.attrs.title;
|
||||
this.enonces = vn.attrs.enonces;
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log(vn.attrs.enonces);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'part'
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h1", {'class':'part'}, m.trust(markdown.renderInline(this.title))),
|
||||
// create text node
|
||||
this.enonces.map(function(e){
|
||||
// console.log(e.text);
|
||||
return m(_Enonce, Object.assign({"partid":this.id},e))
|
||||
})
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// ______
|
||||
// /_ __/_______ ___
|
||||
// / / / ___/ _ \/ _ \
|
||||
// / / / / / __/ __/
|
||||
// /_/ /_/ \___/\___/
|
||||
module.exports = {
|
||||
view: function(){
|
||||
console.log('_Inline view', _dbs.lang);
|
||||
return [
|
||||
m(_Header),
|
||||
m('main', {id:"content", 'class':'inline'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
// console.log("MAP _dbs", p);
|
||||
return m(_Part,p);
|
||||
})
|
||||
),
|
||||
m(_Footer)
|
||||
]
|
||||
}
|
||||
}
|
||||
+223
-179
@@ -9,188 +9,225 @@ var _dbs = require('./dbs');
|
||||
var _Header = require('./header');
|
||||
var _Footer = require('./footer');
|
||||
|
||||
// __ _ __
|
||||
// / / (_)___ / /__
|
||||
// / / / / __ \/ //_/
|
||||
// / /___/ / / / / ,<
|
||||
// /_____/_/_/ /_/_/|_|
|
||||
var _Link = {
|
||||
tid:"",
|
||||
opened:false,
|
||||
oninit: function(vn){
|
||||
// console.log("INIT LINK : vn", vn);
|
||||
// define target id
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
onbeforeupdate: function(vn){
|
||||
this.tid = vn.attrs.href;
|
||||
},
|
||||
view: function(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 !!');
|
||||
}
|
||||
if(this.opened && this.tid_known){
|
||||
// console.log('this.tid', vn.state);
|
||||
return m('div', {'class':'opened-link'},
|
||||
[
|
||||
m('span', {'class':"link text"}, vn.children),
|
||||
typeof _dbs.data_byid[_dbs.lang][this.tid].childs != "undefined"
|
||||
? m(_Enonce, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
: m(_Item, _dbs.data_byid[_dbs.lang][this.tid])
|
||||
]
|
||||
);
|
||||
}else{
|
||||
// console.log(vn);
|
||||
return m('a', {
|
||||
'class':'link',
|
||||
'href':'#'+this.tid,
|
||||
'rel':this.tid,
|
||||
onclick:function(e){
|
||||
e.preventDefault();
|
||||
console.log('click', this);
|
||||
vn.state.opened = true;
|
||||
return false;
|
||||
}
|
||||
}, vn.children); // c'est quoi ce vn.children ?
|
||||
}
|
||||
// var _lang = require('../main.js')._langs;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ______ __
|
||||
// /_ __/__ _ __/ /_
|
||||
// / / / _ \| |/_/ __/
|
||||
// / / / __/> </ /_
|
||||
// /_/ \___/_/|_|\__/
|
||||
|
||||
// recusive function to record information of all subnodes
|
||||
function parseTextDom(nodes){
|
||||
var list = [];
|
||||
// loop through childNodes
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var n = {};
|
||||
if(typeof nodes[i].localName != "undefined"){
|
||||
n.tag=nodes[i].localName;
|
||||
if (n.tag == 'p') {
|
||||
// replace p by div as we will insert other div in them
|
||||
n.tag = 'div';
|
||||
n.attrs = {'class':'paragraph'};
|
||||
}
|
||||
if (n.tag == 'a') {
|
||||
// record the href attribute for cross reference
|
||||
n.attrs = {'href':nodes[i].attributes.href.value};
|
||||
}
|
||||
if(nodes[i].childNodes.length){
|
||||
// again parse node's childs
|
||||
n.childs = parseTextDom(nodes[i].childNodes);
|
||||
}
|
||||
}else if (nodes[i].textContent.length > 1){
|
||||
// if node has no localName it is probably a #text node
|
||||
// we record it if it's not empty
|
||||
n.tag='#text';
|
||||
n.text=nodes[i].textContent;
|
||||
}
|
||||
// add the node to the list if it has a tag
|
||||
if(typeof n.tag != "undefined")
|
||||
list.push(n);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// recusive fucntion to generate mithril object from information recorded with parseTextDom()
|
||||
function populateTextDom(n,i){
|
||||
// console.log('populateTextDom : '+i,n);
|
||||
return n.tag == "#text"
|
||||
? m.trust(n.text)
|
||||
: m(
|
||||
n.tag != 'a' ? n.tag : _Link,
|
||||
typeof n.attrs != "undefined" ? n.attrs : {},
|
||||
typeof n.childs != "undefined"
|
||||
? n.childs.map(populateTextDom)
|
||||
: typeof n.text != "undefined"
|
||||
? m.trust(n.text)
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
var _Text = {
|
||||
// ____ __
|
||||
// / __ \____ / /_
|
||||
// / / / / __ \/ __/
|
||||
// / /_/ / /_/ / /_
|
||||
// /_____/\____/\__/
|
||||
var _Dot = {
|
||||
id:null,
|
||||
text:"",
|
||||
texthtml:"",
|
||||
textdom:null,
|
||||
textchilds:[],
|
||||
parsetext: function(){
|
||||
// console.log('parsetext', this);
|
||||
// !! we need to convert markdown to html here because parseTextDom() is recursive through nodes tree
|
||||
// convert markdown to html
|
||||
this.texthtml = markdown.render(this.text)
|
||||
// TODO: fixe number link text disapear [3](1d3) ( in 104d )
|
||||
// TODO: fixe parenthèse disparait _(par les Défin. [test 3](1d3) et [test 5](1d5))_ ( in 104d )
|
||||
// parse html string to virtual dom
|
||||
this.textdom = new DOMParser().parseFromString(this.texthtml, "text/html");
|
||||
// get the text nodes (avoid html document extra)
|
||||
this.textchilds = parseTextDom(this.textdom.getElementsByTagName('body')[0].childNodes);
|
||||
type:'',
|
||||
text:'',
|
||||
summary:'',
|
||||
active:true,
|
||||
opened:false,
|
||||
links:null,
|
||||
parents:[],
|
||||
lang:_dbs.lang,
|
||||
setuptext:function(vn){
|
||||
// console.log('setuptext', vn);
|
||||
|
||||
// construct text
|
||||
this.text = markdown.render(vn.attrs.text);
|
||||
|
||||
// construct summary
|
||||
// TODO: summary needs more work (strip tags, markdown render)
|
||||
this.summary = vn.attrs.text.match('([^ ]*[ ]{0,1}){1,6}')[0];
|
||||
this.summary = this.summary.trim().replace(/_([^_]+)$/g, "_$1_");
|
||||
this.summary = this.summary.replace(/\[([^\]]+)$/g, "$1");
|
||||
this.summary = markdown.renderInline(this.summary) + " …";
|
||||
|
||||
},
|
||||
oninit: function(vn){
|
||||
this.id = vn.attrs.id;
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
this.type = vn.attrs.type;
|
||||
|
||||
this.setuptext(vn);
|
||||
|
||||
if(typeof vn.attrs.active !== 'undefined')
|
||||
this.active = vn.attrs.active;
|
||||
|
||||
// links
|
||||
this.links = _dbs.data_strct[this.id];
|
||||
// console.log(this.links);
|
||||
|
||||
// parents memorize where do we come from to avoid duplicates and looping nav
|
||||
if(vn.attrs.parents){
|
||||
this.parents = this.parents.concat(vn.attrs.parents);
|
||||
// console.log('_Dot init '+this.id+' parents :',this.parents);
|
||||
}
|
||||
|
||||
},
|
||||
onbeforeupdate: function(vn,old){
|
||||
this.text = vn.attrs.text;
|
||||
this.parsetext();
|
||||
oncreate: function(vn){
|
||||
if(this.active){
|
||||
vn.dom.classList.remove('disabled');
|
||||
}else{
|
||||
vn.dom.classList.add('disabled');
|
||||
}
|
||||
},
|
||||
onbeforeupdate: function(vn){
|
||||
// console.log('onbeforeupdate');
|
||||
if(this.lang != _dbs.lang){
|
||||
this.lang = _dbs.lang;
|
||||
this.setuptext(vn);
|
||||
}
|
||||
},
|
||||
view: function(vn){
|
||||
// console.log('_Text :: view : '+vn.attrs.slug, vn);
|
||||
return m('div',
|
||||
{'class':'text'},
|
||||
// loop through childNodes list generated by parseTextDom() in init
|
||||
this.textchilds.map(populateTextDom)
|
||||
); // /m.div.text
|
||||
} // view:
|
||||
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){
|
||||
// console.log(id);
|
||||
if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
|
||||
return m(_Dot, {
|
||||
"id":id,
|
||||
'text':_dbs.data_byid[_dbs.lang][id].text,
|
||||
'type':'',
|
||||
// passe the memory of crossed dots plus the current one
|
||||
'parents':vn.state.parents.concat([vn.state.id]),
|
||||
// activate link only if not in parents (already went through it)
|
||||
'active':vn.state.parents.indexOf(id) == -1 ? true:false
|
||||
});
|
||||
}
|
||||
})
|
||||
)
|
||||
: null,
|
||||
// id
|
||||
m('span', {'class':'id'}, this.id), // this.type+' '+
|
||||
// bullet
|
||||
m('span', {'class':'bullet'}, m.trust('⚫')),
|
||||
// full text
|
||||
m('section', {
|
||||
'class':'text',
|
||||
onmouseover: function(e){
|
||||
e.preventDefault();
|
||||
if(e.target.nodeName == "A" ){
|
||||
// console.log("over e.target", e.target);
|
||||
// console.log('over vn', vn);
|
||||
var id = e.target.getAttribute("href");
|
||||
// add highlight class
|
||||
vn.dom.querySelector('nav.links>div[uid="'+id+'"]').classList.add('highlight');
|
||||
}else{
|
||||
// remove all hilight class
|
||||
for (link of vn.dom.querySelectorAll('nav.links>div.dot')) {
|
||||
link.classList.remove('highlight');
|
||||
}
|
||||
}
|
||||
},
|
||||
onclick:function(e){
|
||||
e.preventDefault();
|
||||
if(e.target.nodeName == "A" ){
|
||||
// console.log("over e.target", e.target);
|
||||
// console.log('over vn', vn);
|
||||
var id = e.target.getAttribute("href");
|
||||
// add highlight class
|
||||
vn.dom.querySelector('nav.links>div[uid="'+id+'"]>.summary').click();
|
||||
}
|
||||
}
|
||||
}, m.trust(this.text)),
|
||||
// links from
|
||||
this.links.from.length
|
||||
? m('nav', {'class':'links from'}, this.links.from.map(function(id){
|
||||
// retrun a dot
|
||||
return m(_Dot, {
|
||||
"id":id,
|
||||
'text':_dbs.data_byid[_dbs.lang][id].text,
|
||||
'type':'',
|
||||
// passe the memory of crossed dots plus the current one
|
||||
'parents':vn.state.parents.concat([vn.state.id]),
|
||||
// activate link only if not in parents (already went through it)
|
||||
'active':vn.state.parents.indexOf(id) == -1 ? true:false
|
||||
});
|
||||
})
|
||||
)
|
||||
: null
|
||||
];
|
||||
}else{
|
||||
// preview dot
|
||||
var dot_content = [
|
||||
m('span', {'class':'id'}, this.id), // this.type+' '+
|
||||
m('span', {'class':'bullet'}, m.trust('•')),
|
||||
m('p', {
|
||||
'class':'summary',
|
||||
onclick:function(e){
|
||||
// TODO: animate openening (text and links separatly)
|
||||
vn.state.opened = true;
|
||||
}
|
||||
}, m.trust(this.summary))
|
||||
];
|
||||
}
|
||||
|
||||
return m('div',{
|
||||
'uid':this.id,
|
||||
'class':'dot'
|
||||
},
|
||||
dot_content
|
||||
);
|
||||
},
|
||||
onupdate: function(vn){
|
||||
// console.log('_Dot : onupdate', vn);
|
||||
if(this.active){
|
||||
if (this.opened){
|
||||
vn.dom.classList.add('opened');
|
||||
if(this.links.to.length)
|
||||
vn.dom.classList.add('to-links');
|
||||
if(this.links.from.length)
|
||||
vn.dom.classList.add('from-links');
|
||||
}else{
|
||||
vn.dom.classList.remove('opened');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ______
|
||||
// / _/ /____ ____ ___
|
||||
// / // __/ _ \/ __ `__ \
|
||||
// _/ // /_/ __/ / / / / /
|
||||
// /___/\__/\___/_/ /_/ /_/
|
||||
var _Item = {
|
||||
/*
|
||||
|
||||
down vote
|
||||
Here's full list of black dotlikes from unicode
|
||||
|
||||
● - ● - Black Circle
|
||||
⏺ - ⏺ - Black Circle for Record
|
||||
⚫ - ⚫ - Medium Black Circle
|
||||
⬤ - ⬤ - Black Large Circle
|
||||
⧭ - ⧭ - Black Circle with Down Arrow
|
||||
🞄 - 🞄 - Black Slightly Small Circle
|
||||
• - • - Bullet
|
||||
∙ - ∙ - Bullet Operator
|
||||
⋅ - ⋅ - Dot Operator
|
||||
🌑 - 🌑 - New Moon Symbol
|
||||
*/
|
||||
|
||||
|
||||
// _______ _ __ __
|
||||
// / ___/ / (_) /__/ /
|
||||
// / /__/ _ \/ / / _ /
|
||||
// \___/_//_/_/_/\_,_/
|
||||
var _Child = {
|
||||
id:null,
|
||||
part:null,
|
||||
type:null,
|
||||
nested:false,
|
||||
// nested:false,
|
||||
text:'',
|
||||
oninit: function(vn){
|
||||
// console.log('vn.attrs', vn.attrs);
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
// vn.state.part = vn.state.slug.match(/^(\d)(.+)/)[1];
|
||||
this.text = vn.attrs.text;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate: function(vn, old){
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
this.type = vn.attrs.type;
|
||||
this.text = vn.attrs.text;
|
||||
},
|
||||
view: function(vn){
|
||||
return m("section", {
|
||||
'id':this.id,
|
||||
'class':'item'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h3", {
|
||||
// 'ref':vn.attrs.href,
|
||||
onclick: function(e){
|
||||
vn.state.active = vn.state.active ? 0 : 1;
|
||||
}
|
||||
}, this.type),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id})
|
||||
]
|
||||
)
|
||||
return m(_Dot, {"id":this.id, 'text':this.text, 'type':this.type});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -204,7 +241,7 @@ var _Enonce = {
|
||||
id:null,
|
||||
title:null,
|
||||
text:null,
|
||||
nested:false,
|
||||
// nested:false,
|
||||
childs:[],
|
||||
oninit:function(vn){
|
||||
// // console.log('Enonce on init', vn);
|
||||
@@ -213,35 +250,30 @@ var _Enonce = {
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
},
|
||||
onbeforeupdate:function(vn, old) {
|
||||
// console.log(vn.attrs.childs);
|
||||
this.title = vn.attrs.title;
|
||||
this.text = vn.attrs.text;
|
||||
this.childs = vn.attrs.childs;
|
||||
this.nested = vn.attrs.nested || false;
|
||||
// this.nested = vn.attrs.nested || false;
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
|
||||
},
|
||||
view: function(vn){
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
||||
return m("section", {
|
||||
'id' :this.id,
|
||||
'class' :'enonce'+(this.nested ? ' nested':'')
|
||||
},
|
||||
[
|
||||
// create title node
|
||||
m("h2", {}, this.title),
|
||||
// create text node
|
||||
m(_Text, {'text':this.text, 'id':this.id}),
|
||||
return [
|
||||
// create dot
|
||||
m(_Dot, {"id":this.id, 'text':this.text,'type':this.title}),
|
||||
// addd children
|
||||
this.childs.map(function(c){
|
||||
return m(_Item, c)
|
||||
return m(_Child, c);
|
||||
})
|
||||
])
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ____ __
|
||||
// / __ \____ ______/ /_
|
||||
// / /_/ / __ `/ ___/ __/
|
||||
@@ -277,22 +309,34 @@ var _Part = {
|
||||
}
|
||||
}
|
||||
|
||||
// ______
|
||||
// /_ __/_______ ___
|
||||
// / / / ___/ _ \/ _ \
|
||||
// / / / / / __/ __/
|
||||
// /_/ /_/ \___/\___/
|
||||
|
||||
// ____ __
|
||||
// / __ \____ / /______
|
||||
// / / / / __ \/ __/ ___/
|
||||
// / /_/ / /_/ / /_(__ )
|
||||
// /_____/\____/\__/____/
|
||||
module.exports = {
|
||||
view: function(){
|
||||
console.log('_Tree view', _dbs.lang);
|
||||
// console.log('_Tree view', _dbs.lang);
|
||||
return [
|
||||
m(_Header),
|
||||
m('main', {id:"content", 'class':'tree'}, _dbs.data[_dbs.lang].map(function(p){
|
||||
// console.log("MAP _dbs", p);
|
||||
return m(_Part,p);
|
||||
})
|
||||
),
|
||||
m(_Footer)
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// function(){
|
||||
// switch(_dbs.lang){
|
||||
// case 'fr':
|
||||
// return "Hello dots !";
|
||||
// break;
|
||||
// case 'bra':
|
||||
// return '"Hola dots !"'
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user