mode connection is ok
This commit is contained in:
+77
-2
@@ -34,6 +34,45 @@ module.exports = {
|
||||
loaded_dbs:0,
|
||||
data_byid:[],
|
||||
data_strct:{},
|
||||
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)?$/,
|
||||
id_strct:[
|
||||
'Partie',
|
||||
{
|
||||
'prop':'Proposition', // \d\d
|
||||
'app' :'Appendice',
|
||||
'agd' :'Definition generale des affections',
|
||||
'pr' :'Preface',
|
||||
'ad' :'Definiton des affections',
|
||||
'ap' :'Appendice',
|
||||
'c' :'Corollaire',
|
||||
'p' :'Postulat',
|
||||
'd' :'Definition',
|
||||
'a' :'Axiome',
|
||||
},
|
||||
{
|
||||
// \d\d
|
||||
// \d
|
||||
'cd' :'Corollaire Demonstration',
|
||||
'sc' :'Scolie',
|
||||
'd' :'Demonstration',
|
||||
'c' :'Corollaire',
|
||||
'a' :'Axiome',
|
||||
'l' :'Lemme',
|
||||
'p' :'Postulat',
|
||||
},
|
||||
{
|
||||
// \d
|
||||
'e':'Explication',
|
||||
'sc':'Scolie',
|
||||
},
|
||||
{
|
||||
'd':'Demonstration',
|
||||
'c':'Corollaire',
|
||||
'a':'Axiome',
|
||||
'sc':'Scolie',
|
||||
}
|
||||
],
|
||||
|
||||
load(callback) {
|
||||
// load all dbs, when all loaded call main app callback function
|
||||
for (var i = 0; i < this.langs.length; i++) {
|
||||
@@ -94,6 +133,8 @@ module.exports = {
|
||||
// guess the type from the id
|
||||
// console.log(this.data[l][p].enonces[e].id);
|
||||
this.data[l][p].enonces[e].dottype = this.setupType(this.data[l][p].enonces[e].id);
|
||||
// breadcrumb (full tree title)
|
||||
this.data[l][p].enonces[e].breadcrumb = this.setupBreadcrumb(this.data[l][p].enonces[e].id);
|
||||
// records childs in array keyed by ids
|
||||
this.data_byid[l][this.data[l][p].enonces[e].id] = this.data[l][p].enonces[e];
|
||||
}
|
||||
@@ -103,6 +144,8 @@ module.exports = {
|
||||
if(this.data[l][p].enonces[e].childs[c].id){
|
||||
// guess the type from the id
|
||||
this.data[l][p].enonces[e].childs[c].dottype = this.setupType(this.data[l][p].enonces[e].childs[c].id);
|
||||
// breadcrumb (full tree title)
|
||||
this.data[l][p].enonces[e].childs[c].breadcrumb = this.setupBreadcrumb(this.data[l][p].enonces[e].childs[c].id);
|
||||
// records childs in array keyed by ids
|
||||
this.data_byid[l][this.data[l][p].enonces[e].childs[c].id] = this.data[l][p].enonces[e].childs[c];
|
||||
}
|
||||
@@ -114,10 +157,42 @@ module.exports = {
|
||||
// console.log('this.data_byid', this.data_byid);
|
||||
this.parseStrct(callback);
|
||||
},
|
||||
setupBreadcrumb(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 breadcrumb = ""
|
||||
var m = id.match(this.rx_id);
|
||||
if(m){
|
||||
m.shift();
|
||||
// console.log("id", m);
|
||||
for (let i = 0; i < m.length; i++) { // we loop through match result variables
|
||||
// console.log('m[i]', m[i]);
|
||||
if(i == 0){ // first digit is part number
|
||||
breadcrumb += `${this.id_strct[i]} ${m[i]}`
|
||||
}else{
|
||||
if(typeof m[i] !== 'undefined'){
|
||||
if(isNaN(m[i])){ // if not a number we get the label
|
||||
breadcrumb += ` ${this.id_strct[i][m[i]]}`
|
||||
}else{ // if its a number
|
||||
if(i == 1){ // we just add the number to the breadcrumb preceded by 'Proposition'
|
||||
breadcrumb += ` ${this.id_strct[i]['prop']} ${m[i]}`
|
||||
}else{ // we just add the number to the breadcrumb
|
||||
breadcrumb += ` ${m[i]}`
|
||||
}
|
||||
}
|
||||
}else{ // if variable is not defined we are at the end of the id
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('breadcrumb', breadcrumb);
|
||||
return breadcrumb;
|
||||
},
|
||||
setupType(id){
|
||||
// console.log('setupType',id);
|
||||
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 = id.match(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 = id.match(this.rx_id);
|
||||
if(m){
|
||||
switch(true){
|
||||
case /^\d{2}$/.test(m[2]): // proposition
|
||||
|
||||
Reference in New Issue
Block a user