bugfixes, copy paste unique

This commit is contained in:
Sriram Hariharan
2019-01-14 16:29:53 -06:00
parent 6419fc045a
commit 9947248cd3
3 changed files with 78 additions and 20 deletions

View File

@@ -9,7 +9,7 @@
}
.container {
padding: 2px 16px;
padding: 2px 16px 2px 10px;
}
h2 {
@@ -32,6 +32,7 @@ body {
transition: 0.3s;
}
.settingsbut:focus {
outline: 0;
}
@@ -49,6 +50,33 @@ body {
transition: 0.3s;
}
.copybut {
background-color: transparent;
padding: 0px;
margin: 0px 3px 0px 0px;
border: none;
font-size: 15px;
border-radius: 50%;
transition: .2s;
}
.copybut:focus {
outline: 0;
}
.copybut:hover {
box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.16), 0 4px 20px 0 rgba(0, 0, 0, 0.12);
}
#copyicon {
font-size: x-large;
border-radius: 50%;
padding: 3px;
}
ul {
margin-bottom: 30px;
}
@@ -191,6 +219,7 @@ i {
animation: ripple 1s ease-out;
}
input {
width: 80px;
border-radius: 5px;

View File

@@ -26,7 +26,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
checkConflicts(response);
break;
case "updateStatus":
updateStatus();
updateStatus(response);
break;
case "getLine":
getLine(request.dtarr, response);
@@ -41,6 +41,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
const xhr = new XMLHttpRequest();
const method = request.method ? request.method.toUpperCase() : "GET";
xhr.open(method, request.url, true);
console.log(request);
xhr.onload = () => response(xhr.responseText);
xhr.onerror = () => response(xhr.statusText);
if (method == "POST") {
@@ -246,15 +247,18 @@ function updateTabs() {
});
}
const UPDATE_INTERVAL = 1000 * 60 * 15 // 15 mins
const UPDATE_INTERVAL = 1000 * 60; // 1 mins
setInterval(updateStatus, UPDATE_INTERVAL);
function updateStatus() {
function updateStatus(sendResponse) {
chrome.storage.sync.get('savedCourses', function (data) {
var courses = data.savedCourses;
var nochange = true;
for (let i = 0; i < courses.length; i++) {
try {
let c = courses[i];
let oldstatus = c.status;
let oldlink = c.registerlink;
var xhr = new XMLHttpRequest();
xhr.open("GET", c.link, false);
xhr.send();
@@ -266,15 +270,25 @@ function updateStatus() {
if (registerlink) {
registerlink = registerlink.getAttribute('href');
}
var haschanged = (newstatus == oldstatus && registerlink == oldlink);
if (!haschanged) {
console.log(c.unique + 'updated from ' + oldstatus + " to " + newstatus + " and " + oldlink + " to " + registerlink);
}
nochange &= haschanged;
c.registerlink = registerlink;
c.status = newstatus;
} catch (e) {
console.log('Not logged into UT Coursebook. Could not update class statuses.');
}
}
chrome.storage.sync.set({
savedCourses: courses
});
if (!nochange) {
chrome.storage.sync.set({
savedCourses: courses
});
console.log('updated status');
} else {
console.log('no change');
}
// console.log("updated status' and registerlinks");
});
}

View File

@@ -40,7 +40,12 @@ function setCourseList() {
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;'>
<button class='copybut' id='copybut' value='${courses[i].unique}'>
<i style='color:white;float:left;text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.16);font-size:x-large;' id='copyicon' class="material-icons copy">
content_copy
</i>
</button>
<h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;align-items:center;'>
<b>${department} ${course_nbr} <span style='font-size:medium'> with <span style='font-size:medium'>${profname} (${courses[i].unique})</span></b>
</h4>
<p id='arrow' style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;font-family: sans-serif'>&#9658;</p>
@@ -114,6 +119,22 @@ function updateConflicts() {
/* Handle the button clicks */
$(document).ready(function () {
$('.copybut').click(function (e) {
e.stopPropagation();
var temp = $("<input>");
$(this).find('i').text('check');
$(this).find('i').css('box-shadow', 'none');
$(this).find('i').delay(200).queue(function (n) {
$(this).text('content_copy');
n();
})
$("body").append(temp);
temp.val($(this).val()).select();
document.execCommand("copy");
temp.remove();
});
$("#courseList").on('click', 'li', function () {
$(this).find("#listMoreInfo").click(function () {
window.open(courses[$(this).closest("li").attr("id")].link);
@@ -139,6 +160,7 @@ $(document).ready(function () {
});
})
}
/* clear the conflict messages, then remove the course and updateConflicts. update the tabs*/
$(this).find("#listRemove").click(function () {
var thisForm = this;
@@ -286,6 +308,9 @@ $("#importOrig").change(function (e) {
}
});
setCourseList();
chrome.runtime.sendMessage({
command: "updateStatus",
});
}
} catch (err) {
@@ -399,12 +424,7 @@ function clear() {
function getSemesters() {
var schedulelist = 'https://registrar.utexas.edu/schedules';
chrome.runtime.sendMessage({
method: "GET",
action: "xhttp",
url: schedulelist,
data: ""
}, function (response) {
$.get(schedulelist, function (response) {
if (response) {
var object = $('<div/>').html(response).contents();
object.find('.callout2>ul>li>a').each(function (index) {
@@ -412,12 +432,7 @@ function getSemesters() {
if ($(this).text() != "Course Schedule Archive") {
var semname = $(this).text().split(" ")[0].substring(0, 2) + " " + $(this).text().split(" ")[1];
$("#semesters").append(`<option>${semname}</option>`);
chrome.runtime.sendMessage({
method: "GET",
action: "xhttp",
url: $(this).attr('href'),
data: ""
}, function (response) {
$.get($(this).attr('href'), function (response) {
if (response) {
var object = $('<div/>').html(response).contents();
var name = object.find(".page-title").text();