diff --git a/__pycache__/classroom.cpython-312.pyc b/__pycache__/classroom.cpython-312.pyc index 4d874b33..2ebb1789 100644 Binary files a/__pycache__/classroom.cpython-312.pyc and b/__pycache__/classroom.cpython-312.pyc differ diff --git a/__pycache__/database.cpython-312.pyc b/__pycache__/database.cpython-312.pyc index 40fe1b5b..403b9af4 100644 Binary files a/__pycache__/database.cpython-312.pyc and b/__pycache__/database.cpython-312.pyc differ diff --git a/__pycache__/goals.cpython-312.pyc b/__pycache__/goals.cpython-312.pyc index 9365e9c6..70115dc9 100644 Binary files a/__pycache__/goals.cpython-312.pyc and b/__pycache__/goals.cpython-312.pyc differ diff --git a/__pycache__/grades.cpython-312.pyc b/__pycache__/grades.cpython-312.pyc index fa2c2a0c..773f17e7 100644 Binary files a/__pycache__/grades.cpython-312.pyc and b/__pycache__/grades.cpython-312.pyc differ diff --git a/__pycache__/jupiter.cpython-312.pyc b/__pycache__/jupiter.cpython-312.pyc index b5209b74..6a843c59 100644 Binary files a/__pycache__/jupiter.cpython-312.pyc and b/__pycache__/jupiter.cpython-312.pyc differ diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc index c96934e1..fad6777a 100644 Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ diff --git a/main.py b/main.py index cf1928a9..3c1c7a45 100644 --- a/main.py +++ b/main.py @@ -297,6 +297,16 @@ def fetch_data(): if sheet_name=="Friends": #send if the user's osis is in the OSIS or targetOSIS of the row response[sheet_name] = [item for item in data if str(session['user_data']['osis']) in item['OSIS'] or str(session['user_data']['osis']) in item['targetOSIS']] + elif sheet_name =="FClasses": + #sebd all classes that users firends are in + firend_osises = [item['targetOSIS'] for item in data if + str(session['user_data']['osis']) in item['OSIS']] + [item['OSIS'] for + item in data if str (session['user_data']['osis']) in item['targetOSIS']] + r = [] + classes = get_data("Classes") + for friend in friend_osises: + r += [item for item in classes if friend in item['OSIS']] + response[sheet_name] = r elif sheet_name=="Assignments": # send if item['class'] is the id for any of the rows in response['Classes'] class_ids = [item['id'] for item in response['Classes']] diff --git a/static/Home.js b/static/Home.js index 731aa118..b35ca7bb 100644 --- a/static/Home.js +++ b/static/Home.js @@ -4,21 +4,105 @@ document.getElementById('scrolltodash').addEventListener('click', function() { behavior: 'smooth' }); }); +//bell schedule, values in total minutes of day example: 2AM would be 120 minutes +var bellSchedule = [0, 485, 531, 577, 625, 671, 717, 763, 809, 855, 902] +var thursBellSchedule = [0, 486, 530, 574, 618, 633, 677, 721, 765, 809, 853, 897] +function setPeriod(userClasses, friendsData, friendsClasses, currentPeriod) { + + const userClass = userClasses.find(classItem => classItem.period === currentPeriod); + if (userClass) { + document.getElementById("current-class").textContent = `Current Class: ${userClass.name}`; + } + friendsData.forEach(friend => { + const friendClass = friendsClasses.find(classItem => classItem.period === currentPeriod && classItem.osisList.includes(friend.osis)); + if (friendClass) { + const friendClassElement = document.createElement('h5'); + friendClassElement.textContent = `${friend.name}: ${friendClass.name}`; + + + document.getElementById("friends-classes").appendChild(friendClassElement); + } + }); +} + +function getPeriod(){ + // get the time in minutes since midnight + var today = new Date(); + var time = today.getMinutes() + (today.getHours() * 60) + console.log(time) + var isThursday = (today.getDay() === 4); + if (isThursday == true){ + for(let i = 0; i < thursBellSchedule.length; i++){ + if (time < thursBellSchedule[i + 1]){ + return i + } + else if (i < 500){ + return 0 + } + } + } else { + for(let i = 0; i < bellSchedule.length; i++){ + if (time < bellSchedule[i + 1]){ + return i + + } + else if (i < 460){ + return 0 + } + } + } +} +function datechecker(){ + var today = new Date(); + if(today.getMinutes() > 500 || today.getDay() == 0 || today.getDay() == 6){ + return false + } + else{ + return true + } + +} +function updateTime(){ + var period = getPeriod() + console.log(period) + var today = new Date(); + var time = today.getMinutes() + (today.getHours() * 60) + var isThursday = today.getDay() === 4; + if (isThursday == true){ + var timeRemaining = thursBellSchedule[period + 1] - time; + } else{ + var timeRemaining = bellSchedule[period + 1] - time; + } + return timeRemaining; + +} +function hTimer() { + + var minRemaining = updateTime(); - 1 + var secRemaining = 60-(new Date().getSeconds()); + + // if secRemaining is less than 10, add a 0 in front of it + if (secRemaining < 10){ + secRemaining = "0" + secRemaining; + } + document.getElementById("timer").textContent = minRemaining + ":" + secRemaining; +} + // Create function show_recent_messages to display the number and location of messages that were sent in the last 24 hours in classes and assignments that the user is in function show_recent_messages(messages, classes, assignments){ //Create a variable to store the data in format [{location: assignment and/or class, num_messages: number of messages sent in the last 24 hours, id: id of the assignment or class}] var locations = []; var class_ids = get_classes_ids(classes); - console.log(class_ids) + //Iterate over all messages for (const message of messages) { var in_classes = in_user_classes(message.location, classes); var in_assignments = in_user_assignments(class_ids, assignments, message.location); var recent = is_recent(message.timestamp); - console.log(in_classes, in_assignments, recent) + //Check if the message was sent in the last 24 hours if (recent && (in_classes !== false || in_assignments !== false)){ //Check if the location of the message is already in the locations list @@ -95,14 +179,27 @@ function get_classes_ids(classes){ } return ids; } - +window.onload = function() { + if (datechecker() === true){ + setInterval(hTimer, 1000); + } + else{ + document.getElementById("timer").textContent = "No School :D"; + } + + console.log("Its always around me, all this noise but Not nearly as loud as the voice sayin Let it happen, let it happenIt's gonna feel so good Just let it happen, let it happen. Ie") + +} +window.addEventListener("DOMContentLoaded", (event) => { + console.log("DOM fully loaded and parsed, going with whatg i always longed forrrrrrr feel like a brandnew person making the same msitakes"); +}); //Create a fetch request to /data to get Chat, Classes, and Assignments data async function main(){ -console.log("fetching data") -const data = await fetchRequest('/data', { data: "Chat, FILTERED Classes, Assignments" }); - console.log("got data") +const data = await fetchRequest('/data', { data: "Chat, FILTERED Classes, Assignments, FILTERED Friends, FILTERED FClasses" }); + + //Store the data in variables var messages = data['Chat'] var classes = data['Classes'] @@ -110,8 +207,11 @@ const data = await fetchRequest('/data', { data: "Chat, FILTERED Classes, Assign show_recent_messages(messages, classes, assignments); - console.log("done") + return true; + + + } // Register service worker for the app diff --git a/templates/index.html b/templates/index.html index f87c46f9..dcfc4e0e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -72,13 +72,17 @@

This is the dashboard

Recent Messages

- + +
+

00:00

+

Current Class:

+
+
+ - - - + + - - \ No newline at end of file +