deleting from calendar
This commit is contained in:
@@ -244,7 +244,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
|
|||||||
#classname {
|
#classname {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin-bottom: -10px;
|
margin-bottom: -10px;
|
||||||
font-size: medium;
|
font-size: large;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-content {
|
.modal-content {
|
||||||
@@ -254,7 +254,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border: 1px solid #888;
|
border: 1px solid #888;
|
||||||
width: 30%;
|
width: 35%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#prof {
|
#prof {
|
||||||
@@ -266,6 +266,12 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
|
|||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body a:link,
|
||||||
|
body a:visited {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #3c87a3;
|
||||||
|
}
|
||||||
|
|
||||||
.time {
|
.time {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ $(function () {
|
|||||||
]);
|
]);
|
||||||
const fadetime = 150;
|
const fadetime = 150;
|
||||||
const butdelay = 75;
|
const butdelay = 75;
|
||||||
$("#calendar").prepend('<div id="myModal" class="modal"><div class="modal-content"><span class="close">×</span><div class="card"><div class="cardcontainer"><div><div style="display:flex;"><h2 id="classname">Classname</h2></div><p id="prof">Prof</p></div><div id="timelines"></div><button id="info" class="matbut" style="font-size:medium; margin-right: auto; margin-left:auto; background: #FF9800;">More Info</button></div></div></div></div>');
|
$("#calendar").prepend('<div id="myModal" class="modal"><div class="modal-content"><span class="close">×</span><div class="card"><div class="cardcontainer"><div><div style="display:flex;"><h2 id="classname">Classname</h2></div><p id="prof">Prof</p></div><div id="timelines"></div><button id="info" class="matbut" style="font-size:medium; margin-right: auto; margin-left:auto; background: #FF9800;">More Info</button><button id="remove" class="matbut" style="font-size:medium;margin:10px;background: #FF0000;">Remove</button></div></div></div></div>');
|
||||||
// Counter to iterate through material colors to avoid duplicates
|
// Counter to iterate through material colors to avoid duplicates
|
||||||
var colorCounter = 0;
|
var colorCounter = 0;
|
||||||
// Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR'
|
// Each schedule needs to store 'TITLE - START TIME - END TIME - COLOR'
|
||||||
var classSchedules = [];
|
var classSchedules = [];
|
||||||
var savedCourses = [];
|
var savedCourses = [];
|
||||||
var currLink = "";
|
var currLink = "";
|
||||||
|
var currindex = 0;
|
||||||
chrome.storage.sync.get("savedCourses", function (data) {
|
chrome.storage.sync.get("savedCourses", function (data) {
|
||||||
// Iterate through each saved course and add to 'event'
|
// Iterate through each saved course and add to 'event'
|
||||||
savedCourses = data.savedCourses;
|
savedCourses = data.savedCourses;
|
||||||
@@ -53,11 +54,12 @@ $(function () {
|
|||||||
},
|
},
|
||||||
eventClick: function (data, event, view) {
|
eventClick: function (data, event, view) {
|
||||||
$("#myModal").fadeIn(fadetime);
|
$("#myModal").fadeIn(fadetime);
|
||||||
currLink = savedCourses[data.index].link;
|
currindex = data.index;
|
||||||
var currunique = savedCourses[data.index].unique;
|
currLink = savedCourses[currindex].link;
|
||||||
$("#classname").html(`${savedCourses[data.index].coursename} <span style='font-size:small'>(${savedCourses[data.index].unique})</span>`);
|
var currunique = savedCourses[currindex].unique;
|
||||||
$("#timelines").append(makeLine(savedCourses[data.index].datetimearr));
|
$("#classname").html(`${savedCourses[currindex].coursename} <span style='font-size:small'>(${savedCourses[currindex].unique})</span>`);
|
||||||
$("#prof").html(`with <span style='font-weight:bold;'>${savedCourses[data.index].profname}</span>`);
|
$("#timelines").append(makeLine(savedCourses[currindex].datetimearr));
|
||||||
|
$("#prof").html(`with <span style='font-weight:bold;'>${savedCourses[currindex].profname}</span>`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -103,6 +105,25 @@ $(function () {
|
|||||||
window.open(currLink);
|
window.open(currLink);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
|
$("#remove").click(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "courseStorage",
|
||||||
|
course: savedCourses[currindex],
|
||||||
|
action: "remove"
|
||||||
|
}, function (response) {
|
||||||
|
$("#myModal").fadeOut(fadetime);
|
||||||
|
updateCalendar();
|
||||||
|
chrome.tabs.query({}, function (tabs) {
|
||||||
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
|
chrome.tabs.sendMessage(tabs[i].id, {
|
||||||
|
command: "updateCourseList"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, butdelay);
|
||||||
|
});
|
||||||
/*Close Modal when hit escape*/
|
/*Close Modal when hit escape*/
|
||||||
$(document).keydown((e) => {
|
$(document).keydown((e) => {
|
||||||
if (e.keyCode == 27) {
|
if (e.keyCode == 27) {
|
||||||
@@ -189,13 +210,17 @@ $(function () {
|
|||||||
chrome.runtime.onMessage.addListener(
|
chrome.runtime.onMessage.addListener(
|
||||||
function (request, sender, sendResponse) {
|
function (request, sender, sendResponse) {
|
||||||
if (request.command == "updateCourseList" || request.command == "courseAdded") {
|
if (request.command == "updateCourseList" || request.command == "courseAdded") {
|
||||||
chrome.storage.sync.get("savedCourses", function (data) {
|
updateCalendar();
|
||||||
savedCourses = data.savedCourses
|
|
||||||
setAllEvents(data.savedCourses);
|
|
||||||
console.log(classSchedules);
|
|
||||||
$('#calendar').fullCalendar('removeEventSources');
|
|
||||||
$("#calendar").fullCalendar('addEventSource', classSchedules, true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function updateCalendar() {
|
||||||
|
chrome.storage.sync.get("savedCourses", function (data) {
|
||||||
|
savedCourses = data.savedCourses
|
||||||
|
setAllEvents(data.savedCourses);
|
||||||
|
console.log(classSchedules);
|
||||||
|
$('#calendar').fullCalendar('removeEventSources');
|
||||||
|
$("#calendar").fullCalendar('addEventSource', classSchedules, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
@@ -50,25 +50,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#saveCourse").click(function () {
|
$("#saveCourse").click(function () {
|
||||||
var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl);
|
saveCourse();
|
||||||
chrome.runtime.sendMessage({
|
|
||||||
command: "courseStorage",
|
|
||||||
course: c,
|
|
||||||
action: $("#saveCourse").text().substring(0, $("#saveCourse").text().indexOf(" ")).toLowerCase()
|
|
||||||
}, function (response) {
|
|
||||||
$("#saveCourse").text(response.label);
|
|
||||||
$("#snackbar").text(response.done);
|
|
||||||
$("#snackbar").attr("class", "show");
|
|
||||||
setTimeout(function () {
|
|
||||||
$("#snackbar").attr("class", "");
|
|
||||||
}, 3000);
|
|
||||||
chrome.runtime.sendMessage({
|
|
||||||
command: "updateCourseList"
|
|
||||||
}, function () {
|
|
||||||
update();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#Syllabi").click(function () {
|
$("#Syllabi").click(function () {
|
||||||
@@ -86,12 +68,15 @@ $(function () {
|
|||||||
window.open(eCISLink);
|
window.open(eCISLink);
|
||||||
}, butdelay);
|
}, butdelay);
|
||||||
});
|
});
|
||||||
/*Close Modal when hit escape*/
|
|
||||||
$(document).keydown(function (e) {
|
$(document).keydown(function (e) {
|
||||||
|
/*Close Modal when hit escape*/
|
||||||
if (e.keyCode == 27) {
|
if (e.keyCode == 27) {
|
||||||
$("#myModal").fadeOut(fadetime);
|
$("#myModal").fadeOut(fadetime);
|
||||||
|
$("#snackbar").attr("class", "");
|
||||||
|
} else if (e.keyCode == 13) {
|
||||||
|
/*save course when hit enter*/
|
||||||
|
saveCourse();
|
||||||
}
|
}
|
||||||
$("#snackbar").attr("class", "");
|
|
||||||
});
|
});
|
||||||
/*Listen for update mssage coming from popup*/
|
/*Listen for update mssage coming from popup*/
|
||||||
chrome.runtime.onMessage.addListener(
|
chrome.runtime.onMessage.addListener(
|
||||||
@@ -103,6 +88,27 @@ $(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function saveCourse() {
|
||||||
|
var c = new Course(coursename, uniquenum, profname, datetimearr, status, profurl);
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "courseStorage",
|
||||||
|
course: c,
|
||||||
|
action: $("#saveCourse").text().substring(0, $("#saveCourse").text().indexOf(" ")).toLowerCase()
|
||||||
|
}, function (response) {
|
||||||
|
$("#saveCourse").text(response.label);
|
||||||
|
$("#snackbar").text(response.done);
|
||||||
|
$("#snackbar").attr("class", "show");
|
||||||
|
setTimeout(function () {
|
||||||
|
$("#snackbar").attr("class", "");
|
||||||
|
}, 3000);
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
command: "updateCourseList"
|
||||||
|
}, function () {
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
|
/* Update the course list to show if the row contains a course that conflicts with the saved course is one of the saved courses */
|
||||||
function update() {
|
function update() {
|
||||||
chrome.storage.sync.get('courseConflictHighlight', function (data) {
|
chrome.storage.sync.get('courseConflictHighlight', function (data) {
|
||||||
|
|||||||
162
js/popup.js
162
js/popup.js
@@ -1,159 +1,175 @@
|
|||||||
var courses;
|
var courses;
|
||||||
// get the courses from storage
|
// get the courses from storage
|
||||||
chrome.storage.sync.get('savedCourses', function(data) {
|
chrome.storage.sync.get('savedCourses', function (data) {
|
||||||
//find, build, and show the messages for the conflicts in the saved courses
|
//find, build, and show the messages for the conflicts in the saved courses
|
||||||
chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) {
|
chrome.runtime.sendMessage({
|
||||||
|
command: "checkConflicts"
|
||||||
|
}, function (response) {
|
||||||
var isConflicted = [];
|
var isConflicted = [];
|
||||||
if(response.isConflict){
|
if (response.isConflict) {
|
||||||
var between = response.between;
|
var between = response.between;
|
||||||
var text = "";
|
var text = "";
|
||||||
for(var i = 0; i<between.length;i++){
|
for (var i = 0; i < between.length; i++) {
|
||||||
text+="CONFLICT: "+ getSimpleName(between[i][0].coursename,between[i][0].unique) + " and "+getSimpleName(between[i][1].coursename,between[i][1].unique);
|
text += "CONFLICT: " + getSimpleName(between[i][0].coursename, between[i][0].unique) + " and " + getSimpleName(between[i][1].coursename, between[i][1].unique);
|
||||||
isConflicted.push(between[i][0].unique);
|
isConflicted.push(between[i][0].unique);
|
||||||
isConflicted.push(between[i][1].unique);
|
isConflicted.push(between[i][1].unique);
|
||||||
if(i != between.length-1){
|
if (i != between.length - 1) {
|
||||||
text+= "<br>";
|
text += "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px 5px 5px 10px'>"+text+"</>");
|
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px 5px 5px 10px'>" + text + "</>");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
courses = data.savedCourses;
|
courses = data.savedCourses;
|
||||||
if(courses.length != 0){
|
if (courses.length != 0) {
|
||||||
$("#empty").hide();
|
$("#empty").hide();
|
||||||
}
|
}
|
||||||
// build and append the course list element
|
// build and append the course list element
|
||||||
for(var i = 0; i<courses.length;i++){
|
for (var i = 0; i < courses.length; i++) {
|
||||||
var color;
|
var color;
|
||||||
status = courses[i].status;
|
status = courses[i].status;
|
||||||
if(status.includes("open")){
|
if (status.includes("open")) {
|
||||||
color = "#4CAF50";
|
color = "#4CAF50";
|
||||||
}
|
} else if (status.includes("waitlisted")) {
|
||||||
else if(status.includes("waitlisted")){
|
|
||||||
color = "#FF9800"
|
color = "#FF9800"
|
||||||
}
|
} else if (status.includes("closed") || status.includes("cancelled")) {
|
||||||
else if(status.includes("closed") || status.includes("cancelled")){
|
|
||||||
color = "#F44336";
|
color = "#F44336";
|
||||||
}
|
}
|
||||||
var department = courses[i].coursename.substring(0,courses[i].coursename.search(/\d/)-2);
|
var department = courses[i].coursename.substring(0, courses[i].coursename.search(/\d/) - 2);
|
||||||
var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/),courses[i].coursename.indexOf(" ",courses[i].coursename.search(/\d/)));
|
var course_nbr = courses[i].coursename.substring(courses[i].coursename.search(/\d/), courses[i].coursename.indexOf(" ", courses[i].coursename.search(/\d/)));
|
||||||
var profname = courses[i].profname.substring(0,1)+courses[i].profname.substring(1).toLowerCase();
|
var profname = courses[i].profname.substring(0, 1) + courses[i].profname.substring(1).toLowerCase();
|
||||||
var listhtml = "<li id='"+i+"'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:"+color+"''><h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;'><b>"+department + " "+course_nbr+"<span style='font-size:medium'>"+" with </span><span style='font-size:medium'>"+profname+" ("+courses[i].unique+")"+"</span></b></h4><p style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;'>▼</p></div></div><div id='moreInfo' style='display: none;'><p style='font-weight:bold;padding:10px;margin:0px;font-size:small;background-color:#FFCDD2;'>"+makeLine(i)+"</p><div id='infoButtons' style='border-radius:0px;'><button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button><button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button></div></div></li>";
|
var listhtml = "<li id='" + i + "'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:" + color + "''><h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;'><b>" + department + " " + course_nbr + "<span style='font-size:medium'>" + " with </span><span style='font-size:medium'>" + profname + " (" + courses[i].unique + ")" + "</span></b></h4><p style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;'>▼</p></div></div><div id='moreInfo' style='display: none;'><p style='font-weight:bold;padding:10px;margin:0px;font-size:small;background-color:#FFCDD2;'>" + makeLine(i) + "</p><div id='infoButtons' style='border-radius:0px;'><button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button><button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button></div></div></li>";
|
||||||
$("#courseList").append(listhtml);
|
$("#courseList").append(listhtml);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* prettify the name for the conflict messages*/
|
/* prettify the name for the conflict messages*/
|
||||||
function getSimpleName(coursename, unique){
|
function getSimpleName(coursename, unique) {
|
||||||
var department = coursename.substring(0,coursename.search(/\d/)-2);
|
var department = coursename.substring(0, coursename.search(/\d/) - 2);
|
||||||
var course_nbr = coursename.substring(coursename.search(/\d/),coursename.indexOf(" ",coursename.search(/\d/)));
|
var course_nbr = coursename.substring(coursename.search(/\d/), coursename.indexOf(" ", coursename.search(/\d/)));
|
||||||
return department+" "+course_nbr+" ("+unique+")";
|
return department + " " + course_nbr + " (" + unique + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the conflict messages */
|
/* Update the conflict messages */
|
||||||
function updateConflicts(){
|
function updateConflicts() {
|
||||||
chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) {
|
chrome.runtime.sendMessage({
|
||||||
|
command: "checkConflicts"
|
||||||
|
}, function (response) {
|
||||||
var isConflicted = [];
|
var isConflicted = [];
|
||||||
if(response.isConflict){
|
if (response.isConflict) {
|
||||||
var between = response.between;
|
var between = response.between;
|
||||||
var text = "";
|
var text = "";
|
||||||
for(var i = 0; i<between.length;i++){
|
for (var i = 0; i < between.length; i++) {
|
||||||
text+="Conflict between: "+ getSimpleName(between[i][0].coursename,between[i][0].unique) + " and "+getSimpleName(between[i][1].coursename,between[i][1].unique);
|
text += "Conflict between: " + getSimpleName(between[i][0].coursename, between[i][0].unique) + " and " + getSimpleName(between[i][1].coursename, between[i][1].unique);
|
||||||
isConflicted.push(between[i][0].unique);
|
isConflicted.push(between[i][0].unique);
|
||||||
isConflicted.push(between[i][1].unique);
|
isConflicted.push(between[i][1].unique);
|
||||||
if(i != between.length-1){
|
if (i != between.length - 1) {
|
||||||
text+= "<br>";
|
text += "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px;'>"+text+"</>");
|
$("#courseList").prepend("<p style='font-size:small; font-weight:bold; color:red; margin:5px;'>" + text + "</>");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the button clicks */
|
/* Handle the button clicks */
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
$("#courseList li").click(function(){
|
$("#courseList li").click(function () {
|
||||||
$(this).find("#listMoreInfo").click(function(){
|
$(this).find("#listMoreInfo").click(function () {
|
||||||
window.open(courses[$(this).closest("li").attr("id")].link);
|
window.open(courses[$(this).closest("li").attr("id")].link);
|
||||||
});
|
});
|
||||||
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
|
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
|
||||||
$(this).find("#listRemove").click(function(){
|
$(this).find("#listRemove").click(function () {
|
||||||
var thisForm = this;
|
var thisForm = this;
|
||||||
$(thisForm).closest("ul").find("> p").remove();
|
$(thisForm).closest("ul").find("> p").remove();
|
||||||
chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) {
|
chrome.runtime.sendMessage({
|
||||||
|
command: "courseStorage",
|
||||||
|
course: courses[$(thisForm).closest("li").attr("id")],
|
||||||
|
action: "remove"
|
||||||
|
}, function (response) {
|
||||||
$(thisForm).closest("li").fadeOut(200);
|
$(thisForm).closest("li").fadeOut(200);
|
||||||
if($(thisForm).closest("ul").children(':visible').length===1){
|
if ($(thisForm).closest("ul").children(':visible').length === 1) {
|
||||||
$("#courseList").fadeOut(300,function(){
|
$("#courseList").fadeOut(300, function () {
|
||||||
$("#empty").fadeIn(200);
|
$("#empty").fadeIn(200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateConflicts();
|
updateConflicts();
|
||||||
chrome.tabs.query({}, function(tabs) {
|
chrome.tabs.query({}, function (tabs) {
|
||||||
for(var i = 0; i<tabs.length; i++){
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
chrome.tabs.sendMessage(tabs[i].id, {command: "updateCourseList"});
|
chrome.tabs.sendMessage(tabs[i].id, {
|
||||||
|
command: "updateCourseList"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/* Show the times popout and more info options*/
|
/* Show the times popout and more info options*/
|
||||||
if($(this).find("#moreInfo").is(":hidden")){
|
if ($(this).find("#moreInfo").is(":hidden")) {
|
||||||
$(this).find("#moreInfo").fadeIn(200);
|
$(this).find("#moreInfo").fadeIn(200);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$(this).find("#moreInfo").fadeOut(200);
|
$(this).find("#moreInfo").fadeOut(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#clear").click(function(){
|
$("#clear").click(function () {
|
||||||
clear();
|
clear();
|
||||||
});
|
});
|
||||||
$("#schedule").click(function(){
|
$("#schedule").click(function () {
|
||||||
chrome.tabs.create({ 'url': 'https://registrar.utexas.edu/schedules'});
|
chrome.tabs.create({
|
||||||
|
'url': 'https://registrar.utexas.edu/schedules'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$("#open").click(function(){
|
$("#open").click(function () {
|
||||||
chrome.tabs.create({ 'url': "options.html"});
|
chrome.tabs.create({
|
||||||
|
'url': "options.html"
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$("#calendar").click(function() {
|
$("#calendar").click(function () {
|
||||||
chrome.tabs.create({ 'url': "calendar.html"});
|
chrome.tabs.create({
|
||||||
|
'url': "calendar.html"
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* convert from the dtarr and maek the time lines*/
|
/* convert from the dtarr and maek the time lines*/
|
||||||
function makeLine(index){
|
function makeLine(index) {
|
||||||
var datetimearr = courses[index].datetimearr;
|
var datetimearr = courses[index].datetimearr;
|
||||||
//converted times back
|
//converted times back
|
||||||
var dtmap = new Map([]);
|
var dtmap = new Map([]);
|
||||||
for(var i = 0; i<datetimearr.length;i++){
|
for (var i = 0; i < datetimearr.length; i++) {
|
||||||
datetimearr[i][1][0] = moment(datetimearr[i][1][0], ["HH:mm"]).format("h:mm A");
|
datetimearr[i][1][0] = moment(datetimearr[i][1][0], ["HH:mm"]).format("h:mm A");
|
||||||
datetimearr[i][1][1] = moment(datetimearr[i][1][1], ["HH:mm"]).format("h:mm A");
|
datetimearr[i][1][1] = moment(datetimearr[i][1][1], ["HH:mm"]).format("h:mm A");
|
||||||
}
|
}
|
||||||
for(var i = 0; i<datetimearr.length;i++){
|
for (var i = 0; i < datetimearr.length; i++) {
|
||||||
if(dtmap.has(String(datetimearr[i][1]))){
|
if (dtmap.has(String(datetimearr[i][1]))) {
|
||||||
dtmap.set(String(datetimearr[i][1]),dtmap.get(String(datetimearr[i][1]))+datetimearr[i][0]);
|
dtmap.set(String(datetimearr[i][1]), dtmap.get(String(datetimearr[i][1])) + datetimearr[i][0]);
|
||||||
}
|
} else {
|
||||||
else{
|
dtmap.set(String(datetimearr[i][1]), datetimearr[i][0]);
|
||||||
dtmap.set(String(datetimearr[i][1]),datetimearr[i][0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var output="";
|
var output = "";
|
||||||
var timearr = Array.from(dtmap.keys());
|
var timearr = Array.from(dtmap.keys());
|
||||||
var dayarr = Array.from(dtmap.values());
|
var dayarr = Array.from(dtmap.values());
|
||||||
for(var i = 0; i<dayarr.length;i++){
|
for (var i = 0; i < dayarr.length; i++) {
|
||||||
output += "<span style='font-size:medium'>"+dayarr[i]+"</span>: <span style='float:right'>"+timearr[i].split(",")[0]+" to "+timearr[i].split(",")[1]+"</span><br>";
|
output += "<span style='font-size:medium'>" + dayarr[i] + "</span>: <span style='float:right'>" + timearr[i].split(",")[0] + " to " + timearr[i].split(",")[1] + "</span><br>";
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*Clear the list and the storage of courses*/
|
/*Clear the list and the storage of courses*/
|
||||||
function clear(){
|
function clear() {
|
||||||
chrome.storage.sync.set({savedCourses: []});
|
chrome.storage.sync.set({
|
||||||
chrome.tabs.query({}, function(tabs) {
|
savedCourses: []
|
||||||
for(var i = 0; i<tabs.length; i++){
|
});
|
||||||
chrome.tabs.sendMessage(tabs[i].id, {command: "updateCourseList"});
|
chrome.tabs.query({}, function (tabs) {
|
||||||
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
|
chrome.tabs.sendMessage(tabs[i].id, {
|
||||||
|
command: "updateCourseList"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("cleared");
|
console.log("cleared");
|
||||||
$("#courseList").fadeOut(300,function(){
|
$("#courseList").fadeOut(300, function () {
|
||||||
$("#empty").fadeIn(200);
|
$("#empty").fadeIn(200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user