Skip to content
Open
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
Binary file modified __pycache__/classroom.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/database.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/goals.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/grades.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/jupiter.cpython-312.pyc
Binary file not shown.
Binary file modified __pycache__/main.cpython-312.pyc
Binary file not shown.
10 changes: 10 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']]
Expand Down
114 changes: 107 additions & 7 deletions static/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,23 +179,39 @@ 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']
var assignments = data['Assignments']


show_recent_messages(messages, classes, assignments);
console.log("done")

return true;



}

// Register service worker for the app
Expand Down
16 changes: 10 additions & 6 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ <h2>This is the dashboard</h2>
<h3>Recent Messages</h3>
<div id="recent_messages"></div>
</section>

<!-- Live Classes Section -->
<div id="live-classes-section">
<h3 id="timer">00:00</h3>
<p id="current-class">Current Class: </p>
<div id="friends-classes"></div>
</div>

</div>
</main>
<script src="/static/util.js"></script>
<script src="/static/user_data.js"></script>
<script src="/static/Home.js"></script>

<script src="/static/user_data.js"></script>
<script src="/static/Home.js"></script>
</body>

</html>
</html>