Skip to content

Commit

Permalink
fix bug where related courses by prof not displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
demetrios-koziris committed May 25, 2016
1 parent d6ad505 commit 2b1b528
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions js/courseLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ url = window.location.href;
var loadMessage = "McGill Enhanced is loading ratings!";

function encodeSymbolsWin1252(string) {
return encodeURI(string).replace("%C3%8", "%C").replace("%C3%9", "%D").replace("%C3%A", "%E").replace("%C3%B", "%F").replace("'", "%27");
return encodeURI(string).replace(/\%C3\%8/g, "%C").replace(/\%C3\%9/g, "%D").replace(/\%C3\%A/g, "%E").replace(/\%C3\%B/g, "%F").replace(/\'/, "%27");
}

function updateProfURL(profKey, profURL) {
Expand Down Expand Up @@ -238,6 +238,7 @@ if (url.match(/.+study.+courses.+[-]+/) != null) {


profs = {};
profsLength = 0;
profsF = [];
profsW = [];
profsS = [];
Expand Down Expand Up @@ -719,9 +720,8 @@ if (url.match(/.+study.+courses.+[-]+/) != null) {
}
}



if (profs.length > 0) {
profKeys = Object.keys(profs)
if (profKeys.length > 0) {

var profCourses = document.createElement('div');
profCourses.className = "view-catalog-program";
Expand All @@ -733,19 +733,20 @@ if (url.match(/.+study.+courses.+[-]+/) != null) {
profCoursesTitle.innerHTML = "<i>View Related Courses by Professor</i>";
profCourses.appendChild(profCoursesTitle);

for (p = 0; p < profs.length; p++) {
prof = profs[p].replace(/\s/g, "%20");
for (var p = 0; p < profKeys.length; p++) {
profName = profs[profKeys[p]].fullName
profURLName = profName.replace(/\&nbsp/g, "%20");
//https://www.mcgill.ca/study/2016-2017/courses/search?search_api_views_fulltext=thomas&sort_by=field_subject_code
//url = "https://www.mcgill.ca/study/" + urlYears + "/search/apachesolr_search/\"" + prof + "\"?filters=type%3Acatalog";
profCoursesURL = "https://www.mcgill.ca/study/" + urlYears + "/courses/search" + (isNewStyle ? "?search_api_views_fulltext=" : "/") + prof;
profCoursesURL = "https://www.mcgill.ca/study/" + urlYears + "/courses/search" + (isNewStyle ? "?search_api_views_fulltext=" : "/") + profURLName;

var profCoursesLinkDiv = document.createElement('div');
profCoursesLinkDiv.className = p==profs.length-1 ? "views-row views-row-last" : "views-row";
profCoursesLinkDiv.className = (p==profKeys.length-1 ? "views-row views-row-last" : "views-row");
profCourses.appendChild(profCoursesLinkDiv);

var profCoursesLink = document.createElement('a');
profCoursesLink.setAttribute("href", profCoursesURL);
profCoursesLink.innerHTML = profs[p];
profCoursesLink.innerHTML = profName
profCoursesLinkDiv.appendChild(profCoursesLink);
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "McGill Enhanced",
"manifest_version": 2,
"version": "2.1.36",
"version": "2.1.37",
"description": "Enhance the functionality of McGill.ca",
"permissions" : [
"declarativeContent"
Expand Down

0 comments on commit 2b1b528

Please sign in to comment.