|
@@ -32,6 +32,9 @@ module.exports = {
|
|
data:[],
|
|
data:[],
|
|
loaded_dbs:0,
|
|
loaded_dbs:0,
|
|
data_byid:[],
|
|
data_byid:[],
|
|
|
|
+ data_bytype:[], // not sure we'll use it ...
|
|
|
|
+ types:[],
|
|
|
|
+ active_type_filter:null,
|
|
data_strct:{},
|
|
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)?$/,
|
|
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:[
|
|
id_strct:[
|
|
@@ -141,12 +144,16 @@ module.exports = {
|
|
|
|
|
|
},
|
|
},
|
|
parseByID(callback){
|
|
parseByID(callback){
|
|
|
|
+ // TODO: make this function recursive to avoid code repetition
|
|
// create a id keyed array of contents
|
|
// create a id keyed array of contents
|
|
- var e_id, c_id, cc_id;
|
|
|
|
- // loop through laguages
|
|
|
|
|
|
+ var e_id, c_id, cc_id,
|
|
|
|
+ dottype;
|
|
|
|
+ // loop through languages
|
|
for(let l in this.data){
|
|
for(let l in this.data){
|
|
// console.log('l', l);
|
|
// console.log('l', l);
|
|
this.data_byid[l] = {};
|
|
this.data_byid[l] = {};
|
|
|
|
+ this.data_bytype[l] = {};
|
|
|
|
+ this.types[l] = [];
|
|
// loop through parts
|
|
// loop through parts
|
|
for (let p in this.data[l]) {
|
|
for (let p in this.data[l]) {
|
|
if(this.data[l][p].type !== "intro"){
|
|
if(this.data[l][p].type !== "intro"){
|
|
@@ -158,11 +165,18 @@ module.exports = {
|
|
e_id = this.data[l][p].enonces[e].id;
|
|
e_id = this.data[l][p].enonces[e].id;
|
|
// guess the type from the id
|
|
// guess the type from the id
|
|
// console.log(this.data[l][p].enonces[e].id);
|
|
// console.log(this.data[l][p].enonces[e].id);
|
|
- this.data[l][p].enonces[e].dottype = this.setupType(e_id);
|
|
|
|
|
|
+ dottype = this.setupType(e_id);
|
|
|
|
+ this.data[l][p].enonces[e].dottype = dottype;
|
|
// breadcrumb (full tree title)
|
|
// breadcrumb (full tree title)
|
|
this.data[l][p].enonces[e].breadcrumb = this.setupBreadcrumb(e_id);
|
|
this.data[l][p].enonces[e].breadcrumb = this.setupBreadcrumb(e_id);
|
|
// records childs in array keyed by ids
|
|
// records childs in array keyed by ids
|
|
this.data_byid[l][e_id] = this.data[l][p].enonces[e];
|
|
this.data_byid[l][e_id] = this.data[l][p].enonces[e];
|
|
|
|
+ // data by dottype
|
|
|
|
+ if (dottype) {
|
|
|
|
+ if(typeof this.data_bytype[l][dottype] == "undefined") this.data_bytype[l][dottype] = {};
|
|
|
|
+ if(this.types[l].indexOf(dottype) == -1) this.types[l].push(dottype);
|
|
|
|
+ this.data_bytype[l][dottype][e_id] = this.data[l][p].enonces[e];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// loop through childs
|
|
// loop through childs
|
|
for (let c in this.data[l][p].enonces[e].childs){
|
|
for (let c in this.data[l][p].enonces[e].childs){
|
|
@@ -170,11 +184,18 @@ module.exports = {
|
|
if(this.data[l][p].enonces[e].childs[c].id){
|
|
if(this.data[l][p].enonces[e].childs[c].id){
|
|
c_id = 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
|
|
// guess the type from the id
|
|
- this.data[l][p].enonces[e].childs[c].dottype = this.setupType(c_id);
|
|
|
|
|
|
+ dottype = this.setupType(c_id);
|
|
|
|
+ this.data[l][p].enonces[e].childs[c].dottype = dottype;
|
|
// breadcrumb (full tree title)
|
|
// breadcrumb (full tree title)
|
|
this.data[l][p].enonces[e].childs[c].breadcrumb = this.setupBreadcrumb(c_id);
|
|
this.data[l][p].enonces[e].childs[c].breadcrumb = this.setupBreadcrumb(c_id);
|
|
// records childs in array keyed by ids
|
|
// records childs in array keyed by ids
|
|
this.data_byid[l][c_id] = this.data[l][p].enonces[e].childs[c];
|
|
this.data_byid[l][c_id] = this.data[l][p].enonces[e].childs[c];
|
|
|
|
+ // data by dottype
|
|
|
|
+ if (dottype) {
|
|
|
|
+ if(typeof this.data_bytype[l][dottype] == "undefined") this.data_bytype[l][dottype] = {};
|
|
|
|
+ if(this.types[l].indexOf(dottype) == -1) this.types[l].push(dottype);
|
|
|
|
+ this.data_bytype[l][dottype][c_id] = this.data[l][p].enonces[e].childs[c];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// loop through childs of childs
|
|
// loop through childs of childs
|
|
for (let cc in this.data[l][p].enonces[e].childs[c].childs){
|
|
for (let cc in this.data[l][p].enonces[e].childs[c].childs){
|
|
@@ -183,13 +204,19 @@ module.exports = {
|
|
cc_id = 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);
|
|
// console.log('cc_id', cc_id);
|
|
// guess the type from the id
|
|
// guess the type from the id
|
|
- this.data[l][p].enonces[e].childs[c].childs[cc].dottype = this.setupType(cc_id);
|
|
|
|
|
|
+ dottype = this.setupType(cc_id);
|
|
|
|
+ this.data[l][p].enonces[e].childs[c].childs[cc].dottype = dottype;
|
|
// breadcrumb (full tree title)
|
|
// breadcrumb (full tree title)
|
|
this.data[l][p].enonces[e].childs[c].childs[cc].breadcrumb = this.setupBreadcrumb(cc_id);
|
|
this.data[l][p].enonces[e].childs[c].childs[cc].breadcrumb = this.setupBreadcrumb(cc_id);
|
|
// records childs in array keyed by ids
|
|
// records childs in array keyed by ids
|
|
this.data_byid[l][cc_id] = this.data[l][p].enonces[e].childs[c].childs[cc];
|
|
this.data_byid[l][cc_id] = this.data[l][p].enonces[e].childs[c].childs[cc];
|
|
|
|
+ // data by dottype
|
|
|
|
+ if (dottype) {
|
|
|
|
+ if(typeof this.data_bytype[l][dottype] == "undefined") this.data_bytype[l][dottype] = {};
|
|
|
|
+ if(this.types[l].indexOf(dottype) == -1) this.types[l].push(dottype);
|
|
|
|
+ this.data_bytype[l][dottype][cc_id] = this.data[l][p].enonces[e].childs[c].childs[cc];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|