Changeset - ae13413f1878
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 14 years ago 2012-02-15 13:26:36
ohnobinki@ohnopublishing.net
Only show the course slot information to the user for the courses which have multiple slots.
1 file changed with 13 insertions and 8 deletions:
0 comments (0 inline, 0 general)
scripts/scheduleInput.js
Show inline comments
 
@@ -57,49 +57,49 @@ var last_section_i = 0;
 
 *   A quick hash to prevent there from being two AJAX requests for a
 
 *   given course at one time.
 
 */
 
var course_ajax_requests = [];
 

	
 
/**
 
 * \brief
 
 *   The course number which contains nothing.
 
 *
 
 * To avoid having a user need to click the ``Add course'' button, we
 
 * keep a course added at the end of the list of courses. If this
 
 * variable is -1, it indicates that no such free course exists. If it
 
 * is zero or greater, that number is the class which is the free one.
 
 */
 
var slate_permutate_course_free = -1;
 

	
 
/**
 
 * \brief
 
 *   Whether or not we should divulge the existence of course slots to
 
 *   the user.
 
 *
 
 * This will automatically be set to true as soon as a course
 
 * utilizing multiple slots is added using autocomplete.
 
 */
 
var show_course_slots = false;
 
var show_course_slots = [];
 

	
 
/*
 
 * General Input Functions
 
 */
 

	
 
/**
 
 * Outputs an <option/> element. It will inlcude selected="selected"
 
 * if the value param equals the test_value param.
 
 */
 
function genOptionHtml(value, content, test_value)
 
{
 
    var selected = ' selected="selected"';
 
    if (value != test_value)
 
	selected = '';
 
    return '<option value="' + value + '"' + selected + '>' + content + "</option>\n";
 
}
 

	
 

	
 
/** Add tooltips for user guidance */
 
function addTips()
 
{
 
  var tr = jQuery('tr');
 
  var td = tr.eq(tr.length-1);
 

	
 
@@ -300,83 +300,88 @@ function add_sections(cnum, data)
 
	jQuery.each(data.dependencies, function(i, dep) {
 
			/* 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);
 
		    });
 
}
 

	
 
/**
 
 * \brief
 
 *   Adds an identifier for a course slot.
 
 *
 
 * \param course_i
 
 *   The javascript index of the course to which a slot is being
 
 *   added.
 
 * \param slot_id
 
 *   The idenfifier of the slot.
 
 */
 
function course_add_slot_row(course_i, slot_id)
 
{
 
    var extra_classes = '';
 

	
 
    if (!show_course_slots)
 
    if (!show_course_slots[course_i])
 
    {
 
	var aclass;
 
	/*
 
	 * Then check if this course has multiple slots and we should
 
	 * enable displaying them to the user.
 
	 */
 
	aclass = jQuery('.' + safe_css_class('class' + course_i) + '.section .section-slot-entry');
 
	if (aclass.length && aclass.val() != slot_id)
 
	{
 
	    enable_course_slots();
 
	    enable_course_slots(course_i);
 
	}
 
    }
 
    if (!show_course_slots)
 
    if (!show_course_slots[course_i])
 
	extra_classes += ' tr-slot-id-hidden';
 

	
 
    jQuery('tr.class' + course_i + ':last').after(
 
	'<tr class="class' + course_i + ' tr-slot-id ' + safe_css_class('slot-' + slot_id) + extra_classes + '">\n' +
 
	    '  <td><span /></td>\n' +
 
	    '  <td colspan="10"><span class="slot-id-text" /></td>\n' +
 
	    '  <td colspan="2"><span /></td>\n' +
 
	    '</tr>\n'
 
    );
 
    jQuery('tr.class' + course_i + ':last .slot-id-text').text('The following are ' + slot_id + ' sections and will be scheduled as a group.');
 
}
 

	
 
/**
 
 * \brief
 
 * Dynamically enable the displification of course slots to the user.
 
 *   Dynamically enable the displification of course slots to the
 
 *   user.
 
 *
 
 * \param course_i
 
 *   The particular course for which slot displification should be
 
 *   enabled.
 
 */
 
function enable_course_slots()
 
function enable_course_slots(course_i)
 
{
 
    show_course_slots = true;
 
    show_course_slots[course_i] = true;
 

	
 
    jQuery('.tr-slot-id-hidden').removeClass('tr-slot-id-hidden');
 
    jQuery('.' + safe_css_class('class' + course_i) + '.tr-slot-id-hidden').removeClass('tr-slot-id-hidden');
 
}
 

	
 
/**
 
 * \brief
 
 *   Adds a new class to the input.
 
 *
 
 * \param course_id
 
 *   The course_id.
 
 * \param title
 
 *   The human-friendly course title.
 
 * \return
 
 *   The javascript-local course entry identifying number.
 
 */
 
function add_class_n(course_id, title)
 
{
 
    /*
 
     * If we're adding a course entry form with preadded
 
     * content, first remove the empty course.
 
     */
 
    if (course_id.length && slate_permutate_course_free != -1)
 
	course_remove(slate_permutate_course_free);
 

	
 
    sectionsOfClass[classNum] = 0; // Initialize at 0
 
    course_ajax_requests[classNum] = false;
0 comments (0 inline, 0 general)