Commit fd9b61e5 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

Added election information bar that appears for primary days. Currently only...

Added election information bar that appears for primary days. Currently only logs to console for general elections; leaving this as a bite-sized issue to be solved in the fall before the elections.
parent 770ce101
......@@ -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",
"<div class='alert alert-info mb-0 text-center' role='alert'><i class='fa fa-info-circle'></i> Today is Virginia's Primary Elections. Polls are open from 6:00am - 7:00pm. Photo ID is required. <a href='https://vote.elections.virginia.gov/VoterInformation/' class='alert-link'>Click here to verify your registration status, find your polling place, and review your ballot.</a></div>");
}
// 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment