Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
feat: add image for "team project"s
Browse files Browse the repository at this point in the history
  • Loading branch information
adil192 committed Jan 28, 2024
1 parent f19c034 commit 16ca26a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/subjects/team/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Image by <a href="https://pixabay.com/users/vungocquang-33748343/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=7804129">Quang Vu Ngoc</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=7804129">Pixabay</a>
Binary file added assets/subjects/team/team.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions scripts/add_course_images.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ const knownModuleImages = {
"MATH32091": "https://raw.githubusercontent.com/adil192/BlackboardTheme/main/assets/subjects/MATH32091/MATH32091.png",
};

/**
* A module whose name matches one of the regular expressions in this map
* will use the corresponding image.
*
* Modules defined in `knownModuleImages` will take priority.
*
* @type {Map<RegExp, string>}
*/
const specialModuleImages = new Map([
[/team project/i, "https://raw.githubusercontent.com/adil192/BlackboardTheme/main/assets/subjects/team/team.jpg"],
]);


/**
* The IndexDB database with the cached module images.
* @type {IDBDatabase | null}
Expand Down Expand Up @@ -108,6 +121,11 @@ async function findModuleImage(moduleName) {
return knownModuleImages[moduleCode];
}

for (const [regex, image] of specialModuleImages) {
if (!regex.test(moduleName)) continue;
return image;
}

const transaction = moduleImagesDB.transaction("moduleImages", "readonly");
const objectStore = transaction.objectStore("moduleImages");
const cachedImage = await new Promise((resolve) => {
Expand Down

0 comments on commit 16ca26a

Please sign in to comment.