Changeset - ed49fbf4f2e1
[Not reviewed]
default
0 4 0
Nathan Brink (binki) - 15 years ago 2010-10-19 19:15:49
ohnobinki@ohnopublishing.net
Slowly reindent some javascript, hiddenly slip the meeting location into the final table.
4 files changed with 21 insertions and 17 deletions:
0 comments (0 inline, 0 general)
class.schedule.php
Show inline comments
 
@@ -60,25 +60,25 @@ class Schedule
 
  //--------------------------------------------------
 
  // Adds a new class to the schedule.
 
  //--------------------------------------------------
 
  function addClass($n)
 
  {
 
    $this->classStorage[$this->nclasses] = new Classes($n);
 
    $this->nclasses++;
 
  }
 

	
 
  //--------------------------------------------------
 
  // Adds a section to the desired class.
 
  //--------------------------------------------------
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $faculty = NULL, $room = NULL)
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $faculty = NULL, $location = NULL)
 
  {
 
    $found = false;
 
    $counter = 0;
 
      
 
    while(!$found && ($counter < $this->nclasses))
 
      {
 
	$temp = $this->classStorage[$counter]->getName();
 
			
 
	if((strcmp($temp,$course_name)) == 0)
 
	  {
 
	    $found = true;
 
	  } else {
 
@@ -87,25 +87,25 @@ class Schedule
 
      }
 
		
 
    if($counter == $this->nclasses)
 
      {
 
	echo 'Could not find class: ' . $course_name . "<br />\n";
 
      } else {
 
      $section = $this->classStorage[$counter]->section_get($letter);
 
      if (!$section)
 
	{
 
	  $section = new Section($letter, array(), $synonym, $faculty);
 
	  $this->classStorage[$counter]->section_add($section);
 
	}
 
      $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $room));
 
      $section->meeting_add(new SectionMeeting($days, $time_start, $time_end, $location));
 
    }
 
  }
 

	
 
  //--------------------------------------------------
 
  // Finds all of the possible permutations and stores
 
  // the results in the storage array.
 
  //--------------------------------------------------
 
	function findPossibilities()
 
	{
 
		$this->possiblePermutations = 1;
 
		/* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */
 
		if (!$this->nclasses)
input.php
Show inline comments
 
@@ -35,25 +35,26 @@ if ($sch)
 
      $nsections = $class->getnsections();
 
      for ($section_key = $nsections - 1; $section_key >= 0; $section_key --)
 
	{
 
	  $section = $class->getSection($section_key);
 
	  $meetings = $section->getMeetings();
 
	  foreach ($meetings as $meeting)
 
	    {
 
	      $my_hc .= '    add_section_n(class_last, \'' . htmlentities($section->getLetter(), ENT_QUOTES) . '\', \''
 
		. htmlentities($section->getSynonym(), ENT_QUOTES) . '\', \''
 
		. $meeting->getStartTime() . '\', \''
 
		. $meeting->getEndTime() . '\', '
 
		. json_encode(array('m' => $meeting->getDay(0), 't' => $meeting->getDay(1), 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4))) . ', \''
 
		. htmlentities($section->getProf(), ENT_QUOTES) . "');\n";
 
		. htmlentities($section->getProf(), ENT_QUOTES) . '\', \''
 
		. htmlentities($meeting->getLocation(), ENT_QUOTES) . "');\n";
 
	    }
 
	}
 
    }
 
  $my_hc .= '  });
 
';
 
  $inputPage->headcode_add('scheduleInput', $inputPage->script_wrap($my_hc), TRUE);
 
}
 
else
 
  $inputPage->headcode_add('schduleInput', $inputPage->script_wrap('jQuery(document).ready( function() { add_class(); } );'), TRUE);
 

	
 
$inputPage->head();
 

	
process.php
Show inline comments
 
@@ -112,25 +112,25 @@ if(!$DEBUG)
 
		   * section to the class. We know that $class['name']
 
		   * is not a section, so count() needs to be > 1 and
 
		   * we need to skip over 'name' in our loop.
 
		   */
 
			if(is_array($class) && count($class) > 1)
 
			{
 
				$allClasses->addClass($class['name']);
 
		
 
				foreach($class as $section)
 
				  /* Skip the section name, which isn't a section */
 
					if(is_array($section))
 
					{
 
					  $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), NULL, $section['professor']);
 
					  $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), NULL, $section['professor'], $section['location']);
 
					}
 
			}
 
		}
 
		$allClasses->findPossibilities();
 
		if (!isset($_SESSION['saved']))
 
		  $_SESSION['saved'] = array();
 
		$schedule_id = schedule_store_store($schedule_store, $allClasses);
 
		if ($schedule_id != NULL)
 
		  $_SESSION['saved'][$schedule_id] = $allClasses->getName();
 

	
 
		$process_php_s = '';
 
		if (!$clean_urls)
scripts/scheduleInput.js
Show inline comments
 
@@ -56,34 +56,35 @@ var sectionsOfClass = new Array();
 
		selectNone: true
 
	});
 
	jQuery.validator.addClassRules("daysRequired", {
 
		daysRequired: true
 
	});
 

	
 

	
 

	
 
    //--------------------------------------------------
 
    // General Input Functions
 
    //--------------------------------------------------
 

	
 
	//--------------------------------------------------
 
	// Returns the common inputs for each new section.
 
	//--------------------------------------------------
 
/**
 
 * \brief
 
 * Returns the common inputs for each new section.
 
 */
 
        function genSectionHtml(cnum)
 
	{
 
		genSectionHtml_n(cnum,'','','','','','');
 
    genSectionHtml_n(cnum, '', '', '', '', '', '', '');
 
	}
 

	
 
	/* @TODO: This should select & set items based on args, if the args != '' */
 
	function genSectionHtml_n(cnum,name,synonym,stime,etime,days,prof)
 
function genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location)
 
	{
 
		var snum = sectionsOfClass[cnum];
 

	
 
		var result = '<tr class="section class' + cnum + '"><td class="none"></td>';
 
	        result = result + '<td class="sectionIdentifier center"><input type="hidden" name="postData[' + cnum + '][' + snum + '][synonym]" value="' + synonym + '" /><input type="text" size="1" class="required" name="postData[' + cnum + '][' + snum + '][letter]" value="' + name + '" /></td>';
 
		result = result + '<td class="professor center"><input type="text" size="10" class="required" name="postData[' + cnum + ']['+ snum + '][professor]" value="' + prof + '" /></td>';
 
		result = result + '<td><select class="selectRequired" name="postData[' + cnum + '][' + snum + '][start]"><option value="none"></option>'
 
				 + genOptionHtml("0700", "7:00 am", stime) + genOptionHtml("0730", "7:30 am", stime)
 
				 + genOptionHtml("0800", "8:00 am", stime) + genOptionHtml("0830", "8:30 am", stime)
 
				 + genOptionHtml("0900", "9:00 am", stime) + genOptionHtml("0930", "9:30 am", stime)
 
				 + genOptionHtml("1000", "10:00 am", stime) + genOptionHtml("1030", "10:30 am", stime)
 
				 + genOptionHtml("1100", "11:00 am", stime) + genOptionHtml("1130", "11:30 am", stime)
 
@@ -127,65 +128,67 @@ var sectionsOfClass = new Array();
 
		    {
 
			var etime_end = etime.substr(2);
 
			if (etime_end != '50' && etime_end != '20')
 
			    result = result + genOptionHtml(etime, prettyTime(etime), etime);
 
		    }
 

	
 
		result = result + '</select></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][0]" value="1" ' + (days.m ? 'checked="checked"' : '') + ' /></td> \
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][1]" value="1" ' + (days.t ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][2]" value="1" ' + (days.w ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][3]" value="1" ' + (days.h ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" ' + (days.f ? 'checked="checked"' : '') + ' /></td>';
 
		result = result + '<td><div class="deleteSection"><input type="button" value="x" class="gray" /></div></td><td></td></tr>';
 
		result = result + '<td><div class="deleteSection"><input type="button" value="x" class="gray" /></div></td><td>' 
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][location]" value="' + location + '" />'+ '</td></tr>';
 
		return result;
 
	}
 

	
 
/**
 
 * 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 a section to a class
 
        //--------------------------------------------------
 
	function add_section_n(cnum,name,synonym,stime,etime,days,prof)
 
/**
 
 * \brief
 
 *   Add a section to a class.
 
 */
 
function add_section_n(cnum, name, synonym, stime, etime, days, prof, location)
 
	{
 
		 jQuery('.pclass'+cnum).after(genSectionHtml_n(cnum,name,synonym,stime,etime,days,prof));
 
    jQuery('.pclass'+cnum).after(genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location));
 
		 sectionsOfClass[cnum] ++;
 
	}
 
        function add_section(cnum)
 
	{
 
	    return add_section_n(cnum, '', '', '', '', {'m':false, 't':false, 'w':false, 'h':false, 'f':false}, '');
 
    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;
 
    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);
 
	    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)
 
	{
 
		sectionsOfClass[classNum] = 0; // Initialize at 0
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + ' pclass' + classNum + '"><td><input type="text" class="className required defText className'+classNum+'" title="Class Name" name="postData[' + classNum + '][name]" value="' + name + '" /></td><td colspan="9"></td><td class="tdInput"><div class="addSection"><input type="button" value="Add Section" class="gray" /></div></td><td class="tdInput"><div class="deleteClass"><input type="button" value="Remove" class="gray" /></div></td></tr>');
 
		jQuery('.className' + classNum).autocomplete({
 
			source: "auto.php",
0 comments (0 inline, 0 general)