Skip to content

Commit

Permalink
enhance UI
Browse files Browse the repository at this point in the history
  • Loading branch information
EnYiHou committed Feb 10, 2025
1 parent fc7cc06 commit 9a1a5cf
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async function getPayLoad(cookie, courseDigit) {
return inputFields;
} catch (error) {
console.error('Error:', error);
clearMainDiv();
clearMainDiv("Error: " + error.message);
throw error;
}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ async function getHFCourseIDHTML(payload) {
return data;
} catch (error) {
console.error('Error:', error);
clearMainDiv();
clearMainDiv("Error: " + error.message);

throw error;
}
Expand Down Expand Up @@ -433,7 +433,6 @@ async function createCourseDiv(courseDigit, context_title = null, courseListID =

let mediaListDiv = document.createElement('div');
mediaListDiv.className = 'media-list';
mediaListDiv.classList.add('media-list');

let selectAllDiv = document.createElement('div');
selectAllDiv.className = 'select-all-div';
Expand Down Expand Up @@ -630,7 +629,16 @@ async function createCourseDiv(courseDigit, context_title = null, courseListID =


courseDiv.addEventListener('click', () => {
let mediaListDivs = document.querySelectorAll('.media-list');
mediaListDivs.forEach(cmediaListDiv => {
if (cmediaListDiv !== mediaListDiv) {
cmediaListDiv.classList.remove('expanded');
}
});
mediaListDiv.classList.toggle('expanded');
setTimeout(() => {
mediaListDiv.scrollIntoView({ behavior: "smooth", block: "start" });
}, 300);
});
courseDivTitle.addEventListener('contextmenu', async function (ev) {
ev.preventDefault();
Expand Down Expand Up @@ -808,9 +816,7 @@ document.addEventListener('DOMContentLoaded', async function () {


if (!recordingsInfoResult.RecordingsInfo || !mediaRecordingsResult.MediaRecordings || !coursesListResult.CoursesList || !cookiesResult.Cookies) {
clearMainDiv();

return;
clearMainDiv("Error: Unable to get recordings info, please ensure all required data is available.");
}
stoken = recordingsInfoResult.RecordingsInfo.stoken;
etime = recordingsInfoResult.RecordingsInfo.etime;
Expand All @@ -836,7 +842,7 @@ document.addEventListener('DOMContentLoaded', async function () {
}
} catch (error) {
console.error("Error: ", error);
clearMainDiv();
clearMainDiv("Error: " + error.message);

}
});
Expand All @@ -854,10 +860,12 @@ function getFromStorage(key) {
}


function clearMainDiv() {
function clearMainDiv(Error = "Error: Unable to get recordings info") {
while (courses_div.firstChild) {
courses_div.removeChild(courses_div.firstChild);
}
courses_div.appendChild(cannotFindCourses);
const p = document.createElement("p");
p.textContent = Error;
courses_div.appendChild(p);

}

0 comments on commit 9a1a5cf

Please sign in to comment.