From 46a26e3806a8725d6f43513e91695d65a5bcd8fe Mon Sep 17 00:00:00 2001 From: aosdict Date: Wed, 7 Sep 2016 21:27:22 -0400 Subject: [PATCH 1/8] Removed all code that sends the user back to the departments just by typing --- app/assets/javascripts/views/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/views/index.js b/app/assets/javascripts/views/index.js index 4804e7d2..ef42fad5 100644 --- a/app/assets/javascripts/views/index.js +++ b/app/assets/javascripts/views/index.js @@ -25,10 +25,10 @@ Yacs.views.index = function () { var key = event.keyCode; if (!(event.ctrlKey || event.metaKey)) { if ((key >= 48 && key <= 105) || key == 32) { - if (key == 127 && searchbar.value.length <= 1) - Yacs.views.departments(content); + // normal keys focus the searchbar searchbar.focus(); } else if (key == 13) { + // enter searches if (searchbar.value) { Yacs.models.courses.query({ search: searchbar.value, show_sections: true, @@ -37,11 +37,7 @@ Yacs.views.index = function () { if (success) Yacs.views.courses(content, data); }); - } else { - Yacs.views.departments(content); } - } else if ((key == 8 || key == 46) && searchbar.value.length <= 1) { - Yacs.views.departments(content); } } }); From 6fb62c30c6ec816f89f46f7b6735e20b5989980f Mon Sep 17 00:00:00 2001 From: aosdict Date: Tue, 13 Sep 2016 14:42:56 -0400 Subject: [PATCH 2/8] Changed show function to showSchedule as a better name --- app/assets/javascripts/views/schedules.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/views/schedules.js b/app/assets/javascripts/views/schedules.js index bc15a64d..d0ac9bc8 100644 --- a/app/assets/javascripts/views/schedules.js +++ b/app/assets/javascripts/views/schedules.js @@ -43,7 +43,9 @@ Yacs.views.schedule = function (target) { var courseIds = []; var events = []; var crns = []; + var totalCredits = 0; schedule.sections.forEach(function (section) { + console.log(section); var color = courseIds.indexOf(section.course_id); if (color == -1) { courseIds.push(section.course_id); @@ -80,14 +82,14 @@ Yacs.views.schedule = function (target) { var data = processSchedules(schedules); scheduleData = data.schedules; schedule.destroy(); - schedule = new Schedule(scheduleElement, + schedule = new Schedule(scheduleElement, { timeBegin: Math.ceil((data.start) / 60) * 60, timeSpan: Math.ceil((data.end - data.start) / 60) * 60 }); scheduleCountElement.textContent = scheduleData.length; if (scheduleData.length > 0) { - show(0); + showSchedule(0); } else { - show(-1); + showSchedule(-1); if (Yacs.user.getSelections().length > 0) { scheduleStatusElement.textContent = "No schedules found :( Try removing some courses"; } else { @@ -125,14 +127,16 @@ Yacs.views.schedule = function (target) { * Show schdule at given index, and display corresponding CRNs. * If index is -1, show nil schedule. */ - var show = function (index) { + var showSchedule = function (index) { if (index == -1) { scheduleStatusElement.textContent = ""; scheduleNumElement.textContent = 0; } else { schedule.setEvents(scheduleData[index].events) scheduleNumElement.textContent = index + 1; - scheduleStatusElement.textContent = 'CRNs: ' + scheduleData[index].crns.join(', '); + scheduleStatusStr = 'CRNs: ' + scheduleData[index].crns.join(', ') + scheduleStatusStr += ' Total Credits: ' + scheduleData[index].totalCredits; + scheduleStatusElement.textContent = scheduleStatusStr; } }; @@ -142,7 +146,7 @@ Yacs.views.schedule = function (target) { var next = function () { if (scheduleData.length > 0) { scheduleIndex = (++scheduleIndex < scheduleData.length ? scheduleIndex : 0); - show(scheduleIndex); + showSchedule(scheduleIndex); } } @@ -152,7 +156,7 @@ Yacs.views.schedule = function (target) { var previous = function () { if (scheduleData.length > 0) { scheduleIndex = (--scheduleIndex < 0 ? scheduleData.length - 1 : scheduleIndex); - show(scheduleIndex); + showSchedule(scheduleIndex); } } From 2693847909ea46fb8107329844dbfa834614ead7 Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 15 Sep 2016 11:52:47 -0400 Subject: [PATCH 3/8] Removed things relating to credits and unrelated to this bug --- app/assets/javascripts/views/schedules.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/javascripts/views/schedules.js b/app/assets/javascripts/views/schedules.js index d0ac9bc8..df992f93 100644 --- a/app/assets/javascripts/views/schedules.js +++ b/app/assets/javascripts/views/schedules.js @@ -43,7 +43,6 @@ Yacs.views.schedule = function (target) { var courseIds = []; var events = []; var crns = []; - var totalCredits = 0; schedule.sections.forEach(function (section) { console.log(section); var color = courseIds.indexOf(section.course_id); @@ -135,7 +134,6 @@ Yacs.views.schedule = function (target) { schedule.setEvents(scheduleData[index].events) scheduleNumElement.textContent = index + 1; scheduleStatusStr = 'CRNs: ' + scheduleData[index].crns.join(', ') - scheduleStatusStr += ' Total Credits: ' + scheduleData[index].totalCredits; scheduleStatusElement.textContent = scheduleStatusStr; } }; From 46de16dff8e41790af80648bdaaa9ba761626cd0 Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 22 Sep 2016 15:53:39 -0400 Subject: [PATCH 4/8] Removed final console.log statement --- app/assets/javascripts/views/schedules.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/views/schedules.js b/app/assets/javascripts/views/schedules.js index df992f93..515e1be4 100644 --- a/app/assets/javascripts/views/schedules.js +++ b/app/assets/javascripts/views/schedules.js @@ -44,7 +44,6 @@ Yacs.views.schedule = function (target) { var events = []; var crns = []; schedule.sections.forEach(function (section) { - console.log(section); var color = courseIds.indexOf(section.course_id); if (color == -1) { courseIds.push(section.course_id); From b5e30dbb0e9aa7234db006b6e393dcae340c5df3 Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 22 Sep 2016 16:01:07 -0400 Subject: [PATCH 5/8] Reverted showSchedule to show --- app/assets/javascripts/views/schedules.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/views/schedules.js b/app/assets/javascripts/views/schedules.js index 515e1be4..67110c9e 100644 --- a/app/assets/javascripts/views/schedules.js +++ b/app/assets/javascripts/views/schedules.js @@ -85,9 +85,9 @@ Yacs.views.schedule = function (target) { timeSpan: Math.ceil((data.end - data.start) / 60) * 60 }); scheduleCountElement.textContent = scheduleData.length; if (scheduleData.length > 0) { - showSchedule(0); + show(0); } else { - showSchedule(-1); + show(-1); if (Yacs.user.getSelections().length > 0) { scheduleStatusElement.textContent = "No schedules found :( Try removing some courses"; } else { @@ -125,7 +125,7 @@ Yacs.views.schedule = function (target) { * Show schdule at given index, and display corresponding CRNs. * If index is -1, show nil schedule. */ - var showSchedule = function (index) { + var show = function (index) { if (index == -1) { scheduleStatusElement.textContent = ""; scheduleNumElement.textContent = 0; @@ -143,7 +143,7 @@ Yacs.views.schedule = function (target) { var next = function () { if (scheduleData.length > 0) { scheduleIndex = (++scheduleIndex < scheduleData.length ? scheduleIndex : 0); - showSchedule(scheduleIndex); + show(scheduleIndex); } } @@ -153,7 +153,7 @@ Yacs.views.schedule = function (target) { var previous = function () { if (scheduleData.length > 0) { scheduleIndex = (--scheduleIndex < 0 ? scheduleData.length - 1 : scheduleIndex); - showSchedule(scheduleIndex); + show(scheduleIndex); } } From 6d1e82819033ef4f507911cb48a2cf895844c065 Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 22 Sep 2016 18:41:09 -0400 Subject: [PATCH 6/8] Added optional tooltip to events in the schedule grid --- vendor/assets/javascripts/schedule/schedule.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vendor/assets/javascripts/schedule/schedule.js b/vendor/assets/javascripts/schedule/schedule.js index 297d5a6d..7baa3e5f 100644 --- a/vendor/assets/javascripts/schedule/schedule.js +++ b/vendor/assets/javascripts/schedule/schedule.js @@ -51,6 +51,10 @@ window.Schedule = function (scheduleContainer, options) { eventElement.style.borderColor = BORDER_COLORS[colorIndex]; eventBackground.style.backgroundColor = BACKGROUND_COLORS[colorIndex]; + if("tooltip" in event) { + eventElement.title = event.tooltip; + } + eventElement.appendChild(eventBackground); eventElement.appendChild(eventText); scheduleElement.appendChild(eventElement); From cc9eabe44d9752853775893e8d54a6669fbd456c Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 22 Sep 2016 18:43:00 -0400 Subject: [PATCH 7/8] Added course name to event objects passed into schedule --- app/assets/javascripts/views/schedules.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/views/schedules.js b/app/assets/javascripts/views/schedules.js index 67110c9e..a21be799 100644 --- a/app/assets/javascripts/views/schedules.js +++ b/app/assets/javascripts/views/schedules.js @@ -62,7 +62,8 @@ Yacs.views.schedule = function (target) { section.department_code + ' ' + section.course_number + ' - ' + section.name, section.crn, section.instructors[0] || '' - ] + ], + tooltip: section.course_name, }); }); }); @@ -130,9 +131,9 @@ Yacs.views.schedule = function (target) { scheduleStatusElement.textContent = ""; scheduleNumElement.textContent = 0; } else { - schedule.setEvents(scheduleData[index].events) + schedule.setEvents(scheduleData[index].events); scheduleNumElement.textContent = index + 1; - scheduleStatusStr = 'CRNs: ' + scheduleData[index].crns.join(', ') + scheduleStatusStr = 'CRNs: ' + scheduleData[index].crns.join(', '); scheduleStatusElement.textContent = scheduleStatusStr; } }; From 38c9ba16e6cdd9130d8cb916f8a0fc8b32222d64 Mon Sep 17 00:00:00 2001 From: copperwater Date: Thu, 22 Sep 2016 21:17:24 -0400 Subject: [PATCH 8/8] Added if space and changed double quotes to single --- vendor/assets/javascripts/schedule/schedule.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/assets/javascripts/schedule/schedule.js b/vendor/assets/javascripts/schedule/schedule.js index 7baa3e5f..3676ccb8 100644 --- a/vendor/assets/javascripts/schedule/schedule.js +++ b/vendor/assets/javascripts/schedule/schedule.js @@ -51,7 +51,7 @@ window.Schedule = function (scheduleContainer, options) { eventElement.style.borderColor = BORDER_COLORS[colorIndex]; eventBackground.style.backgroundColor = BACKGROUND_COLORS[colorIndex]; - if("tooltip" in event) { + if ('tooltip' in event) { eventElement.title = event.tooltip; }