Changeset - 59ee50e4d13c
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2010-10-29 19:45:23
ohnobinki@ohnopublishing.net
Automatically add a new class each time an auto.php?getsections AJAX call returns a valid list of sections to reduce user confusion about how to use autocomplete.
1 file changed with 10 insertions and 1 deletions:
0 comments (0 inline, 0 general)
scripts/scheduleInput.js
Show inline comments
 
@@ -166,24 +166,29 @@ function add_section(cnum)
 
{
 
    return add_section_n(cnum, '', '', '', '', {'m':false, 't':false, 'w':false, 'h':false, 'f':false}, '', '');
 
}
 

	
 
/**
 
 * Add a list of sections gotten via an AJAX call.
 
 */
 
function add_sections(cnum, data)
 
{
 
    var i;
 
    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.prof, section.location);
 
	}
 
}
 

	
 
	//--------------------------------------------------
 
	// Adds a new class to the input.
 
	//--------------------------------------------------
 
	function add_class_n(name)
 
	{
 
@@ -194,25 +199,29 @@ function add_sections(cnum, data)
 
		jQuery('.className' + classNum).bind('autocompleteselect', {'class_num': classNum},
 
			function(event, ui)
 
			    {
 
				if (ui.item && ui.item.value.indexOf('-'))
 
				    {
 
					jQuery.ajax(
 
						      {
 
							  url: 'auto.php',
 
							  data: {'getsections': 1, 'term': ui.item.value},
 
							  context: {'class_num': event.data.class_num},
 
							  success: function(data, textStatus, reqobj)
 
							      {
 
								  add_sections(this.class_num, data);
 
								  if (data.sections)
 
								      {
 
									  add_sections(this.class_num, data);
 
									  add_class();
 
								      }
 
							      }
 
						      }
 
						      );
 
				    }
 
			    });
 

	
 

	
 
		classNum++;
 

	
 
		return (classNum - 1);
 
	};
 
function add_class()
0 comments (0 inline, 0 general)