Able to show and hide null-courses
This commit is contained in:
parent
8b8458a33e
commit
f7ff1bbb37
|
@ -13,13 +13,15 @@ table.table.table-bordered.table-striped.table-hover
|
||||||
td #{course[type]}
|
td #{course[type]}
|
||||||
td #{course.totalTdEquivalent}
|
td #{course.totalTdEquivalent}
|
||||||
tr#extend
|
tr#extend
|
||||||
td
|
td(colspan=2+types.length)
|
||||||
a(href="#") ...
|
a#extendText(href="#") ...
|
||||||
|
|
||||||
|
each course in noCourses
|
||||||
|
tr.no-courses
|
||||||
|
td #{course.name}
|
||||||
each type in types
|
each type in types
|
||||||
td
|
td #{course[type]}
|
||||||
a(href="#") ...
|
td #{course.totalTdEquivalent}
|
||||||
td
|
|
||||||
a(href="#") ...
|
|
||||||
|
|
||||||
tr.table-active
|
tr.table-active
|
||||||
td
|
td
|
||||||
|
|
|
@ -119,7 +119,17 @@ module.exports.totalTableByCourse = function(req, res, render, next) {
|
||||||
for (let type in cal.Type) {
|
for (let type in cal.Type) {
|
||||||
res.locals.types.push(type);
|
res.locals.types.push(type);
|
||||||
}
|
}
|
||||||
res.locals.courses = result.courses;
|
res.locals.courses = [];
|
||||||
|
res.locals.noCourses = [];
|
||||||
|
|
||||||
|
for (let course of result.courses) {
|
||||||
|
if (course.totalTdEquivalent > 0) {
|
||||||
|
res.locals.courses.push(course);
|
||||||
|
} else {
|
||||||
|
res.locals.noCourses.push(course);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res.locals.total = result.total;
|
res.locals.total = result.total;
|
||||||
render('totalTableByCourse.pug');
|
render('totalTableByCourse.pug');
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ var loadingDiv = document.getElementById('loading');
|
||||||
var errorDiv = document.getElementById('error');
|
var errorDiv = document.getElementById('error');
|
||||||
var resultDiv = document.getElementById('result');
|
var resultDiv = document.getElementById('result');
|
||||||
const timeout = 10000;
|
const timeout = 10000;
|
||||||
|
var emptyCoursesShown = false;
|
||||||
|
|
||||||
function getTable() {
|
function getTable() {
|
||||||
// Send XHR to totalTable
|
// Send XHR to totalTable
|
||||||
|
@ -27,32 +28,50 @@ function setData(text) {
|
||||||
loadingDiv.style.display = "none";
|
loadingDiv.style.display = "none";
|
||||||
errorDiv.style.display = "none";
|
errorDiv.style.display = "none";
|
||||||
resultDiv.innerHTML = text;
|
resultDiv.innerHTML = text;
|
||||||
|
emptyCoursesShown = false;
|
||||||
|
|
||||||
var emptyCourses = document.getElementsByClassName('no-courses');
|
var emptyCourses = document.getElementsByClassName('no-courses');
|
||||||
if (emptyCourses.length === 0) {
|
if (emptyCourses.length === 0) {
|
||||||
showEmptyCourses();
|
showEmptyCourses();
|
||||||
|
document.getElementById('extend').style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
hideEmptyCourses();
|
hideEmptyCourses();
|
||||||
document.getElementById('extend').addEventListener('click', function() {
|
document.getElementById('extend').addEventListener('click', function() {
|
||||||
showEmptyCourses();
|
switchEmptyCourses();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
updateExtendText();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEmptyCourses() {
|
function showEmptyCourses() {
|
||||||
|
emptyCoursesShown = true;
|
||||||
var emptyCourses = document.getElementsByClassName('no-courses');
|
var emptyCourses = document.getElementsByClassName('no-courses');
|
||||||
for (var i = 0; i < emptyCourses.length; i++) {
|
for (var i = 0; i < emptyCourses.length; i++) {
|
||||||
emptyCourses[i].style.display = "";
|
emptyCourses[i].style.display = "";
|
||||||
}
|
}
|
||||||
document.getElementById('extend').style.display = "none";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideEmptyCourses() {
|
function hideEmptyCourses() {
|
||||||
|
emptyCoursesShown = false;
|
||||||
var emptyCourses = document.getElementsByClassName('no-courses');
|
var emptyCourses = document.getElementsByClassName('no-courses');
|
||||||
for (var i = 0; i < emptyCourses.length; i++) {
|
for (var i = 0; i < emptyCourses.length; i++) {
|
||||||
emptyCourses[i].style.display = "none";
|
emptyCourses[i].style.display = "none";
|
||||||
}
|
}
|
||||||
document.getElementById('extend').style.display = "";
|
}
|
||||||
|
|
||||||
|
function switchEmptyCourses() {
|
||||||
|
if (emptyCoursesShown) {
|
||||||
|
hideEmptyCourses();
|
||||||
|
} else {
|
||||||
|
showEmptyCourses();
|
||||||
|
}
|
||||||
|
updateExtendText();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateExtendText() {
|
||||||
|
document.getElementById('extendText').innerHTML =
|
||||||
|
"Courses with null TD equivalent " + (emptyCoursesShown ? "(hide)" : "(show)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setError() {
|
function setError() {
|
||||||
|
|
Loading…
Reference in New Issue