diff --git a/src/js/addProfLinks.js b/src/js/addProfLinks.js index 4d00162..8a387e5 100644 --- a/src/js/addProfLinks.js +++ b/src/js/addProfLinks.js @@ -17,13 +17,27 @@ The GNU General Public License can also be found at 1) { - profsByTerm[termKey] = profsTermSource[0].split(","); + profsForTerm = profsTermSource[0].split(","); - for (let p=0; p'; profSection.appendChild(profSectionTitle); for (let profKey in profs) { @@ -125,10 +140,11 @@ function makeProfLinks() { termImg.src = chrome.extension.getURL('icons/empty-15.png'); termDiv.appendChild(termImg); - if (termKey in prof.terms) { - termDiv.title = termKey; + if (termKey in prof.termsTeaching) { + termInfo = prof.termsTeaching[termKey]; + termDiv.title = termNames[lang][termInfo.code] + ' ' + termInfo.year; termDiv.className += ' tooltip'; - termImg.src = terms[termKey]; + termImg.src = 'https://www.mcgill.ca/ece/sites/all/modules/mcgill/courses/' + termKey.toLowerCase() + '.gif'; } } @@ -183,7 +199,7 @@ function makeProfLinks() { } -function generateProfObject(minervaProfs, origName, term) { +function generateProfObject(minervaProfs, origName, termKey) { const name = origName.trim(); const splitName = name.split(' '); const profName = { @@ -193,14 +209,13 @@ function generateProfObject(minervaProfs, origName, term) { }; const prof = { key: name.replace(/\W/g, ''), - terms: {}, + termsTeaching: {}, minerva: minervaProfs[name], name: profName, urlCourses: 'https://www.mcgill.ca/study/' + urlYears + '/courses/search' + (isNewStyle ? '?search_api_views_fulltext=' : '/') + profName.full, urlGoogle: 'https://www.google.ca/search?q="rate"+"mcgill"+' + profName.first + '+' + profName.last, urlMercury: 'https://horizon.mcgill.ca/pban1/bzskmcer.p_display_form?form_mode=ar&inst_tab_in=' + minervaProfs[profName.full] }; - prof.terms[term] = ''; return prof; } diff --git a/src/js/addSidebar.js b/src/js/addSidebar.js index f27dbc0..9a499c0 100644 --- a/src/js/addSidebar.js +++ b/src/js/addSidebar.js @@ -34,21 +34,21 @@ function makeSidebarContent() { const courseTerms = document.getElementsByClassName("catalog-terms")[0].innerHTML; const courseTermsCodes = []; - if (courseTerms.match(/Fall/)) { + if (courseTerms.match(termNames[lang][9])) { courseTermsCodes.push( { name: "Fall " + urlYearF, code: urlYearF + "09", vsbURL: "https://vsb.mcgill.ca/vsb/criteria.jsp?term=" + urlYearF + "09&course_0_0=" + courseSubject + "-" + courseNumber + "&ca_0_0=&bbs=" } ); } - if (courseTerms.match(/Winter/)) { + if (courseTerms.match(termNames[lang][1])) { courseTermsCodes.push( { name: "Winter " + urlYearW, code: urlYearW + "01", vsbURL: "https://vsb.mcgill.ca/vsb/criteria.jsp?term=" + urlYearW + "01&course_0_0=" + courseSubject + "-" + courseNumber + "&ca_0_0=&bbs=" } ); } - if (courseTerms.match(/Summer/)) { + if (courseTerms.match(termNames[lang][05])) { courseTermsCodes.push( { name: "Summer " + urlYearW, code: urlYearW + "05" diff --git a/src/js/init.js b/src/js/init.js index 84d38bc..4f6ff62 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -23,19 +23,37 @@ if (url.match(/.+www\.mcgill\.ca\/study\/.+/)) { const start = Date.now(); - const courseNameRegex = /([A-Z]{3,4}[0-9]{0,1})\s([0-9]{3}[A-Za-z]{0,1}[0-9]{0,1})/g; + courseNameRegex = /([A-Z]{3,4}[0-9]{0,1})\s([0-9]{3}[A-Za-z]{0,1}[0-9]{0,1})/g; isNewStyle = document.getElementsByClassName("transition").length > 0; urlYearF = parseInt(url.match(/.+(20[0-9][0-9])-.+/)[1]); urlYearW = urlYearF+1; urlYears = urlYearF + "-" + urlYearW; sysYear = new Date().getFullYear(); sysMonth = new Date().getMonth(); + var lang = 'en'; + if (url.match(/\/fr\//)) { + lang = 'fr'; + } if (url.match(/.+(20[0-9][0-9])-(20[0-9][0-9]).+/)) { addYearMenu(); } if (url.match(/.+study.+courses.+[-]+/)) { + + termNames = { + 'en': { + 9: 'Fall', + 1: 'Winter', + 5: 'Summer' + }, + 'fr': { + 9: 'Automne', + 1: 'Hiver', + 5: 'Été' + }, + }; + makeProfLinks(); makeCourseLinks(courseNameRegex); makeSidebarContent(); diff --git a/src/manifest.json b/src/manifest.json index 869bde1..bcf3f7b 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "name": "McGill Enhanced", "author": "Demetrios Koziris", "manifest_version": 2, - "version": "3.0.27", + "version": "3.0.28", "description": "Enhance the functionality of McGill.ca", "permissions" : [ "declarativeContent",