Add support for Christmas Eve and New Years Eve on slideshow.html

Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
James Ketrenos 2020-01-01 17:38:14 -08:00
parent 404d934c55
commit d82ca4982a
2 changed files with 15 additions and 5 deletions

View File

@ -214,7 +214,7 @@ document.addEventListener("DOMContentLoaded", function() {
photoIndex = -1;
nextPhoto();
} else {
info.textContent = "No photos found for " + holiday + ".";
info.textContent = "No photos found for " + data.holiday + ".";
}
}).catch(function(error) {
console.error(error);

View File

@ -551,7 +551,7 @@ router.get("/holiday/:holiday", function(req, res/*, next*/) {
return res.status(404).send(req.params.holiday + " holiday not found.");
}
holidayName = Object.getOwnPropertyNames(lookup)[0];
console.log("Searching for holiday: " + holidayName);
/* Lookup the date for the holiday on every year from 'startYear' (1990) to today */
for (let year = startYear; year <= moment().year(); year++) {
console.log("Getting year: " + year);
@ -564,12 +564,22 @@ router.get("/holiday/:holiday", function(req, res/*, next*/) {
/*
* NOTE: Memorial Day and Labor Day are two special cases -- the holiday is a Monday,
* however the entire weekend typically is holidy-esque. Account for that below.
* We (should) could expand this to account for Fri or Mon on the 4th of July, Christmas,
* or New Years as well. */
*
* For those that have 'eve' celebrations, include those too.
*
* We (should) could expand this to account for Fri or Mon on the 4th of July or the
* entire weekend if it occurs on a Thu or Tues */
let extraDays = 0;
if (req.params.holiday.toLowerCase() == 'memorial day') {
switch (req.params.holiday.toLowerCase()) {
case 'labor day':
case 'memorial day':
extraDays = -2; /* Include two days prior */
break;
case 'christmas day':
case 'new year\'s day':
extraDays = -1; /* Include 'Eve' */
break;
}
let direction = extraDays < 0 ? -1 : 1;