|
@@ -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);
|
|
|
})
|
|
|
),
|
|
@@ -3550,312 +3430,8 @@ 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) {
|
|
|
+/* 23 */
|
|
|
+/***/ (function(module, exports) {
|
|
|
|
|
|
module.exports = {
|
|
|
"Aacute": "Á",
|
|
@@ -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
|