From f34ec12b2e5c32a5cc18a0ae29d2622c74cbf2f5 Mon Sep 17 00:00:00 2001 From: sghsri Date: Fri, 31 Aug 2018 13:00:24 -0500 Subject: [PATCH] location on popup --- js/popup.js | 45 +++++++++++++++++++++++++++++++++++++++++---- todo | 4 ++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/js/popup.js b/js/popup.js index 536eb4c1..47555963 100644 --- a/js/popup.js +++ b/js/popup.js @@ -95,9 +95,9 @@ $(document).ready(function () { $(this).find("#register").text("Register").css("background-color","#4CAF50").click(function () { let registerlink = courses[$(this).closest("li").attr("id")].registerlink; chrome.tabs.query({currentWindow: true, active: true}, function (tab) { - chrome.tabs.update(tab.id, {url: registerlink}); + chrome.tabs.update(tab.id, {url: registerlink}); + }); }); - }); } /* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/ @@ -171,8 +171,45 @@ function makeLine(index) { var output = ""; var timearr = Array.from(dtmap.keys()); var dayarr = Array.from(dtmap.values()); - for (var i = 0; i < dayarr.length; i++) { - output += "" + dayarr[i] + ": " + timearr[i].split(",")[0] + " to " + timearr[i].split(",")[1] + "
"; + + if(timearr.length == 0){ + output="This class has no meeting times." + } + else { + for (var i = 0; i < dayarr.length; i++) { + var place = findLoc(dayarr[i], timearr[i], datetimearr); + var building = place.substring(0, place.search(/\d/) - 1); + if (building == "") { + building = "Undecided Location"; + } + output += `${dayarr[i]}:${timearr[i].split(",")[0]} to ${timearr[i].split(",")[1]}${place}
`; + } + } + return output; +} + + +//find the location of a class given its days and timearrs. +function findLoc(day, timearr, datetimearr) { + for (let i = 0; i < datetimearr.length; i++) { + var dtl = datetimearr[i]; + console.log(dtl[1]); + console.log(timearr); + if (day.includes(dtl[0])) { + if (JSON.stringify(timearr) == JSON.stringify(fixDtl1(dtl[1]))) { + return dtl[2]; + } + } + } +} + +function fixDtl1(dtl1) { + let output = ""; + for (let i = 0; i < dtl1.length; i++) { + output += dtl1[i]; + if (i != dtl1.length - 1) { + output += ","; + } } return output; } diff --git a/todo b/todo index fc9d678d..8236fd94 100644 --- a/todo +++ b/todo @@ -8,11 +8,11 @@ FEATURES: - import calendar BUGS TO FIX: -- online classes no times in popup link DONE/FIXED: - unneeded Logout message on individual course pages - RMP not working on individual course pages - Textbook button (amber) -- Calendar popup \ No newline at end of file +- Calendar popup +- online classes no times in popup link