From 2247143ed2b1d2386975a9595b717bca7fd0162b Mon Sep 17 00:00:00 2001 From: MrFry Date: Sat, 25 Jan 2020 21:29:59 +0100 Subject: [PATCH] Updated alldata page --- modules/qmining/qmining.js | 21 ++++++++++ modules/qmining/views/alldata.ejs | 67 ++++++++++++++++++++++--------- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/modules/qmining/qmining.js b/modules/qmining/qmining.js index 15a77d6..98028d3 100644 --- a/modules/qmining/qmining.js +++ b/modules/qmining/qmining.js @@ -99,8 +99,29 @@ app.get('/legacy', function (req, res) { }, 0) let scount = data.length + let grouped = data.Subjects.reduce((res, s) => { + let sName = s.getSubjNameWithoutYear() + if (sName) { + if (!res[sName]) { + res[sName] = [] + } + res[sName].push(s) + } else { + res.others.push(s) + } + return res + }, { + others: [] + }) + + const ordered = {} + Object.keys(grouped).sort().forEach((key) => { + ordered[key] = grouped[key] + }) + res.render('alldata', { data: data, + orderedData: ordered, scount: scount, qcount: qcount, siteurl: url diff --git a/modules/qmining/views/alldata.ejs b/modules/qmining/views/alldata.ejs index 4a9f454..9be3302 100755 --- a/modules/qmining/views/alldata.ejs +++ b/modules/qmining/views/alldata.ejs @@ -79,7 +79,7 @@ <% include aludni.ejs %> - <% for (var i = 0; i < data.Subjects.length; i++) { %> + <% Object.keys(orderedData).sort().forEach((key, i) => { %>
- <% var a = data.Subjects[i].toString().split('\n')%> - <% for (var j = 1; j < a.length; j++) { %> - <% if (a[j][0] == '?') { %> -
- <% } %> - <%=a[j] %> -
- <% } %> + + + <% orderedData[key].forEach((subj, i) => { %> + +
+ <% var a = subj.toString().split('\n')%> + <% for (var j = 1; j < a.length; j++) { %> + <% if (a[j][0] == '?') { %> +
+ <% } %> + <%=a[j] %> +
+ <% } %> +
+ <% }) %> + +
- <% } %> + <% }) %> + + +