fix: teacher name format, non-bold total, total row spacing, year-level show/custom/smart settings
This commit is contained in:
+14
-3
@@ -164,14 +164,25 @@
|
||||
try {
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Downloading...';
|
||||
const { header, courses } = await scrapeStudyLoad();
|
||||
const { header, courses, period: selectedPeriod } = await scrapeStudyLoad();
|
||||
const included = ISMIStools.filterStudyLoadCourses(courses);
|
||||
if (!included.length) throw new Error('No enrolled courses found.');
|
||||
const totalUnits = ISMIStools.sumUnits(included);
|
||||
const { truncateDescription } = await browser.storage.local.get('truncateDescription');
|
||||
const settings = await browser.storage.local.get(['truncateDescription', 'showYearLevel', 'customYearLevel']);
|
||||
// Resolve the Year Level: custom value wins; otherwise prefer the scraped
|
||||
// value, smart-adjusted (minus one) during SUMMER when the year level has
|
||||
// not yet advanced.
|
||||
header.showYearLevel = settings.showYearLevel !== false;
|
||||
const custom = String(settings.customYearLevel || '').trim();
|
||||
if (custom) {
|
||||
header.yearLevel = custom;
|
||||
} else if (/summer/i.test(selectedPeriod || '')) {
|
||||
const n = parseInt(header.yearLevel, 10);
|
||||
if (Number.isFinite(n) && n > 1) header.yearLevel = String(n - 1);
|
||||
}
|
||||
const res = await browser.runtime.sendMessage({
|
||||
type: 'generate-pdf',
|
||||
data: { header, courses: included, totalUnits, truncateDescription: truncateDescription !== false }
|
||||
data: { header, courses: included, totalUnits, truncateDescription: settings.truncateDescription !== false }
|
||||
});
|
||||
if (!res || !res.ok) throw new Error((res && res.error) || 'PDF generation failed');
|
||||
showToast('PDF downloaded.');
|
||||
|
||||
Reference in New Issue
Block a user