Skip to content

Commit

Permalink
fixed bugs with classes starting at the half hour
Browse files Browse the repository at this point in the history
  • Loading branch information
digas99 committed Sep 6, 2022
1 parent 4eb8247 commit afa7e98
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 17 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# [Changelog v0.1.0](https://github.com/digas99/schedule-ua/releases/tag/v1.0.0)
# [Changelog v1.0.1](https://github.com/digas99/schedule-ua/releases/tag/v1.0.1)

## Bug Fixes
- Fixed issue with classes starting at the half hour (--h30)
- Fixed class info popup not showing when hovering classes the first time the schedule was loaded
- Added another layer of error warnings when fetching the schedule through the PACO API, to prevent infinite loading screen

## Popup
- Changed days selector from the bottom of the page to a popup on the navbar that opens when hovering over the schedule button

# [Changelog v1.0.0](https://github.com/digas99/schedule-ua/releases/tag/v1.0.0)
Released on 06/09/2022

## Content
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ Browser Extension for easy access to your Schedule from Universidade de Aveiro.
1. [Pictures](#pictures)

## Latest Features
### [Changelog v1.0.1](https://github.com/digas99/schedule-ua/releases/tag/v1.0.1)
Released on 07/09/2022

#### Bug Fixes
- Fixed issue with classes starting at the half hour (--h30)
- Fixed class info popup not showing when hovering classes the first time the schedule was loaded
- Added another layer of error warnings when fetching the schedule through the PACO API, to prevent infinite loading screen

#### Popup
- Changed days selector from the bottom of the page to a popup on the navbar that opens when hovering over the schedule button

### [Changelog v0.1.0](https://github.com/digas99/schedule-ua/releases/tag/v1.0.0)
Released on 06/09/2022

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "SchedUA",
"description": "Unoficial extension to easily look up your schedule from Universidade de Aveiro.",
"version": "1.0.0",
"version": "1.0.1",
"manifest_version": 3,
"action": {
"default_popup": "login.html"
Expand Down
8 changes: 4 additions & 4 deletions scripts/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ chrome.storage.sync.get([...STORAGE_KEYS, "trimmed", "subject_colors", "selected
if (!subjectColors)
chrome.storage.sync.set({"subject_colors": mySchedule.subjectColors});

if (!result["subjects"] && mySchedule.subjects)
if (mySchedule.subjects)
chrome.storage.sync.set({"subjects": mySchedule.subjects});

if (result["trimmed"]) updateExpandButton("shrink");

if (result["trimmed"])
updateExpandButton("shrink");

if (result["selected"]) {
const selectors = document.querySelectorAll(".day-selector div");
Expand Down Expand Up @@ -230,7 +230,7 @@ window.addEventListener("mouseover", e => {
const start = parseFloat(subjectInfo["start"].replace(",", "."));
const duration = parseFloat(subjectInfo["duration"].replace(",", "."));
const end = start+duration;
const popup = classInfoPopup(subjectInfo["subject"]["name"], start, end, subjectColors[targetSubject]);
const popup = classInfoPopup(subjectInfo["subject"]["name"], start, end, mySchedule.subjectColors ? mySchedule.subjectColors[targetSubject] : null);
popup.style.top = (subject.offsetHeight - 5)+"px";
subject.appendChild(popup);
}
Expand Down
15 changes: 14 additions & 1 deletion scripts/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ chrome.storage.sync.get([...STORAGE_KEYS, "email"], result => {

document.querySelector(".loading").remove();
const text = document.querySelector("#main > div > div");
if (text) {
if (text && message) {
text.innerText = message;
text.style.color = "#f56161";
}
Expand All @@ -72,6 +72,19 @@ chrome.storage.sync.get([...STORAGE_KEYS, "email"], result => {
if (success)
window.location.href = "/home.html";
});
})
.catch(() => {
document.querySelector(".loading").remove();
const text = document.querySelector("#main > div > div");
if (text) {
text.innerText = "Something went wrong! Please try again.";
text.style.color = "#f56161";
}

// save email if asked
const remember = document.getElementById("remember-email")?.querySelector("input").checked;
if (remember) data["email"] = email;
else chrome.storage.sync.remove("email");
});
}
});
Expand Down
22 changes: 14 additions & 8 deletions scripts/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,37 @@ Schedule.prototype = {
Object.entries(this.schedule).sort(([a_day, a_subject], [b_day, b_subject]) => this.daysIndex[a_day] - this.daysIndex[b_day])
.forEach(([day, subjects]) => {
subjects?.forEach(subject => {
const start = Number(subject["start"].replace("h", ""));
const start = parseFloat(subject["start"].replace("h", ""));
this.matrix[start][this.daysIndex[day]] = subject;
});
});
console.log(this.matrix);
},
setColors: function() {
this.subjectColors = shuffleColors(this.subjects, SUBJECT_COLORS);
},
fill: function() {
// iterate through filled matrix
Object.entries(Object.entries(this.matrix)).forEach(([i, [hour, subjects]]) => {
const currentTableIndex = (Number(i)+1)*2;
const tableRow = this.table.querySelector(`tr:nth-of-type(${currentTableIndex})`);
let rowIndex = (Number(i)+1)*2;
let tableRow = this.table.querySelector(`tr:nth-of-type(${rowIndex})`);
let halfHourStart = false;
if (tableRow) {
// fill the row with the subjects
// iterate cells
for (let j = 0; j < subjects.length; j++) {
const subject = subjects[j];
if (subject) {
// check for XXh30 cases
if (parseInt(subject["start"].split(",")[1]) >= 5) {
tableRow = this.table.querySelector(`tr:nth-of-type(${++rowIndex})`);
halfHourStart = true;
}

tableRow.setAttribute("filled", "true");
if (tableRow.nextElementSibling) tableRow.nextElementSibling.setAttribute("filled", "true");

const thisSubjectId = this.subjectId++;
const cell = tableRow.querySelector(`td:nth-child(${j+2})`);
const cell = tableRow.querySelector(`td:nth-child(${j+(!halfHourStart ? 2 : 1)})`);
cell.classList.add("class");
cell.setAttribute("id", thisSubjectId);
cell.setAttribute("subject", subject["subject"]["abbrev"]);
Expand All @@ -129,7 +135,7 @@ Schedule.prototype = {
cell.setAttribute("rowspan", rowspan);
// hide cells below covered by the span
for (let k = 1; k < rowspan; k++) {
const rowOffset = currentTableIndex+k;
const rowOffset = rowIndex+k;
const row = this.table.querySelector(`tr:nth-of-type(${rowOffset})`);
if (row) {
row.setAttribute("filled", "true");
Expand Down Expand Up @@ -178,7 +184,6 @@ Schedule.prototype = {
this.table.querySelectorAll("tr").forEach(row => row.children[Object.keys(this.schedule).length].style.display = "none");
},
trim: function(force=false) {
console.log(this.limitTrimming, this.soonest, this.latest);
if (!this.empty || force || this.limitTrimming) {
const tableRows = this.table.querySelectorAll("tr");
if(tableRows) {
Expand Down Expand Up @@ -294,5 +299,6 @@ const SUBJECT_COLORS = [
"#6fb792",
"#cf77b0",
"#a274df",
"#62c1d1"
"#62c1d1",
"#e6a356"
];
2 changes: 0 additions & 2 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ let subjects, subjectColors;

chrome.storage.sync.get(["subject_colors", "subjects", "email", "selected", "paco_buttons", "highlight_now", "limit_trimming"], result => {
subjectColors = result["subject_colors"];
console.log(subjects);
subjects = result["subjects"];
const subjectColorsElem = document.getElementById("subjects-colors");
if (subjectColors && subjectColorsElem) {
Expand Down Expand Up @@ -43,7 +42,6 @@ chrome.storage.sync.get(["subject_colors", "subjects", "email", "selected", "pac
window.addEventListener("click", e => {
const target = e.target;

console.log(subjects, subjectColors);
if (subjects && subjectColors) {
if (target.closest("#subjects-colors-refresh")) {
subjectColors = shuffleColors(subjects, SUBJECT_COLORS);
Expand Down

0 comments on commit afa7e98

Please sign in to comment.