Recent Legislation
Recent Reports
Hearing Schedule
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|
");
popup.html(this.value);
popup.addClass("popup");
popup.attr("id", ID);
$(el).append(popup);
handleTransform(popup[0], el);
$(popup).on("click", (ev)=> {
handleClick(ev);
});
};
this.destroyPopup = () => {
let popup = getElement();
$(popup).off("click", handleClick);
popup.remove();
};
this.setValue = (e) => {
this.value = e;
updateValue();
};
return [this.value, this.setValue, this.createPopup, this.destroyPopup, this.popupExists];
}
document.addEventListener('DOMContentLoaded', function() {
const currentDate = new Date();
const currentDateString = dateToYearMonthDay(currentDate);
let selectedDate = currentDate;
let getSelectedYear = ()=> selectedDate.getFullYear();
let getSelectedMonthNum = ()=> selectedDate.getMonth();
let getSelectedMonthAndYear = ()=> {
const month = selectedDate.toLocaleString('default', {month: 'long'});
const year = getSelectedYear();
return `${month}, ${year}`;
};
let getDaysInMonth = ()=> new Date(getSelectedYear(), getSelectedMonthNum() + 1, 0).getDate();
//Gets first and last day of month as index of the week. (Sunday:0, Monday:1, etc.)
let getFirstDayOfMonth = ()=> new Date(getSelectedYear(), getSelectedMonthNum()).getDay();
let getLastDayOfMonth = ()=> new Date(getSelectedYear(), getSelectedMonthNum()+1, 0).getDay();
var [currentPopupValue, setPopupValue, createPopup, destroyPopup, popupExists] = usePopup("test");
let events = [];
let categories = [
{name:"closed", id:39, title:"Closed Hearing"},
{name:"open", id:38, title: "Open Hearing"}];
init();
function changeCursorToWait() {
$(".calendar").addClass("wait");
}
function changeCursorToDefault() {
$(".calendar").removeClass("wait");
}
async function getEvents() {
const startDate = new Date(getSelectedYear(), getSelectedMonthNum() - 1, 1).toISOString();
const endDate = new Date(getSelectedYear(), getSelectedMonthNum() + 1, 0, 23, 59, 59).toISOString();
changeCursorToWait();
events = [];
const customPostType = 'posts';
try {
const response = await fetch(`/wp-json/wp/v2/${customPostType}?after=${startDate}&before=${endDate}`);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
for (let event of json) {
events.push({date: event.acf.date_time, name: event.title.rendered, categories: event.categories, link: event.link});
}
changeCursorToDefault();
} catch(ex) {
console.error("Error " + ex.message);
}
}
function dateToYearMonthDay(date) {
const dateObj = typeof(date)==Date ? date : new Date(date);
const month = dateObj.getUTCMonth() + 1; // months from 1-12
const day = dateObj.getUTCDate();
const year = dateObj.getUTCFullYear();
const newDate = month + "/" + day + "/" + year;
return newDate;
}
function getEvent(date) {
const results = events.filter((event)=>dateToYearMonthDay(date)==dateToYearMonthDay(event.date));
return results;
}
function populateDataCells() {
let body = $("#calendarBody");
body.empty();
let tableRow = $(" ");
let cellIndex = 0;
let selected = null;
for (let i = 0; i < getFirstDayOfMonth(); i++) {
cellIndex++;
tableRow.append($(` `));
}
for (let i = 1; i <= getDaysInMonth(); i++) {
let date = dateToYearMonthDay(new Date(getSelectedYear(), getSelectedMonthNum(), i));
let tableCellId = date.replaceAll("/","");
let eventsToday = getEvent(date);
cellIndex++;
let dayOfWeek = cellIndex % 7;
let classes = "";
if (date === currentDateString){
classes += "current-day ";
}
if (eventsToday.length > 0) classes += "has-events ";
let cell = $(
`0?0:-1}>
${i}
${
eventsToday.length > 0 ?
` `);
tableRow.append(cell);
if (eventsToday.length > 0) {
$(document.body).on("click", ()=> {
if (popupExists() && selected != null) {
deselectTableCell();
}
});
$(document).on("keydown", (ev)=> {
if (ev.key === "Tab") {
if (popupExists() && selected != null) {
deselectTableCell();
}
}
});
$(cell).on("click", (ev)=> {
if (!popupExists()) {
selectTableCell();
} else if (popupExists() && selected !== tableCellId) {
deselectTableCell();
selectTableCell();
}
ev.stopPropagation();
});
$(cell).on("keypress", function(ev) {
if (ev.key === "Enter") {
if (!popupExists()) {
selectTableCell();
} else if (popupExists() && selected !== tableCellId) {
deselectTableCell();
selectTableCell();
}
}
});
function deselectTableCell() {
$(`#${selected}`).removeClass("selected");
destroyPopup();
selected = null;
}
function selectTableCell() {
selected = tableCellId;
$(`#${selected}`).addClass("selected");
createPopup(cell);
// Set Popup content
setPopupValue(`${eventsToday.map((event) => {
let category = categories.filter((e)=>event.categories.includes(e.id))[0].title;
return `${event.name}
Time ${formatDate(new Date(event.date))}
Category ${category} `}).join("")}`); } } if ((dayOfWeek == 0 && i != 0) || i == getDaysInMonth()) { body.append(tableRow); tableRow = $(" ");
}
}
let lastChild = body.children().last();
for (let i = 0; i < 7-(getLastDayOfMonth()+1); i++) {
cellIndex++;
lastChild.append($(` `));
}
}
function formatDate(date) {
let month = date.getMonth() + 1; // Months are zero-based
let day = date.getDate();
let year = date.getFullYear();
let hours = date.getHours();
let minutes = date.getMinutes();
let ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
let strTime = hours + ':' + minutes + ampm;
return month + '/' + day + '/' + year + ' - ' + strTime;
}
function setMonthElement() {
let e = $("#monthText");
e.text(getSelectedMonthAndYear());
}
async function reset() {
selectedDate = currentDate;
await getEvents();
reloadCalendar();
}
function reloadCalendar() {
populateDataCells();
setMonthElement();
}
function setRelativeMonth(increment) {
selectedDate = new Date(getSelectedYear(), getSelectedMonthNum() + increment);
}
async function onLastMonthButtonClicked() {
setRelativeMonth(-1);
await getEvents();
reloadCalendar();
}
async function onNextMonthButtonClicked() {
setRelativeMonth(1);
await getEvents();
reloadCalendar();
}
function onResetButtonClicked() {
reset();
}
async function init() {
setMonthElement();
await getEvents();
populateDataCells();
$("#lastMonthButton").on("click", () => {
onLastMonthButtonClicked();
})
$("#nextMonthButton").on("click", () => {
onNextMonthButtonClicked();
})
$("#resetButton").on("click", () => {
onResetButtonClicked();
})
}
});
${eventsToday.map((event)=> {
let category = categories.filter((e)=>event.categories.includes(e.id))[0].name;
return (`
`);
}).join("")}
` : ""
}
Category ${category} `}).join("")}`); } } if ((dayOfWeek == 0 && i != 0) || i == getDaysInMonth()) { body.append(tableRow); tableRow = $("
Open Hearing
Closed Meeting
Closed Meeting
Committee Leadership & Members

Tom Cotton
Chairman

Mark Warner
Vice Chairman