Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #6

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/calendar_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def extract_organizer(organizer, description):

@staticmethod
def get_names(description):
names = re.findall(r"@(\w+)\s", description)
names = re.findall(r"(?<=^| )@(\w+)(?=$| )", description, re.MULTILINE)
return [name.capitalize() for name in names]

@staticmethod
Expand Down
41 changes: 27 additions & 14 deletions app/static/scripts/myscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,28 @@ function filterEvents() {
document.getElementById("myInput").onkeyup = filterEvents;

function startTime() {
var today, r, t, li, a, b, ul;
today = new Date();
t = today.getTime();
ul = document.getElementById("myUL");
li = ul.getElementsByClassName("event_li");

for (var i = 0; i < li.length; i++) {
a = parseInt(li[i].getElementsByClassName("begin_epoch")[0].innerText);
b = parseInt(li[i].getElementsByClassName("end_epoch")[0].innerText);

if (b > t && t > a) {
li[i].style.backgroundColor = "lightblue";
} else {
li[i].style.backgroundColor = t > b ? "lightgray" : "";
}
}

setTimeout(startTime, 10000); // Keep updating the time and colors
}

function scrollToEvent() {
var today,
r,
t,
li,
a,
Expand All @@ -60,25 +80,17 @@ function startTime() {
a = parseInt(li[i].getElementsByClassName("begin_epoch")[0].innerText);
b = parseInt(li[i].getElementsByClassName("end_epoch")[0].innerText);

if (b > t && t > a) {
li[i].style.backgroundColor = "lightblue";
if (!currentEventFound) {
li[i].scrollIntoView({ behavior: "smooth", block: "center" });
currentEventFound = true;
}
} else {
li[i].style.backgroundColor = t > b ? "lightgray" : "";
if (a > t && !nextEventElement) {
nextEventElement = li[i];
}
if (b > t && t > a && !currentEventFound) {
li[i].scrollIntoView({ behavior: "smooth", block: "center" });
currentEventFound = true;
} else if (a > t && !nextEventElement) {
nextEventElement = li[i];
}
}

if (!currentEventFound && nextEventElement) {
nextEventElement.scrollIntoView({ behavior: "smooth", block: "center" });
}

setTimeout(startTime, 10000);
}

var coll = document.getElementsByClassName("events-vert");
Expand All @@ -96,4 +108,5 @@ for (var i = 0; i < coll.length; i++) {

document.addEventListener("DOMContentLoaded", function () {
startTime();
scrollToEvent(); // Call only on page load
});