diff --git a/scripts/scheduleInput.js b/scripts/scheduleInput.js --- a/scripts/scheduleInput.js +++ b/scripts/scheduleInput.js @@ -117,7 +117,7 @@ function add_section_n(cnum, name, synon if(type == 'lab') cssclasses += ' lab'; - var section_html = '' + + var section_html = '' + '' + '' + '' + ''; - jQuery('.pclass' + cnum).after(section_html); + jQuery('tr.class' + cnum + ':last').after(section_html); sectionsOfClass[cnum] ++; - var section_tr = jQuery('.pclass' + cnum).next(); + var section_tr = jQuery('#tr-section-' + String(snum)); /* store course_i in a place the newly added section will look for it */ section_tr.data({course_i: cnum}); @@ -239,16 +239,11 @@ function add_sections(cnum, data) if (!data.sections) return; - /* - * we get the sections in the correct order. For the user to see - * them in the correct order, we must reverse the add_setion_n() - * calls. - */ - for (i = data.sections.length - 1; i >= 0; i --) - { - section = data.sections[i]; - add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end, section.days, section.instructor, section.location, section.type); - } + + jQuery.each(data.sections, function(i, section) + { + add_section_n(cnum, section.section, section.synonym, section.time_start, section.time_end, section.days, section.instructor, section.location, section.type); + }); /* * Handle course-level interdependencies. @@ -256,7 +251,11 @@ function add_sections(cnum, data) if (data.dependencies) jQuery.each(data.dependencies, function(i, dep) { - var new_course_num = add_class_n(dep['class'], dep['title'] ? dep['title'] : ''); + /* Gracefully deprecate the old crawler's JSON format. */ + if (dep['class']) + dep.course = dep['class']; + + var new_course_num = add_class_n(dep.course, dep['title'] ? dep['title'] : ''); add_sections(new_course_num, dep); }); }