Skip to content

Commit

Permalink
Mark new upcoming event (fixes #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
zieren committed Nov 30, 2022
1 parent 858d41d commit bd5c9eb
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ async function readEventsInternal(page, now) {
// single line for better readability.
const compactDateTime = (s) => s.replace(/( |20\d\d)/g, '').replace(/-/g, '‑');
const descriptionHTML =
'<tr><td>' + compactDateTime(td.innerText)
'<td>*</td><td>' + compactDateTime(td.innerText)
+ '</td><td>&nbsp;' + compactDateTime(td.nextSibling.innerText)
+ '</td><td>' + td.nextSibling.nextSibling.innerText + '</td></tr>';
+ '</td><td>' + td.nextSibling.nextSibling.innerText + '</td>';
return {
ts: ts,
descriptionHTML: descriptionHTML,
Expand Down Expand Up @@ -548,10 +548,17 @@ async function readEvents(page, previousHashes, emails) {
return;
}
let emailHTML = '<!DOCTYPE html><html><head><title>Bevorstehende Termine</title>'
+ '<style>table { border-collapse: collapse; } tr { border-bottom: 1pt solid; }</style>'
+ '<style>'
+ 'table { border-collapse: collapse; } '
+ 'tr { border-bottom: 1pt solid; } '
+ 'td:first-child { visibility: hidden; } '
+ 'tr.new { font-weight: bold; } '
+ 'tr.new td:first-child { visibility: visible; } '
+ '</style>'
+ '</head><body><h2>Termine in den n&auml;chsten ' + CONFIG.options.eventLookaheadDays
+ ' Tagen</h2><table>';
upcomingEvents.forEach(e => emailHTML += e.descriptionHTML);
upcomingEvents.forEach(e => emailHTML +=
'<tr class="' + (e.hash in previousHashes ? '' : 'new') + '">' + e.descriptionHTML + '</tr>');
emailHTML += '</table></body></html>';
const doStudent = !!CONFIG.options.emailToStudent;
let emailsLeft = doStudent ? 2 : 1;
Expand Down

0 comments on commit bd5c9eb

Please sign in to comment.