diff --git a/assets/subjects/team/LICENSE.md b/assets/subjects/team/LICENSE.md new file mode 100644 index 0000000..a43234a --- /dev/null +++ b/assets/subjects/team/LICENSE.md @@ -0,0 +1 @@ +Image by Quang Vu Ngoc from Pixabay \ No newline at end of file diff --git a/assets/subjects/team/team.jpg b/assets/subjects/team/team.jpg new file mode 100644 index 0000000..f866db5 Binary files /dev/null and b/assets/subjects/team/team.jpg differ diff --git a/scripts/add_course_images.js b/scripts/add_course_images.js index a9aa8eb..e28a171 100644 --- a/scripts/add_course_images.js +++ b/scripts/add_course_images.js @@ -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} + */ +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} @@ -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) => {