Fixed overlapping issue and modified event format

This commit is contained in:
Kevin Dao
2018-08-10 21:11:33 -05:00
parent 6ee0cb51c6
commit f4bac4d558
2 changed files with 14 additions and 17 deletions

View File

@@ -47,9 +47,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
border-radius: 4px; border-radius: 4px;
border: none; border: none;
padding: 5px; padding: 5px;
opacity: 0.65; opacity: 1;
left: 5% !important;
right: 5% !important;
} }
/* Bolds the name of the event and inherits the font size */ /* Bolds the name of the event and inherits the font size */

View File

@@ -7,10 +7,6 @@ $(function() {
'#FFEA00', '#FFC400', '#FF9100', 'FF3D00', '#FFEA00', '#FFC400', '#FF9100', 'FF3D00',
'#4E342E', '#424242', '#37474F']; '#4E342E', '#424242', '#37474F'];
// console.log(moment().day('Tuesday')._d.toString().split(' '));
// console.log(moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2]);
// Counter to iterate through material colors to avoid duplicates // Counter to iterate through material colors to avoid duplicates
var colorCounter = 0; var colorCounter = 0;
@@ -20,18 +16,22 @@ $(function() {
chrome.storage.sync.get('savedCourses', function (data) { chrome.storage.sync.get('savedCourses', function (data) {
var savedCourses = data.savedCourses; var savedCourses = data.savedCourses;
console.log(savedCourses);
// Iterate through each saved course and add to 'event' // Iterate through each saved course and add to 'event'
for (let i = 0; i < savedCourses.length; i++) { for (let i = 0; i < savedCourses.length; i++) {
var classInfo = savedCourses[i]; // Store all info for a single class var classInfo = savedCourses[i]; // Store all info for a single class
var department = classInfo.coursename.substring(0,classInfo.coursename.search(/\d/)-2);
var course_nbr = classInfo.coursename.substring(classInfo.coursename.search(/\d/),classInfo.coursename.indexOf(" ",classInfo.coursename.search(/\d/)));
var uncapProf = classInfo.profname;
uncapProf = uncapProf.charAt(0) + uncapProf.substring(1).toLowerCase();
for (let j = 0; j < classInfo.datetimearr.length; j++) { for (let j = 0; j < classInfo.datetimearr.length; j++) {
let session = classInfo.datetimearr[j]; // One single session for a class let session = classInfo.datetimearr[j]; // One single session for a class
if (session[0] == 'M') { if (session[0] == 'M') {
classSchedules.push({ classSchedules.push({
title: classInfo.coursename, title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Monday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00', start: moment().format("YYYY-MM-") + moment().day('Monday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Monday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00', end: moment().format("YYYY-MM-") + moment().day('Monday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter], color: materialColors[colorCounter],
@@ -41,7 +41,7 @@ $(function() {
if (session[0] == 'T') { if (session[0] == 'T') {
classSchedules.push({ classSchedules.push({
title: classInfo.coursename, title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00', start: moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00', end: moment().format("YYYY-MM-") + moment().day('Tuesday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter], color: materialColors[colorCounter],
@@ -51,7 +51,7 @@ $(function() {
if (session[0] == 'W') { if (session[0] == 'W') {
classSchedules.push({ classSchedules.push({
title: classInfo.coursename, title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Wednesday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00', start: moment().format("YYYY-MM-") + moment().day('Wednesday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Wednesday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00', end: moment().format("YYYY-MM-") + moment().day('Wednesday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter], color: materialColors[colorCounter],
@@ -61,7 +61,7 @@ $(function() {
if (session[0] == 'TH') { if (session[0] == 'TH') {
classSchedules.push({ classSchedules.push({
title: classInfo.coursename, title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Thursday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00', start: moment().format("YYYY-MM-") + moment().day('Thursday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Thursday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00', end: moment().format("YYYY-MM-") + moment().day('Thursday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter], color: materialColors[colorCounter],
@@ -71,23 +71,23 @@ $(function() {
if (session[0] == 'F') { if (session[0] == 'F') {
classSchedules.push({ classSchedules.push({
title: classInfo.coursename, title: `${department}-${course_nbr}\n${uncapProf}`,
start: moment().format("YYYY-MM-") + moment().day('Friday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00', start: moment().format("YYYY-MM-") + moment().day('Friday')._d.toString().split(' ')[2] + 'T' + session[1][0] + ':00',
end: moment().format("YYYY-MM-") + moment().day('Friday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00', end: moment().format("YYYY-MM-") + moment().day('Friday')._d.toString().split(' ')[2] + 'T' + session[1][1] + ':00',
color: materialColors[colorCounter], color: materialColors[colorCounter],
allday: false allday: false
}); });
} }
colorCounter++; colorCounter++;
} }
} }
$('#calendar').fullCalendar({ $('#calendar').fullCalendar({
editable: false, // Don't allow editing of events editable: false, // Don't allow editing of events
handleWindowResize: true, handleWindowResize: true,
weekends: false, // will hide Saturdays and Sundays weekends: false, // will hide Saturdays and Sundays
slotDuration: '00:15:00', // 15 minute intervals on vertical column
slotEventOverlap: false, // No overlapping between events
defaultView: 'agendaWeek', // Only show week view defaultView: 'agendaWeek', // Only show week view
header: false, // Hide buttons/titles header: false, // Hide buttons/titles
minTime: '08:00:00', // Start time minTime: '08:00:00', // Start time
@@ -97,7 +97,6 @@ $(function() {
allDaySlot: false, allDaySlot: false,
events: classSchedules events: classSchedules
}) })
}); });
}); });