|
@@ -27,75 +27,12 @@ var _Dot = {
|
|
links:null,
|
|
links:null,
|
|
parents:[],
|
|
parents:[],
|
|
lang:_dbs.lang,
|
|
lang:_dbs.lang,
|
|
- setupDotType(vn){
|
|
|
|
- // var rx_id = /^(\d)(app|agd|\d\d|pr|ad|ap|c|p|d|a)(cd|sc|\d\d|d|c|a|l|p|\d)?(e|\d|sc)?(d|c|a|sc)?$/;
|
|
|
|
- // var m = this.id.match(rx_id);
|
|
|
|
- // if(m){
|
|
|
|
- // switch(true){
|
|
|
|
- // case /^\d{2}$/.test(m[2]):
|
|
|
|
- // switch(true){
|
|
|
|
- // case /^cd$/.test(m[3]) : this.dottype = 'corollaire-demo'; break;
|
|
|
|
- // case /^sc$/.test(m[3]) : this.dottype = 'scolie'; break;
|
|
|
|
- // case /^d$/.test(m[3]) : this.dottype = 'demonstration'; break;
|
|
|
|
- // case /^c$/.test(m[3]) :
|
|
|
|
- // switch(true){
|
|
|
|
- // case /^sc$/.test(m[4]): this.dottype = 'scolie'; break;
|
|
|
|
- // case /^d$/.test(m[4]) : this.dottype = 'demonstration'; break;
|
|
|
|
- // case /^d$/.test(m[5]) : this.dottype = 'demonstration'; break;
|
|
|
|
- // case /^sc$/.test(m[5]): this.dottype = 'scolie'; break;
|
|
|
|
- // case /^\d$/.test(m[4]): this.dottype = 'corollaire'; break;
|
|
|
|
- // case !m[4] : this.dottype = 'corollaire'; break;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case /^a$/.test(m[3]) : this.dottype = 'axiom'; break;
|
|
|
|
- // case /^l$/.test(m[3]) :
|
|
|
|
- // switch(true){
|
|
|
|
- // case /^d$/.test(m[5]) : this.dottype = 'demonstration'; break;
|
|
|
|
- // case /^sc$/.test(m[5]): this.dottype = 'scolie'; break;
|
|
|
|
- // case !m[5] : this.dottype = 'lemme'; break;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case /^p$/.test(m[3]) : this.dottype = 'postulat'; break;
|
|
|
|
- // case /^\d$/.test(m[3]) : this.dottype = '??'; break;
|
|
|
|
- // case /^\d{2}$/.test(m[3]) : this.dottype = '??'; break;
|
|
|
|
- // case !m[3] : this.dottype = 'proposition'; break;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case /^app|ap$/.test(m[2]) : this.dottype = 'appendice'; break;
|
|
|
|
- // case /^agd$/.test(m[2]) : this.dottype = 'def-gen-affect'; break;
|
|
|
|
- // case /^pr$/.test(m[2]) : this.dottype = 'preface'; break;
|
|
|
|
- // case /^ad$/.test(m[2]) :
|
|
|
|
- // switch(true){
|
|
|
|
- // case /^e$/.test(m[4]) :this.dottype = 'explication'; break;
|
|
|
|
- // case !m[4] :this.dottype = 'def-affect'; break;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case /^c$/.test(m[2]) : this.dottype = 'chapitre'; break;
|
|
|
|
- // case /^p$/.test(m[2]) : this.dottype = 'postulat'; break;
|
|
|
|
- // case /^d$/.test(m[2]) :
|
|
|
|
- // switch(true){
|
|
|
|
- // case /^e$/.test(m[4]) : this.dottype = 'explication'; break;
|
|
|
|
- // case !m[4] : this.dottype = 'definition'; break;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case /^a$/.test(m[2]) : this.dottype = 'axiom'; break;
|
|
|
|
- // }
|
|
|
|
- // // }
|
|
|
|
- // }
|
|
|
|
- // console.log(`${this.id} -> ${this.dottype}`,m);
|
|
|
|
- //
|
|
|
|
- // // TODO: fix false ids
|
|
|
|
- // // we have app and ap for appendice (1app | 4ap)
|
|
|
|
- // // 213def ??
|
|
|
|
- // // 209cd demo ou corollaire-demo ??
|
|
|
|
- // // 210csc scolie ou corollaire-scolie ??
|
|
|
|
- // // 213l1d demo ??
|
|
|
|
- },
|
|
|
|
setupTitle(vn){
|
|
setupTitle(vn){
|
|
this.title = vn.attrs.title;
|
|
this.title = vn.attrs.title;
|
|
if(!this.title){
|
|
if(!this.title){
|
|
this.title = this.type;
|
|
this.title = this.type;
|
|
}
|
|
}
|
|
|
|
+ this.title = markdown.renderInline(this.title);
|
|
},
|
|
},
|
|
setuptext(vn){
|
|
setuptext(vn){
|
|
// console.log('setuptext', vn);
|
|
// console.log('setuptext', vn);
|
|
@@ -113,16 +50,15 @@ var _Dot = {
|
|
|
|
|
|
},
|
|
},
|
|
oninit(vn){
|
|
oninit(vn){
|
|
|
|
+ // console.log('Dot init : vn',vn);
|
|
this.id = vn.attrs.id;
|
|
this.id = vn.attrs.id;
|
|
this.type = vn.attrs.type;
|
|
this.type = vn.attrs.type;
|
|
- // this.title = vn.attrs.title || "title";
|
|
|
|
- // this.setupDotType(vn);
|
|
|
|
this.dottype = vn.attrs.dottype;
|
|
this.dottype = vn.attrs.dottype;
|
|
|
|
|
|
this.setupTitle(vn);
|
|
this.setupTitle(vn);
|
|
this.setuptext(vn);
|
|
this.setuptext(vn);
|
|
|
|
|
|
- console.log(`${this.id} -> ${this.dottype}`);
|
|
|
|
|
|
+ // console.log(`${this.id} -> ${this.dottype}`);
|
|
|
|
|
|
if(typeof vn.attrs.active !== 'undefined')
|
|
if(typeof vn.attrs.active !== 'undefined')
|
|
this.active = vn.attrs.active;
|
|
this.active = vn.attrs.active;
|
|
@@ -150,6 +86,7 @@ var _Dot = {
|
|
if(this.lang != _dbs.lang){
|
|
if(this.lang != _dbs.lang){
|
|
this.lang = _dbs.lang;
|
|
this.lang = _dbs.lang;
|
|
this.setuptext(vn);
|
|
this.setuptext(vn);
|
|
|
|
+ this.setupTitle(vn);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
view(vn){
|
|
view(vn){
|
|
@@ -158,15 +95,17 @@ var _Dot = {
|
|
// console.log('_Dot view '+this.id+' parents :',this.parents);
|
|
// console.log('_Dot view '+this.id+' parents :',this.parents);
|
|
var dot_content = [
|
|
var dot_content = [
|
|
// links to
|
|
// links to
|
|
- // TODO: add dottype class to nested dots
|
|
|
|
this.links.to.length
|
|
this.links.to.length
|
|
? m('nav', {'class':'links to'}, this.links.to.map(id => {
|
|
? m('nav', {'class':'links to'}, this.links.to.map(id => {
|
|
// console.log(id);
|
|
// console.log(id);
|
|
if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
|
|
if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
|
|
|
|
+ var obj = _dbs.data_byid[_dbs.lang][id];
|
|
|
|
+ // console.log('link to : obj', obj);
|
|
return m(_Dot, {
|
|
return m(_Dot, {
|
|
"id":id,
|
|
"id":id,
|
|
- 'text':_dbs.data_byid[_dbs.lang][id].text,
|
|
|
|
- 'type':'',
|
|
|
|
|
|
+ 'text':obj.text,
|
|
|
|
+ 'dottype':obj.dottype,
|
|
|
|
+ 'type':obj.type,
|
|
// passe the memory of crossed dots plus the current one
|
|
// passe the memory of crossed dots plus the current one
|
|
'parents':vn.state.parents.concat([vn.state.id]),
|
|
'parents':vn.state.parents.concat([vn.state.id]),
|
|
// activate link only if not in parents (already went through it)
|
|
// activate link only if not in parents (already went through it)
|
|
@@ -175,7 +114,7 @@ var _Dot = {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
)
|
|
)
|
|
- : null,
|
|
|
|
|
|
+ : null, // if no links to, add nothing
|
|
// id
|
|
// id
|
|
// m('span', {'class':'id'}, this.id), // this.type+' '+
|
|
// m('span', {'class':'id'}, this.id), // this.type+' '+
|
|
// bullet
|
|
// bullet
|
|
@@ -214,12 +153,14 @@ var _Dot = {
|
|
// links from
|
|
// links from
|
|
this.links.from.length
|
|
this.links.from.length
|
|
? m('nav', {'class':'links from'}, this.links.from.map(id => {
|
|
? m('nav', {'class':'links from'}, this.links.from.map(id => {
|
|
- // retrun a dot
|
|
|
|
- // TODO: add dottype class to nested dots
|
|
|
|
|
|
+ var obj = _dbs.data_byid[_dbs.lang][id];
|
|
|
|
+ // console.log('link from : obj', obj);
|
|
|
|
+ // return a dot
|
|
return m(_Dot, {
|
|
return m(_Dot, {
|
|
"id":id,
|
|
"id":id,
|
|
- 'text':_dbs.data_byid[_dbs.lang][id].text,
|
|
|
|
- 'type':'',
|
|
|
|
|
|
+ 'text':obj.text,
|
|
|
|
+ 'dottype':obj.dottype,
|
|
|
|
+ 'type':obj.type,
|
|
// passe the memory of crossed dots plus the current one
|
|
// passe the memory of crossed dots plus the current one
|
|
'parents':vn.state.parents.concat([vn.state.id]),
|
|
'parents':vn.state.parents.concat([vn.state.id]),
|
|
// activate link only if not in parents (already went through it)
|
|
// activate link only if not in parents (already went through it)
|
|
@@ -227,14 +168,20 @@ var _Dot = {
|
|
});
|
|
});
|
|
})
|
|
})
|
|
)
|
|
)
|
|
- : null
|
|
|
|
|
|
+ : null, // if no links from, add nothing
|
|
];
|
|
];
|
|
}else{
|
|
}else{
|
|
// preview dot
|
|
// preview dot
|
|
var dot_content = [
|
|
var dot_content = [
|
|
// m('span', {'class':'id'}, this.id), // this.type+' '+
|
|
// m('span', {'class':'id'}, this.id), // this.type+' '+
|
|
// m('span', {'class':'bullet'}, m.trust('•')),
|
|
// m('span', {'class':'bullet'}, m.trust('•')),
|
|
- m('span', {'class':'title'}, m.trust(this.title)),
|
|
|
|
|
|
+ m('span', {
|
|
|
|
+ 'class':'title',
|
|
|
|
+ onclick(e){
|
|
|
|
+ // TODO: animate openening (text and links separatly)
|
|
|
|
+ vn.state.opened = true;
|
|
|
|
+ }
|
|
|
|
+ }, m.trust(this.title)), // TODO: on nested dot add full description : Part 1, Prop 8, scolie
|
|
m('p', {
|
|
m('p', {
|
|
'class':'summary',
|
|
'class':'summary',
|
|
onclick(e){
|
|
onclick(e){
|
|
@@ -247,7 +194,11 @@ var _Dot = {
|
|
|
|
|
|
return m('div',{
|
|
return m('div',{
|
|
'uid':this.id,
|
|
'uid':this.id,
|
|
- 'class':`dot ${this.dottype}`
|
|
|
|
|
|
+ 'class':`dot ${this.dottype}`,
|
|
|
|
+ // onclick(e){
|
|
|
|
+ // // TODO: animate openening (text and links separatly)
|
|
|
|
+ // vn.state.opened = true;
|
|
|
|
+ // }
|
|
},
|
|
},
|
|
dot_content
|
|
dot_content
|
|
);
|
|
);
|
|
@@ -352,7 +303,7 @@ var _Enonce = {
|
|
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
|
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
|
return [
|
|
return [
|
|
// create dot
|
|
// create dot
|
|
- m(_Dot, {"id":this.id, 'text':this.text,'type':this.title, 'dottype':this.dottype}),
|
|
|
|
|
|
+ m(_Dot, {"id":this.id, 'text':this.text, 'type':this.title, 'dottype':this.dottype}),
|
|
// addd children
|
|
// addd children
|
|
this.childs.map(c => { return m(_Child, c); })
|
|
this.childs.map(c => { return m(_Child, c); })
|
|
]
|
|
]
|