Commit cfe2d499 authored by Zac Wood's avatar Zac Wood
Browse files

clean up

parent bd3f1391
......@@ -4,7 +4,7 @@
class Schedule {
constructor() {
this.isOpen = false;
this._ids = Array.from(document.getElementById('schedule').children).map(e => Number(e.id.split('-')[1]));
this._ids = Array.from(document.getElementById('schedule').children).map(e => Number(e.dataset.crn));
}
get ids() {
......@@ -70,8 +70,8 @@ class Schedule {
}
class Search {
sectionWithId(sectionId) {
return document.getElementById('search-list').querySelector(`#${sectionId}`);
sectionWithCrn(crn) {
return document.getElementById('search-list').querySelector(`[data-crn="${crn}"]`);
}
}
......@@ -80,14 +80,13 @@ const toggleSchedule = () => this.schedule.toggle();
const addToSchedule = (event, section) => {
section.classList.add('selected');
// this.schedule.addToSchedule(JSON.parse(section.dataset.section));
this.schedule.addToSchedule(section.cloneNode(true));
event.stopPropagation();
};
const removeFromSchedule = section => {
this.search.sectionWithId(section.id).classList.remove('selected');
this.search.sectionWithCrn(section.dataset.crn).classList.remove('selected');
this.schedule.removeFromSchedule(section.id.split('-')[1]);
};
......@@ -115,8 +114,3 @@ const addToSystemCalendar = async () => {
const url = `webcal://${window.location.hostname}/api/schedule?crns=${this.schedule.ids.join(',')}`;
window.open(url, '_self');
};
document.addEventListener('DOMContentLoaded', () => {
this.schedule = new Schedule();
this.search = new Search();
});
......@@ -71,3 +71,10 @@
</div>
</div>
</div>
<%= javascript_tag do %>
document.addEventListener('DOMContentLoaded', () => {
this.schedule = new Schedule();
this.search = new Search();
});
<% end %>
<div class="container-fluid">
<div class="row align-left align-sm-center align-md-right" id="navbar">
<div class="col-8 col-sm align-center">
<a href="/search" id="logo">
<a href="/" id="logo">
<i class="fas fa-calendar-alt"></i>
Schedules
</a>
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment