var courses; chrome.storage.sync.get('savedCourses', function(data) { chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) { var isConflicted = []; if(response.isConflict){ var between = response.between; var text = ""; for(var i = 0; i"+text+""); } }); courses = data.savedCourses; if(courses.length != 0){ $("#empty").hide(); } console.log(courses); for(var i = 0; i

"+department + " "+course_nbr+""+" with "+profname+" ("+courses[i].unique+")"+"

"; $("#courseList").append(listhtml); } }); function getSimpleName(coursename, unique){ var department = coursename.substring(0,coursename.search(/\d/)-2); var course_nbr = coursename.substring(coursename.search(/\d/),coursename.indexOf(" ",coursename.search(/\d/))); return department+" "+course_nbr+" ("+unique+")"; } function updateConflicts(){ chrome.runtime.sendMessage({command: "checkConflicts"}, function(response) { var isConflicted = []; if(response.isConflict){ var between = response.between; var text = ""; for(var i = 0; i"+text+""); } }); } $(document).ready(function() { $("#courseList li").click(function(){ //GACKY FIX $(this).find("#listMoreInfo").click(function(){ window.open(courses[$(this).closest("li").attr("id")].link); }); $(this).find("#listRemove").click(function(){ var thisForm = this; chrome.runtime.sendMessage({command: "courseStorage",course: courses[$(thisForm).closest("li").attr("id")], action:"remove"}, function(response) { $(thisForm).closest("li").fadeOut(200); console.log($(thisForm).closest("ul").children(":visible").length); $(thisForm).closest("ul").find("> p").remove(); if($(thisForm).closest("ul").children(':visible').length===1){ $("#courseList").fadeOut(300,function(){ $("#empty").fadeIn(200); }); } updateConflicts(); chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, {command: "update"}); }); }); }); if($(this).find("#moreInfo").is(":hidden")){ $(this).find("#moreInfo").fadeIn(200); //alert("hello"); } else{ $(this).find("#moreInfo").fadeOut(200); } }); $("#clear").click(function(){ clear(); }); $("#schedule").click(function(){ chrome.tabs.create({ 'url': 'https://utexas.collegescheduler.com/entry'}); }); $("#open").click(function(){ chrome.tabs.create({ 'url': 'chrome://extensions/?options=' + chrome.runtime.id }); }); }); function makeLine(index){ var datetimearr = courses[index].datetimearr; //converted times back var dtmap = new Map([]); for(var i = 0; i: "+timearr[i].split(",")[0]+" to "+timearr[i].split(",")[1]+"
"; } return output; } function clear(){ chrome.storage.sync.set({savedCourses: []}); chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, {command: "update"}); }); console.log("cleared"); $("#courseList").fadeOut(300,function(){ $("#empty").fadeIn(200); }); }