diff --git a/src/web/src/pages/Pathway.vue b/src/web/src/pages/Pathway.vue index 22c99c4bb..103b735e5 100644 --- a/src/web/src/pages/Pathway.vue +++ b/src/web/src/pages/Pathway.vue @@ -1,9 +1,15 @@ @@ -172,6 +169,57 @@ export default { col2.push(this.categories[i]) } } + ret.push(col1); + ret.push(col2); + return ret; + }, + + // splited pathways to alphabet categories, then splited categories into 2 arrays, one array = one column + alphabetCols() { + let cols = []; + // put all pathways in one array + for (var i = 0; i < this.categories.length; i++) { + for (var j = 0; j < this.categories[i]['Pathways'].length; j++){ + cols.push(this.categories[i]['Pathways'][j]) + } + } + + let alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; + let ret = []; + let col1 = []; + let col2 = []; + var half_length = Math.ceil(cols.length / 2); + var count = 0; + // splited pathways to alphabet categories, then splited categories into 2 arrays + for (var n = 0; n < alphabet.length; n++) { + var tmp = { + "Category Name": alphabet[n], + "Pathways": [] + } + for (var m = 0; m < cols.length; m++) { + if (cols[m]['Name'][0].startsWith(alphabet[n])) { + var index = 0; + while (index < tmp['Pathways'].length) { + if (cols[m]['Name'][0] < tmp['Pathways'][index]['Name'][0]) { + break; + } + index++; + } + tmp['Pathways'].splice(index, 0, cols[m]); + } + } + // splited categories into 2 arrays + if (tmp['Pathways'].length > 0) { + if (count < half_length) { + col1.push(tmp); + count += tmp['Pathways'].length + 0.2; + } + else { + col2.push(tmp); + } + } + } + ret.push(col1); ret.push(col2); return ret;