Skip to content

Commit

Permalink
add warning tooltip for sidebar links that require minerva registration
Browse files Browse the repository at this point in the history
  • Loading branch information
demetrios-koziris committed Dec 17, 2016
1 parent 195700e commit 4e80c45
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
58 changes: 42 additions & 16 deletions src/js/addSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ function makeSidebarContent() {
if (docuumURLdata) {
const docuumURL = "http://www.docuum.com/McGill/review/read_course/" + docuumURLdata;
const docuumButtonString = "View Docuum Course Reviews";
courseEval.appendChild(generateSidebarLink(docuumURL, "mcen-blue", docuumButtonString));
courseEval.appendChild(generateSidebarLink(docuumURL, "mcen-blue", docuumButtonString, false));
}

const mercuryURL = 'https://horizon.mcgill.ca/pban1/bzskmcer.p_display_form?form_mode=ar&subj_tab_in='+courseSubject+'&crse_in='+courseNumber;
const mercuryButtonString = "View Mercury Course Evaluations";
courseEval.appendChild(generateSidebarLink(mercuryURL, "mcen-red", mercuryButtonString, "Must be already signed into Minerva!"));
courseEval.appendChild(generateSidebarLink(mercuryURL, "mcen-red", mercuryButtonString, true));


if (recordingURLdata) {
Expand All @@ -102,14 +102,14 @@ function makeSidebarContent() {
const yearRecordingURLs = recordingURLdata[urlYearF];
for (let r = 0; r < yearRecordingURLs.length; r++) {
const recordingsButtonString = "View " + yearRecordingURLs[r].semester + " " + yearRecordingURLs[r].year + " Sec " + yearRecordingURLs[r].section + " Lectures";
recordings.appendChild(generateSidebarLink(yearRecordingURLs[r].url, "mcen-red", recordingsButtonString));
recordings.appendChild(generateSidebarLink(yearRecordingURLs[r].url, "mcen-red", recordingsButtonString, false));
}
}
else {
const maxYear = Math.max.apply(Math, Object.keys(recordingURLdata));
const maxYearURL = url.replace(/20[0-9][0-9]-20[0-9][0-9]/, maxYear+"-"+(maxYear+1));
const recordingsButtonString = "View " + maxYear + "-" + (maxYear+1) + " for the latest Lectures";
recordings.appendChild(generateSidebarLink(maxYearURL, "mcen-red", recordingsButtonString));
recordings.appendChild(generateSidebarLink(maxYearURL, "mcen-red", recordingsButtonString, false));
}
}

Expand All @@ -123,7 +123,7 @@ function makeSidebarContent() {
for (let i = 0; i < courseTermsCodes.length; i++) {
const courseRegURL = "https://horizon.mcgill.ca/pban1/bwskfcls.P_GetCrse_Advanced?rsts=dummy&crn=dummy&term_in=" + courseTermsCodes[i].code + "&sel_subj=dummy&sel_day=dummy&sel_schd=dummy&sel_insm=dummy&sel_camp=dummy&sel_levl=dummy&sel_sess=dummy&sel_instr=dummy&sel_ptrm=dummy&sel_attr=dummy&sel_subj=" + courseSubject + "&sel_coll=&sel_crse=" + courseNumber + "&sel_title=&sel_schd=&sel_from_cred=&sel_to_cred=&sel_levl=&sel_ptrm=%25&sel_instr=%25&sel_attr=%25&begin_hh=0&begin_mi=0&begin_ap=a&end_hh=0&end_mi=0&end_ap=a&path=1&SUB_BTN=&";
const courseRegButtonString = "View " + courseTermsCodes[i].name + " Registration";
courseReg.appendChild(generateSidebarLink(courseRegURL, "mcen-red", courseRegButtonString, 'Must be already signed into Minerva!'));
courseReg.appendChild(generateSidebarLink(courseRegURL, "mcen-red", courseRegButtonString, true));
}
}

Expand All @@ -137,17 +137,17 @@ function makeSidebarContent() {
if (csusURLdata) {
const csusURL = "https://mcgill-csus.github.io/compmajorguide.html#" + csusURLdata;
const csusButtonString = "View " + courseNameSpaced + " in the CSUS Guide";
other.appendChild(generateSidebarLink(csusURL, "mcen-white", csusButtonString));
other.appendChild(generateSidebarLink(csusURL, "mcen-white", csusButtonString, false));
}
if (docuumURLdata) {
const docuumURL = "http://www.docuum.com/McGill/document/view_class/" + docuumURLdata;
const docuumButtonString = "View " + courseNameSpaced + " on Docuum";
other.appendChild(generateSidebarLink(docuumURL, "mcen-blue", docuumButtonString));
other.appendChild(generateSidebarLink(docuumURL, "mcen-blue", docuumButtonString, false));
}
if (wikinotesURLdata) {
const wikinotesURL = "https://www.wikinotes.ca/" + wikinotesURLdata;
const wikinotesButtonString = "View " + courseNameSpaced + " on Wikinotes";
other.appendChild(generateSidebarLink(wikinotesURL, "mcen-white", wikinotesButtonString));
other.appendChild(generateSidebarLink(wikinotesURL, "mcen-white", wikinotesButtonString, false));
}
}

Expand All @@ -163,7 +163,7 @@ function makeSidebarContent() {
const term = courseTermsCodes[i];
if (term.vsbURL) {
const vsbButtonString = "View on VSB " + term.name;
const vsbLink = generateSidebarLink(term.vsbURL, "mcen-purple", vsbButtonString);
const vsbLink = generateSidebarLink(term.vsbURL, "mcen-purple", vsbButtonString, false);
vsb.appendChild(vsbLink);
}
}
Expand All @@ -179,7 +179,7 @@ function makeSidebarContent() {
for (let i = 0; i < deps.length; i++) {
const relatedURL = "https://www.mcgill.ca/study/" + urlYears + "/courses/search?" + (isNewStyle ? "f[0]=field_subject_code%3A" : "filters=ss_subject%3A") + deps[i];
const relatedButtonString = "View all " + deps[i] + " Courses";
related.appendChild(generateSidebarLink(relatedURL, "mcen-red", relatedButtonString, 'Must be already signed into Minerva!'));
related.appendChild(generateSidebarLink(relatedURL, "mcen-red", relatedButtonString, false));
}
}

Expand Down Expand Up @@ -207,6 +207,8 @@ function makeSidebarContent() {
container.insertBefore(sidebar, document.getElementById("footer"));
}

sidebarTooltipsy("minervaWarning");

}


Expand All @@ -226,18 +228,19 @@ function generateSidebarSectionTitle(titleString) {
}


function generateSidebarLink(url, colorClass, buttonValue, title) {
function generateSidebarLink(url, colorClass, buttonValue, minervaWarning) {
const sidebarLink = document.createElement('a');
sidebarLink.setAttribute("href", url);
if (title) {
sidebarLink.setAttribute("title", title);
}
sidebarLink.appendChild(generateSidebarLinkButton(colorClass, buttonValue));
if (minervaWarning ) {
sidebarLink.title = "Must be already signed into Minerva!";
sidebarLink.className = "minervaWarning";
}
sidebarLink.appendChild(generateSidebarLinkButton(colorClass, buttonValue, minervaWarning));
return sidebarLink;
}


function generateSidebarLinkButton(colorClass, buttonValue) {
function generateSidebarLinkButton(colorClass, buttonValue, minervaWarning ) {
const linkButton = document.createElement('button');
linkButton.className = 'form-submit mcen-linkButton' + (isNewStyle ? " mcen-newStyle " + colorClass : "");
linkButton.innerHTML = buttonValue;
Expand Down Expand Up @@ -283,4 +286,27 @@ function generateRelatedCoursesLink(url, titleString) {
relatedCoursesLink.setAttribute("href", url);
relatedCoursesLink.innerHTML = titleString;
return relatedCoursesLink;
}


function sidebarTooltipsy(className, offset) {
if (offset === undefined) {
offset = [0, -10];
}
$('.' + className).tooltipsy( {
delay: 400,
offset: offset,
hide: function (e, $el) {
$el.slideUp(50);
},
css: {
fontFamily: 'CartoGothicStdBook',
padding: '4px',
color: '#444444',
fontSize: '.8em',
backgroundColor: '#FFF0F0',
borderRadius: '6px',
border: '1px #E54944 solid'
}
});
}
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "McGill Enhanced",
"author": "Demetrios Koziris",
"manifest_version": 2,
"version": "3.0.10",
"version": "3.0.11",
"description": "Enhance the functionality of McGill.ca",
"permissions" : [
"declarativeContent",
Expand Down

0 comments on commit 4e80c45

Please sign in to comment.