diff --git a/srctweb/assets/js/functions.js b/srctweb/assets/js/functions.js index 312cc02c7e003d99af0f54ab9aecaaad68f887e1..8e43a27958b62d895bd96baed30efba276e8114f 100644 --- a/srctweb/assets/js/functions.js +++ b/srctweb/assets/js/functions.js @@ -3,6 +3,9 @@ function checkDate() { month = '' + (d.getMonth() + 1), day = '' + d.getDate() year = '' + d.getYear(); + + // Mason Pride Week + // if it is March if (month == 3) { // find out what the third week of March is @@ -22,5 +25,42 @@ function checkDate() { document.body.className += " pride-bar"; } } + + // Virginia Primaries and General Elections + // Date reference: https://www.fairfaxcounty.gov/elections/ecalendar + + + // primaries are the second Tuesday of June + if (month == 6) { + juneFirst = new Date(year, month, 1); + weekday = juneFirst.getDay(); + // math for date calculation based on information read here + // http://www.i-programmer.info/programming/javascript/6322-date-hacks-doing-javascript-date-calculations.html + secondTuesday = 1 + (((2 - weekday) + 7) % 7) + 7; + + if (day == secondTuesday) { + var page = document.body; + page.insertAdjacentHTML("afterbegin", + ""); + } + + // generals are the first Tuesday after the first Monday of November + } else if (month == 11) { + novemberFirst = new Date(year, month, 1); + weekday = novemberFirst.getDay() + + // if the first day of the month is a Tuesday + if (weekday == 1) { + // the election will be on the 8th + general = 8; + } else { + general = 1 + (((2 - weekday) + 7) % 7); + } + + if (day == general) { + console.log("It's election day!"); + } + } } + window.onload = checkDate