|
@@ -120,36 +120,54 @@ module.exports = {
|
|
|
},
|
|
|
parseByID(callback){
|
|
|
// create a id keyed array of contents
|
|
|
+ var e_id, c_id, cc_id;
|
|
|
// loop through laguages
|
|
|
- for(l in this.data){
|
|
|
+ for(let l in this.data){
|
|
|
// console.log('l', l);
|
|
|
this.data_byid[l] = {};
|
|
|
// loop through parts
|
|
|
- for (p in this.data[l]) {
|
|
|
+ for (let p in this.data[l]) {
|
|
|
if(this.data[l][p].type !== "intro"){
|
|
|
// console.log(this.data[l][p]);
|
|
|
// loop through enonces
|
|
|
- for (e in this.data[l][p].enonces) {
|
|
|
+ for (let e in this.data[l][p].enonces) {
|
|
|
// console.log('e',e);
|
|
|
if(this.data[l][p].enonces[e].id){
|
|
|
+ e_id = this.data[l][p].enonces[e].id;
|
|
|
// 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);
|
|
|
+ this.data[l][p].enonces[e].dottype = this.setupType(e_id);
|
|
|
// breadcrumb (full tree title)
|
|
|
- this.data[l][p].enonces[e].breadcrumb = this.setupBreadcrumb(this.data[l][p].enonces[e].id);
|
|
|
+ this.data[l][p].enonces[e].breadcrumb = this.setupBreadcrumb(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];
|
|
|
+ this.data_byid[l][e_id] = this.data[l][p].enonces[e];
|
|
|
}
|
|
|
// loop through childs
|
|
|
- for (c in this.data[l][p].enonces[e].childs){
|
|
|
+ for (let c in this.data[l][p].enonces[e].childs){
|
|
|
// console.log(_db[p][e][c]);
|
|
|
if(this.data[l][p].enonces[e].childs[c].id){
|
|
|
+ c_id = 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);
|
|
|
+ this.data[l][p].enonces[e].childs[c].dottype = this.setupType(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);
|
|
|
+ this.data[l][p].enonces[e].childs[c].breadcrumb = this.setupBreadcrumb(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];
|
|
|
+ this.data_byid[l][c_id] = this.data[l][p].enonces[e].childs[c];
|
|
|
+ }
|
|
|
+ // loop through childs of childs
|
|
|
+ for (let cc in this.data[l][p].enonces[e].childs[c].childs){
|
|
|
+ // console.log(_db[p][e][c]);
|
|
|
+ if(this.data[l][p].enonces[e].childs[c].childs[cc].id){
|
|
|
+ cc_id = this.data[l][p].enonces[e].childs[c].childs[cc].id;
|
|
|
+ console.log('cc_id', cc_id);
|
|
|
+ // guess the type from the id
|
|
|
+ this.data[l][p].enonces[e].childs[c].childs[cc].dottype = this.setupType(cc_id);
|
|
|
+ // breadcrumb (full tree title)
|
|
|
+ this.data[l][p].enonces[e].childs[c].childs[cc].breadcrumb = this.setupBreadcrumb(cc_id);
|
|
|
+ // records childs in array keyed by ids
|
|
|
+ this.data_byid[l][cc_id] = this.data[l][p].enonces[e].childs[c].childs[cc];
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -161,7 +179,7 @@ module.exports = {
|
|
|
},
|
|
|
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 breadcrumb_array = [];
|
|
|
var m = id.match(this.rx_id);
|
|
|
var mode = 'full';
|
|
|
if(m){
|
|
@@ -175,28 +193,33 @@ module.exports = {
|
|
|
}
|
|
|
// console.log('m_clean', m_clean);
|
|
|
|
|
|
- for (let i = m_clean.length-1; i >= 0; i--) { // we loop through match result variables
|
|
|
+ for (let i = 0; i < m_clean.length; i++) { // we loop through match result variables
|
|
|
+ // for (let i = m_clean.length-1; i >= 0; i--) { // we loop through match result variables in reverse order
|
|
|
// console.log('m_clean['+i+']', m_clean[i]);
|
|
|
if(i == 0){ // first digit is part number
|
|
|
- breadcrumb += ` ${this.id_strct[i]['dim']} ${m_clean[i]}`
|
|
|
+ breadcrumb_array.unshift(`${this.id_strct[i]['dim']} ${m_clean[i]}`);
|
|
|
}else{
|
|
|
// display mode
|
|
|
mode = i !== m_clean.length-1 ? 'dim' : 'full';
|
|
|
if(isNaN(m_clean[i])){ // if not a number we get the label
|
|
|
- breadcrumb += ` ${this.id_strct[i][m_clean[i]][mode]}`
|
|
|
+ breadcrumb_array.unshift(`${this.id_strct[i][m_clean[i]][mode]}`);
|
|
|
+ // breadcrumb_array.splice(1, 0, `${m_clean[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'][mode]} ${m_clean[i]}`
|
|
|
- }else{ // we just add the number to the breadcrumb
|
|
|
- breadcrumb += ` ${m_clean[i]}`
|
|
|
+ breadcrumb_array.unshift(`${this.id_strct[i]['prop'][mode]} ${m_clean[i]}`);
|
|
|
+ }else{ // we just add the number to the breadcrumb behind the last added item
|
|
|
+ // breadcrumb_array.unshift(`${m_clean[i]}`);
|
|
|
+ // debugger;
|
|
|
+ breadcrumb_array.splice(1, 0, `${m_clean[i]}`);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // console.log('breadcrumb', breadcrumb);
|
|
|
- return breadcrumb;
|
|
|
+ // console.log('breadcrumb_array', breadcrumb_array);
|
|
|
+ return breadcrumb_array.join(' ');
|
|
|
},
|
|
|
setupType(id){
|
|
|
// console.log('setupType',id);
|