From 00e99900cba0a6edefcb09ad13925d7ae4e2d154 Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Fri, 11 Jan 2019 18:34:19 -0600 Subject: [PATCH] fixed image click bug --- calendar.html | 2 +- js/background.js | 71 ++++++++++++++++++++++ js/calendar.js | 137 +++++++++++++++++------------------------- js/html2canvas.min.js | 4 +- 4 files changed, 129 insertions(+), 85 deletions(-) diff --git a/calendar.html b/calendar.html index bc7f852d..41ff7ba7 100644 --- a/calendar.html +++ b/calendar.html @@ -28,6 +28,6 @@ - + \ No newline at end of file diff --git a/js/background.js b/js/background.js index 4c5cf855..028649dc 100644 --- a/js/background.js +++ b/js/background.js @@ -28,6 +28,9 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) { case "updateStatus": updateStatus(); break; + case "getLine": + getLine(request.dtarr, response); + break; case "alreadyContains": alreadyContains(request.unique, response); break; @@ -265,4 +268,72 @@ function updateStatus() { }); // console.log("updated status' and registerlinks"); }); +} + +/* Find if the unique is already contained within the storage*/ +function getLine(datetimearr, sendResponse) { + var output = makeLine(datetimearr); + console.log(output); + sendResponse({ + line: output + }); +} + +/* convert from the dtarr and maek the time lines*/ +function makeLine(datetimearr) { + //converted times back + var output = []; + var dtmap = makeMap(datetimearr); + var timearr = Array.from(dtmap.keys()); + var dayarr = Array.from(dtmap.values()); + 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.push([dayarr[i], timearr[i].split(",")[0], timearr[i].split(",")[1], 'https://maps.utexas.edu/buildings/UTM/' + building, place]); + } + return output; +} + +function makeMap(datetimearr) { + var dtmap = new Map([]); + for (var i = 0; i < datetimearr.length; i++) { + //console.log(datetimearr[i][1][0]); + datetimearr[i][1][0] = moment(datetimearr[i][1][0], ["HH:mm A"]).format("h:mm A"); + datetimearr[i][1][1] = moment(datetimearr[i][1][1], ["HH:mm A"]).format("h:mm A"); + } + for (var i = 0; i < datetimearr.length; i++) { + if (dtmap.has(String(datetimearr[i][1]))) { + dtmap.set(String(datetimearr[i][1]), dtmap.get(String(datetimearr[i][1])) + datetimearr[i][0]); + } else { + dtmap.set(String(datetimearr[i][1]), datetimearr[i][0]); + } + } + return dtmap +} +//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; } \ No newline at end of file diff --git a/js/calendar.js b/js/calendar.js index 0b56fc14..1b1bd466 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -5,6 +5,14 @@ $(function () { '#4E342E', '#424242', '#9E9E9E' ]; + var options = { + + foreignObjectRendering: true, + logging: true, + removeContainer: true, + async: true, + } + const days = new Map([ ["M", "Monday"], ["T", "Tuesday"], @@ -14,19 +22,18 @@ $(function () { ]); const fadetime = 150; const butdelay = 75; - $("#calendar").prepend(`