Skip to content

Commit

Permalink
Add back button to the timetable section
Browse files Browse the repository at this point in the history
Close #22
  • Loading branch information
sbdaule5 committed Dec 28, 2023
1 parent 9198b35 commit 6a0460e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
11 changes: 8 additions & 3 deletions data/generateJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ const getValue = val => {

/**
* @param {string} slot
* @param {string} courseCode
* @return {string[]}
*/
function resolveSlot(slot){
function resolveSlot(slot, courseCode){
if(typeof(slot) !== 'string') {
console.log(typeof(slot))
return;
Expand All @@ -33,7 +34,7 @@ function resolveSlot(slot){
else if(slot.length == 2) {
return {lecture: [slot]};
}
else {
else if(slot.length == 3){
var major = slot[0];
var minor = slot.slice(1).split('');
var slots = [];
Expand All @@ -42,6 +43,10 @@ function resolveSlot(slot){
}
return {lecture: slots};
}
else{
console.log("Failed to resolve slots for ", courseCode);
return;
}
}

const run = async () => {
Expand Down Expand Up @@ -74,7 +79,7 @@ const run = async () => {
},
location: table[row][9],
// Convert slots to the array format manually
slot: resolveSlot(table[row][7]),
slot: resolveSlot(table[row][7], table[row][2]),
instructor: instructors
}

Expand Down
25 changes: 23 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let topRightContainer;
let courses = [];
let slotWiseCourses = {};
export const reset = () => (courses = []);
export const reset = () => {courses = []; websiteState = States.Selecting};
const States = {
Selecting: 0,
TimeTable: 1,
Expand All @@ -30,7 +30,9 @@
function viewTimeTable(){
websiteState = States.TimeTable;
slotWiseCourses = getSlotWise(courses);
}
function editCourses(){
websiteState = States.Selecting;
}
renderGhButton(
{
Expand Down Expand Up @@ -82,6 +84,25 @@
<div class="table">
<TimeTable bind:slotWiseCourses />
</div>

<div style="display: flex; justify-content: center; gap: 0.5rem; margin: 1rem;">

<button on:click={reset} class="outline"><RotateCCWIcon /> Reset</button>

<button
class="raised"
disabled={courses.length === 0 }
on:click={downloadCalendar}
>
Download Calendar
</button>
<button
class="raised"
on:click={editCourses}
>
Change Courses
</button>
</div>
{/if}

<style>
Expand Down

0 comments on commit 6a0460e

Please sign in to comment.