Skip to content

Commit

Permalink
Merge pull request #3 from hft-app/ljans
Browse files Browse the repository at this point in the history
Add lecture time sanity check, show empty days
  • Loading branch information
ljans committed Aug 15, 2023
2 parents aa74751 + 03525ba commit cee7ad4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion scripts/module/lectures.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Lectures {
async process(request) {
const lectures = await this.handler.controller.idb.lectures.all(lecture => lecture.start >= this.handler.today);
this.days = [];
this.hasLectures = false;

// Set and get color seed
if(request.GET.has('repaint')) await this.handler.controller.idb.state.put(Math.floor(Math.random() * 101), 'seed');
Expand Down Expand Up @@ -41,7 +42,8 @@ class Lectures {
});

// Add day to timetable
if(today.length > 0) this.days.push({
if(today.length > 0) this.hasLectures = true;
this.days.push({
table: new Table(today).render(),
date: start,
});
Expand Down
2 changes: 1 addition & 1 deletion scripts/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Table {
// Only check lectures starting in the current time segment
var y = (lecture.start - morning) / (60 * 15 * 1000);
lecture.rowspan = (lecture.end - lecture.start) / (60 * 15 * 1000);
if(!Number.isInteger(y) || y < 0 || y > 48) return false; // OPTIONAL: check for malformed input
if(lecture.rowspan < 0 || !Number.isInteger(y) || y < 0 || y > 48) return false; // OPTIONAL: check for malformed input

// Col traversal (overlap buffer)
for(var x=0; x<12; x++) {
Expand Down
2 changes: 1 addition & 1 deletion styles/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ nav {
height: (44*$height) + 50px;
display: flex;
flex-direction: column;
min-width: 120px;

.head {
height: 54px;
Expand Down
8 changes: 4 additions & 4 deletions templates/_lectures.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{^days.length}}
{{^hasLectures}}
<div class="wrapper">
<div class="screen">
<div class="container">
Expand All @@ -12,8 +12,8 @@
</div>
</div>
</div>
{{/days.length}}
{{#days.length}}
{{/hasLectures}}
{{#hasLectures}}
<div class="wrapper">
<div class="timetable">
{{#days}}
Expand All @@ -33,4 +33,4 @@
{{/days}}
</div>
</div>
{{/days.length}}
{{/hasLectures}}

0 comments on commit cee7ad4

Please sign in to comment.