Skip to content

Commit

Permalink
Begin implementing lunch feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kdk1616 authored and psvenk committed Feb 19, 2020
1 parent 49458de commit cebe314
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 22 deletions.
2 changes: 2 additions & 0 deletions public/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<!--===============================================================================================-->
<script type="text/javascript" src="./js/extraFunctions.js"></script>
<!--===============================================================================================-->
<!-- <script type="text/javascript" src="./js/clock.js"></script>-->
<!--===============================================================================================-->
<script type="text/javascript" src="./js/buttonFunctions.js"></script>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
Expand Down
22 changes: 1 addition & 21 deletions public/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,27 +890,7 @@ function responseCallbackPartial(response) {
//let periods = ["Period 1", "CM/OTI", "Period 2", "Period 3", "Period 4"];
let periods = tableData.schedule.black.slice().map(x => x.aspenPeriod.substring(x.aspenPeriod.indexOf("-") + 1));

var per3 = tableData.schedule.black[3];//right now only decides lunch based on black day...
var floor = per3.room[0];
var zone = per3.room[1];
console.log("zone: " + zone + " floor: " + floor);
let lunch = 0;


//-------LOGIC TO DECIDE LUNCH (THIS WILL NEED TO BE UPDATED)---------------
if ((zone < 6 && floor < 3) && (!per3.name.includes("Bio") && !per3.name.includes("Chem") && !per3.name.includes("Physics") && !per3.name.includes("Science"))) {
lunch = 1;
}
if((zone < 6 && floor > 3) || zone == 6) {
lunch = 2;
}
if (zone < 6 && floor == 3 || per3.name.includes("Bio") || per3.name.includes("Chem") || per3.name.includes("Physics") || per3.name.includes("Science") || per3.name.includes("PE")) {//(Rindge 3rd floor, VPA in Arts Building (NOT ACCOUNTED FOR), Science, War Memorial == C
lunch = 3;
}
else {
lunch = 0;
}
//---------END LUNCH LOGIC----------
lunch = lunchTime();


if (lunch == 1) {//Lunch A
Expand Down
57 changes: 56 additions & 1 deletion public/js/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ function update_lunch() {
redraw_clock();
}


function updateClockLunch(lunch) {

current_schedule = lunch;
console.log("here");
}



// Takes an object with "room" and "id"
function get_schedule(p3room, p3id) {
var floor = Math.floor(p3room / 1000);
Expand Down Expand Up @@ -167,6 +176,13 @@ function school_day() {
}

function redraw_clock() {

var lunch = lunchTime();

if(lunch != 0) {//If correct lunch time can be isolated..
document.getElementById("lunch_range").value = lunch - 1;

}
// Fake call to get_period_name to set current_schedule
get_period_name("Period 1");
// UTC to EST
Expand Down Expand Up @@ -221,7 +237,7 @@ function redraw_clock() {
number += 12 * 60 * 60 * 1000;
}
}

// conver 0-1 to 0-2pi
pos = pos * 2 * Math.PI;

Expand All @@ -234,4 +250,43 @@ function redraw_clock() {
drawName(period_name);
drawHand(large_ctx, large_radius, pos, large_radius * .94, large_radius * .095);
drawNumber(large_ctx, large_radius, pos, number);


}




function lunchTime() {
var per3 = tableData.schedule.black[3];//right now only decides lunch based on black day...
var floor = per3.room[0];
var zone = per3.room[1];
console.log("zone: " + zone + " floor: " + floor);
let lunch = 0;


//-------LOGIC TO DECIDE LUNCH (THIS WILL NEED TO BE UPDATED)---------------
if ((zone < 6 && floor < 3) && (!per3.name.includes("Bio") && !per3.name.includes("Chem") && !per3.name.includes("Physics") && !per3.name.includes("Science"))) {
lunch = 1;
updateClockLunch("regular-a");//Update Clock;
}
if((zone < 6 && floor > 3) || zone == 6) {
lunch = 2;
updateClockLunch("regular-b");//Update Clock;

}
if (zone < 6 && floor == 3 || per3.name.includes("Bio") || per3.name.includes("Chem") || per3.name.includes("Physics") || per3.name.includes("Science") || per3.name.includes("PE")) {//(Rindge 3rd floor, VPA in Arts Building (NOT ACCOUNTED FOR), Science, War Memorial == C
lunch = 3;
updateClockLunch("regular-c");//Update Clock;

}
else {
lunch = 0;
}
//---------END LUNCH LOGIC----------

return lunch;
}



33 changes: 33 additions & 0 deletions public/js/extraFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,36 @@ let anyEdited = function() {
return finalDecision;
}

function lunchTime() {
var per3 = tableData.schedule.black[3];//right now only decides lunch based on black day...
var floor = per3.room[0];
var zone = per3.room[1];
console.log("zone: " + zone + " floor: " + floor);
let lunch = 0;


//-------LOGIC TO DECIDE LUNCH (THIS WILL NEED TO BE UPDATED)---------------
if ((zone < 6 && floor < 3) && (!per3.name.includes("Bio") && !per3.name.includes("Chem") && !per3.name.includes("Physics") && !per3.name.includes("Science"))) {
lunch = 1;
updateClockLunch("regular-a");//Update Clock;
}
if((zone < 6 && floor > 3) || zone == 6) {
lunch = 2;
updateClockLunch("regular-b");//Update Clock;

}
if (zone < 6 && floor == 3 || per3.name.includes("Bio") || per3.name.includes("Chem") || per3.name.includes("Physics") || per3.name.includes("Science") || per3.name.includes("PE")) {//(Rindge 3rd floor, VPA in Arts Building (NOT ACCOUNTED FOR), Science, War Memorial == C
lunch = 3;
updateClockLunch("regular-c");//Update Clock;

}
else {
lunch = 0;
}
//---------END LUNCH LOGIC----------
// redraw_clock();//Redraw Clock based on lunch

return lunch;
}


0 comments on commit cebe314

Please sign in to comment.