added filters by text type

This commit is contained in:
2018-09-18 12:21:57 +02:00
parent 30443960ab
commit 2eeceb6a60
10 changed files with 190 additions and 61 deletions
+33 -6
View File
@@ -32,6 +32,9 @@ module.exports = {
data:[],
loaded_dbs:0,
data_byid:[],
data_bytype:[], // not sure we'll use it ...
types:[],
active_type_filter:null,
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:[
@@ -141,12 +144,16 @@ module.exports = {
},
parseByID(callback){
// TODO: make this function recursive to avoid code repetition
// 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){
// console.log('l', l);
this.data_byid[l] = {};
this.data_bytype[l] = {};
this.types[l] = [];
// loop through parts
for (let p in this.data[l]) {
if(this.data[l][p].type !== "intro"){
@@ -158,11 +165,18 @@ module.exports = {
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(e_id);
dottype = this.setupType(e_id);
this.data[l][p].enonces[e].dottype = dottype;
// breadcrumb (full tree title)
this.data[l][p].enonces[e].breadcrumb = this.setupBreadcrumb(e_id);
// records childs in array keyed by ids
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
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){
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(c_id);
dottype = this.setupType(c_id);
this.data[l][p].enonces[e].childs[c].dottype = dottype;
// breadcrumb (full tree title)
this.data[l][p].enonces[e].childs[c].breadcrumb = this.setupBreadcrumb(c_id);
// records childs in array keyed by ids
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
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;
// 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);
dottype = this.setupType(cc_id);
this.data[l][p].enonces[e].childs[c].childs[cc].dottype = dottype;
// 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];
// 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];
}
}
}
}
}