Changeset - 3f6590312102
[Not reviewed]
default
0 7 0
Nathan Brink (binki) - 15 years ago 2011-02-05 21:29:32
ohnobinki@ohnopublishing.net
Add Saturday support, but hide it on the input page.
7 files changed with 76 insertions and 26 deletions:
0 comments (0 inline, 0 general)
inc/class.schedule.php
Show inline comments
 
@@ -276,48 +276,67 @@ class Schedule
 
      echo '    jQuery("#sharedialog").dialog({ modal: true, width: 550, resizable: false, draggable: false, autoOpen: false });';
 
      echo '    jQuery("#share").click( function() {
 
                  jQuery("#sharedialog").dialog("open");
 
                });';
 
      echo '    jQuery(\'#printItems\').click( function() {
 
		  window.location = "'.$_SERVER['SCRIPT_NAME'].'?s='.$this->id_get().'&print=" + (jQuery(\'#tabs\').tabs(\'option\',\'selected\') + 1);
 
	        });
 
	        jQuery(\'#cancelItems\').click( function() {
 
		  jQuery(\'#selectItemsInput\').hide();
 
	        });';
 
      echo '  });
 
            </script>';
 

	
 
      echo '<div id="sharedialog" title="Share Schedule"><p>You can share your schedule with the URL below:</p><p>' . htmlentities($outputPage->gen_share_url($this->id_get())) . '</p></div>' . "\n";
 
      echo '<p><a href="input.php?s='.$this->id.'">Edit</a> :: <span id="printItems"><a href="#">Print</a></span> :: <span id="share"><a href="#">Share</a></span> :: <a href="input.php">Home</a></p>'. "\n";
 
      echo '<p class="centeredtext">Having problems? <a href="feedback.php">Let us know</a>.</p>' . "\n";
 
      echo '<p class="centeredtext graytext"><em>Keyboard Shortcut: Left and right arrow keys switch between schedules</em></p>' . "\n";
 

	
 
    }		
 

	
 
    echo "\n";
 

	
 
    if($this->nPermutations > 0)
 
      {
 
	/*
 
	 * Figure out if we have to deal with Saturday and then deal
 
	 * with it.
 
	 */
 
	$max_day_plusone = 5;
 
	$have_saturday = FALSE;
 
	foreach ($this->courses as $course)
 
	  {
 
	    for ($si = 0; $si < $course->getnsections(); $si ++)
 
	      foreach ($course->getSection($si)->getMeetings() as $meeting)
 
		if ($meeting->getDay(5))
 
		  {
 
		    $max_day_plusone = 6;
 
		    $have_saturday = TRUE;
 
		    break;
 
		  }
 
	    if ($have_saturday)
 
	      break;
 
	  }
 

	
 
        echo '<div id="regDialog" title="Registration Codes"><p>Enter these codes into your school\'s online course registration system to register for classes:</p><div id="regDialogList"></div></div>';
 
	echo '<div id="tabs">' . "\n" .
 
               '<div id="show-box" class="show-buttons">
 
                  <form action="#"><p class="nospace">
 
                    <label><strong>Display:</strong></label>
 
                    <input id="show-prof" name="show-prof" type="checkbox" checked="checked" /><label for="show-prof">Professor</label>
 
                    <input id="show-location" name="show-location" type="checkbox" /><label for="show-location">Room</label>
 
                    <input id="show-synonym" name="show-synonym" type="checkbox" /><label for="show-synonym">Synonym</label>
 
                    <span id="regCodes"><label><a href="#">Registration Codes</a></label></span></p>
 
                  </form>';
 

	
 
          echo '</div> <!-- id="show-box" -->'
 
	     . '<div id="the-tabs"><ul>' . "\n";
 
			
 
	for($nn = $first_permutation + 1; $nn <= $last_permutation; $nn++)
 
	  {
 
	    echo  "<li><a href=\"#tabs-" . $nn . "\">&nbsp;" . $nn . "&nbsp;</a></li>\n";
 
	  }
 
			
 
	echo "    </ul></div>\n  \n";
 

	
 
	echo "    <div id=\"pagers\">\n";
 
	/* Previous button */
 
@@ -327,60 +346,63 @@ class Schedule
 
	/* Next button */
 
	if ($page + 1 < $npages)
 
	  echo '      <div id="pager-next" class="pager right"><a href="' . htmlentities($this->url($this->id, $page + 1)) . '">Next &raquo;</a></div>' . "\n";
 
	echo "    </div> <!-- id=\"pagers\" -->\n";
 

	
 

	
 
	echo "  <div class=\"scroller\">\n"
 
	  . "    <div class=\"scontent\">\n";
 
		
 
	for($i = $first_permutation; $i < $last_permutation; $i++)
 
	  {
 
             $syns = array();
 
	     echo  '      <div class="section" id="tabs-' . ($i+1) . "\">\n";
 
  
 
	    // Beginning of table
 
	    echo "        <table style=\"empty-cells:show;\" border=\"1\" cellspacing=\"0\">\n";
 
				
 
	    // Header row
 
	    echo "          <tr>\n"
 
	      . '            <td class="none permuteNum">' . ($i + 1) . "</td>\n"
 
	      . "            <td class=\"day\">Monday</td>\n"
 
	      . "            <td class=\"day\">Tuesday</td>\n"
 
	      . "            <td class=\"day\">Wednesday</td>\n"
 
	      . "            <td class=\"day\">Thursday</td>\n"
 
	      . "            <td class=\"day\">Friday</td>\n"
 
	      . "          </tr>\n";
 
	      . "            <td class=\"day\">Friday</td>\n";
 
	    if ($have_saturday)
 
	      echo "            <td class=\"day\">Saturday</td>\n";
 
	    echo "          </tr>\n";
 

	
 
	    $last_meeting = array();
 
	    $rowspan = array(0, 0, 0, 0, 0);
 
	    $rowspan = array(0, 0, 0, 0, 0, 0);
 
	    for($r = 0; $r < (count($time)-1); $r++)
 
	      {
 

	
 
		echo "          <tr>\n"
 
		  . "            <td class=\"time\">" . $this->prettyTime($time[$r]) . "</td>\n";
 

	
 
		for($dayLoop = 0; $dayLoop < 5; $dayLoop++)
 
		/* currently, 0-5 = monday-saturday */
 
		for($dayLoop = 0; $dayLoop < $max_day_plusone; $dayLoop++)
 
		{
 
		  /* Makes sure there is not a class already in progress */
 
		  if($rowspan[$dayLoop] <= 0)
 
		    {
 
		      for($j = 0; $j < count($this->courses); $j++)
 
			{
 
			  $class = $this->courses[$j];
 
			  $section_index = $this->storage[$i][$j];
 
			  $section = $class->getSection($section_index);
 
				  /* iterate through all of a class's meeting times */
 
				  $meetings = $section->getMeetings();
 

	
 
				  /* find any meeting which are going on at this time */
 
				  $current_meeting = NULL;
 
				  foreach ($meetings as $meeting)
 
				    {
 
				      if ($meeting->getDay($dayLoop)
 
					  && $meeting->getStartTime() >= $time[$r]
 
					  && $meeting->getStartTime() < $time[$r+1])
 
					{
 
					  $current_meeting = $meeting;
 
					}
 
				    }
 
				  
inc/class.section.php
Show inline comments
 
@@ -167,52 +167,52 @@ class Section
 
   */
 
  public static function parse($section_spec)
 
  {
 
    $ret = array();
 

	
 
    $section_spec = trim($section_spec);
 
    if (!preg_match(';([a-zA-Z]+)[^0-9]*;', $section_spec, $dept_matches))
 
      return $ret;
 

	
 
    /*
 
     * remove away the already-parsed stuff, including gunk between the
 
     * dept and the course num.
 
     */
 
    $section_spec = trim(substr($section_spec, strlen($dept_matches[0])));
 
    $ret['department'] = strtoupper($dept_matches[1]);
 

	
 
    if (!preg_match(';([0-9a-zA-Z]+)[^a-zA-Z0-9]*;', $section_spec, $course_matches))
 
      return $ret;
 

	
 
    /* skip gunk */
 
    $section_spec = trim(substr($section_spec, strlen($course_matches[0])));
 
    $ret['course'] = strtoupper($course_matches[1]);
 

	
 
    /*
 
     * we accept _either_ alphabetic section _or_ numeric section (the
 
     * latter is for cedarville, particulaly)
 
     * we accept fully alphanumeric section identifiers. ccbcmd uses
 
     * these amazingly.
 
     */
 
    if (!preg_match(';([0-9]+|[a-zA-Z]+);', $section_spec, $section_matches))
 
    if (!preg_match(';([a-zA-Z0-9]+);', $section_spec, $section_matches))
 
      return $ret;
 

	
 
    $ret['section'] = strtoupper($section_matches[1]);
 

	
 
    return $ret;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get arrays of information needed by the AJAX stuff.
 
   *
 
   * \return
 
   *   An array of arrays that should be merged with the return value
 
   *   of other Section::to_json_array() calls.
 
   */
 
  public function to_json_arrays()
 
  {
 
    $json_arrays = array();
 

	
 
    foreach ($this->meetings as $meeting)
 
      {
 
	$json_array = array('section' => $this->letter,
 
			    'prof' => $this->prof,
 
			    'synonym' => $this->synonym,
inc/class.section_meeting.inc
Show inline comments
 
@@ -60,66 +60,66 @@ class SectionMeeting
 
   *   school's notation.
 
   */
 
  public function __construct($days, $time_start, $time_end, $location = NULL, $type = 'lecture')
 
  {
 
    $this->days_set($days);
 

	
 
    $this->time_start = $time_start;
 
    $this->time_end = $time_end;
 

	
 
    $this->location = $location;
 

	
 
    $this->type = $type;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Take a days of week string and store it into our $days of week array.
 
   *
 
   * \param $days_str
 
   *   The days of the week in a string format. One char per
 
   *   day. Mon-Fri is represented with 'm', 't', 'w', 'h', 'f'.
 
   */
 
  private function days_set($days_str)
 
  {
 
    $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE);
 
    $this->days = array(0 => FALSE, 1 => FALSE, 2 => FALSE, 3 => FALSE, 4 => FALSE, 5 => FALSE);
 

	
 
    $days_str_strlen = strlen($days_str);
 
    for ($i = 0; $i < $days_str_strlen; $i ++)
 
      $this->days[self::day_atoi($days_str[$i])] = TRUE;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Convert a day letter to a day numeral.
 
   *
 
   * Works fine if you give the numeral as well.
 
   */
 
  private static function day_atoi($day_c)
 
  {
 
    static $day_atoi = array('m' => 0, 't' => 1, 'w' => 2, 'h' => 3, 'f' => 4,
 
			     'M' => 0, 'T' => 1, 'W' => 2, 'H' => 3, 'F' => 4,
 
			       0 => 0,   1 => 1,   2 => 2,   3 => 3,   4 => 4);
 
    static $day_atoi = array('m' => 0, 't' => 1, 'w' => 2, 'h' => 3, 'f' => 4, 's' => 5,
 
			     'M' => 0, 'T' => 1, 'W' => 2, 'H' => 3, 'F' => 4, 'S' => 5,
 
			      0  => 0,  1  => 1,  2  => 2,  3  => 3,  4  => 4,  5  => 5);
 

	
 
    return $day_atoi[$day_c];
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Determine whether or not this class meeting time meets on a
 
   *   specified day of the week or not.
 
   *
 
   * \param $day
 
   *   The letter or numeral of the day to retrieve.
 
   * \return
 
   *   TRUE if this section meeting meets on that day. FALSE
 
   *   otherwise.
 
   */
 
  public function getDay($day)
 
  {
 
    return $this->days[self::day_atoi($day)];
 
  }
 

	
 
  /**
 
   * \return
 
   *   This SectionMeeting's location or NULL if none is defined.
 
   */
 
@@ -166,64 +166,64 @@ class SectionMeeting
 
   *
 
   * \param $that
 
   *   The other section for which I should check for conflicts.
 
   * \return
 
   *   TRUE if there is a conflict, FALSE otherwise.
 
   */
 
  public function conflictsWith(SectionMeeting $that)
 
  {
 
    /*
 
     * The two sections meetings can't conflict if the start/end times
 
     * don't overlap. Also, use >= or <= here so that one can say ``I
 
     * have gym from 10 through 11 and then latin from 11 though 12''.
 
     */	
 
    if ($this->getStartTime() >= $that->getEndTime()
 
	|| $this->getEndTime() <= $that->getStartTime())
 
      {
 
	return FALSE;
 
      }
 

	
 
    /*
 
     * Now we know that the sections meetings overlap in start/end
 
     * times. But if they don't both meet on the same day at least
 
     * once, they don't conflict.
 
     */
 
    for ($day = 0; $day < 5; $day ++)
 
    for ($day = 0; $day < 6; $day ++)
 
      {
 
	if ($this->getDay($day) && $that->getDay($day))
 
	  return TRUE;
 
      }
 

	
 
    /*
 
     * The sections meetings don't both share a day of the week.
 
     */
 
    return FALSE;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Return an array of JSON keys specific to this section meeting
 
   *   time.
 
   *
 
   * Currently, the AJAX UI doesn't recognize that a given section may
 
   * have multiple meeting times. Thus, we simulate this by having
 
   * multiple instances of the same section but just with different
 
   * times in the UI.
 
   */
 
  public function to_json_array()
 
  {
 
    static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f');
 
    static $daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f', 5 => 's');
 

	
 
    $json_array = array(
 
			'time_start' => $this->time_start,
 
			'time_end' => $this->time_end,
 
			'days' => array(),
 
			'location' => $this->location,
 
			'type' => $this->type,
 
			);
 

	
 
    for ($day = 0; $day < 5; $day ++)
 
    for ($day = 0; $day < 6; $day ++)
 
      $json_array['days'][$daymap[$day]] = $this->getDay($day);
 

	
 
    return $json_array;
 
  }
 
}
input.php
Show inline comments
 
@@ -93,97 +93,116 @@ if (!empty($_REQUEST['selectschool'])
 
  Choose the school you attend from the list below. <strong>If you cannot
 
  find your school</strong>, you may proceed using
 
  the <a href="<?php echo $next_page . (strpos($next_page, '?') === FALSE ? '?' : '&amp;'); ?>school=default">generic
 
  settings</a>.
 
</p>
 
<?php
 
    $inputPage->showSchools($next_page);
 
    $inputPage->foot();
 
    exit;
 
  }
 

	
 
$inputPage->showSavedScheds($_SESSION);
 
?>
 
<p>
 
  Welcome to SlatePermutate<?php $inputPage->addressStudent(', ', '', FALSE); ?>!
 
  <?php if (school_has_auto($inputPage->get_school())): ?>
 
  To get started, enter in some a course identifier (e.g., <em>
 
  <?php echo school_example_course_id($inputPage->get_school()); ?></em>)
 
  and click the autosuggestion to automatically load available sections
 
  for each class.
 
  <?php else: ?>
 
  To get started, enter a course number and add some sections to it.
 
  Then specify each section's letter/number and what times it meets,
 
  add more courses, and click &ldquo;Find a Schedule&rdquo;.
 
  <!--'-->
 
  <?php endif; ?>
 
</p>
 

	
 
<form method="post" action="process.php" id="scheduleForm">
 
<p class="nospace"><label>Schedule Name</label><br />
 
  <input id="scheduleName" style="margin-bottom: 1em;" class="defText required" type="text" size="25" title="Spring 2011" name="postData[name]" <?php if ($sch) echo 'value="' . htmlentities($sch->getName(), ENT_QUOTES) . '"'; /*"*/ ?> />
 
</p>
 

	
 
<table id="container">
 
  <tr>
 
    <td>
 
      <table id="jsrows">
 
	<!-- Allow CSS to apply to entire rows at a time. -->
 
	<colgroup>
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col />
 
	  <col class="saturday" />
 
	  <col />
 
	  <col />
 
	</colgroup>
 
        <!-- Header -->
 
        <tr>
 
          <td>Class ID</td>
 
          <td class="center" id="letterNumber">Section</td>
 
          <td class="center">Prof</td>
 
          <td class="center">Start Time</td>
 
          <td class="center">End Time</td>
 
          <td class="center">M</td>
 
          <td class="center">Tu</td>
 
          <td class="center">W</td>
 
          <td class="center">Th</td>
 
          <td class="center">F</td>
 
	  <td class="center">S</td>
 
          <td class="center"></td>
 
          <td class="center"></td>
 
        </tr>
 
      </table>
 
    </td>
 
  </tr>
 
  <tr>
 
    <td><span class="gray" style="padding: 0 3.5em 0 3.5em;" id="addclass">Add Class</span></td>
 
  </tr>
 
</table>
 

	
 
<div class="paddingtop">
 
  <input class="green" style="margin:0;padding:0;" type="submit" value="Find a schedule" />
 
</div>
 

	
 
</form>
 

	
 
<p>&nbsp;<br /><br /><br /></p>
 
<?php 
 

	
 
/* Show/hide Advanced Options: <p><span id="showadvanced" style="margin-left: 1em;"><a href="#">Advanced</a></span></p> */ 
 

	
 
$inputPage->showSchoolInstructions();
 
$inputPage->foot();
 

	
 
function input_class_js(Course $class, $whitespace = '  ')
 
{
 
  $js = $whitespace . 'class_last = add_class_n(\'' . htmlentities($class->getName(), ENT_QUOTES) . "');\n";
 

	
 
  $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)
 
	{
 
	  $js .= $whitespace . '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))) . ', \''
 
	    . json_encode(array('m' => $meeting->getDay(0), 't' => $meeting->getDay(1), 'w' => $meeting->getDay(2), 'h' => $meeting->getDay(3), 'f' => $meeting->getDay(4),
 
				's' => $meeting->getDay(5))) . ', \''
 
	    . htmlentities($section->getProf(), ENT_QUOTES) . '\', \''
 
	    . htmlentities($meeting->getLocation(), ENT_QUOTES) . '\',\''
 
	    . htmlentities($meeting->type_get(), ENT_QUOTES) . "');\n";
 
	}
 
    }
 

	
 
  return $js;
 
}
process.php
Show inline comments
 
@@ -3,85 +3,86 @@
 
 * Copyright 2010 Nathan Gelderloos, Ethan Zonca, Nathan Phillip Brink
 
 *
 
 * This file is part of SlatePermutate.
 
 *
 
 * SlatePermutate is free software: you can redistribute it and/or modify
 
 * it under the terms of the GNU Affero General Public License as published by
 
 * the Free Software Foundation, either version 3 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * SlatePermutate is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU Affero General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
require_once('inc/schedule_store.inc');
 
require_once('inc/class.page.php');
 
include_once 'inc/class.schedule.php';
 
include_once('inc/class.course.inc');
 
include_once 'inc/class.section.php';
 

	
 
// Converts a 5-element day array into a string.
 
// Converts a 6-element day array into a string.
 
// Supports multiple modes, prettiness, and searching for different indicators
 
function arrayToDays($array, $mode = 'num', $pretty = false, $key = 1) {
 
	$outString = '';
 
	switch($mode)
 
	  {
 
		case 'short':
 
			$days = array('Mon','Tue','Wed','Thur','Fri');
 
			$days = array('Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat');
 
			break;
 
		case 'long':
 
			$days = array('Monday','Tuesday','Wednesday','Thursday','Friday');
 
			$days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
 
			break;
 
		case 'num':
 
			$days = array('1','2','3','4','5');
 
			break;
 
	  case 'alpha':
 
	    $days = array('m', 't', 'w', 'h', 'f');
 
	    $days = array('m', 't', 'w', 'h', 'f', 's');
 
	    break;
 
		default:
 
			$outString = 'Invalid mode passed to arrayToDays()!';
 
			return $outString;
 
	}
 
	if(count($array) > 1){
 
		for($i=0; $i<=4; $i++)	{
 
		for($i = 0; $i < 6; $i ++)
 
		{
 
			if(isset($array[$i]) && $array[$i] == $key){
 
				$outString .= $days[$i];
 
				if($pretty)
 
					$outString .= ', ';
 
			}
 
		}
 
		if($pretty){
 
			$outString = substr($outString,0,strlen($outString) - 2); // Remove last comma and space
 
			$outString = substr($outString,0, strrpos( $outString, ' ')) . ' and' . substr($outString, strrpos( $outString, ' '), strlen($outString));
 
		}
 
	}
 
	else {
 
		for($i=0; $i<=4; $i++)
 
		for($i=0; $i < 6; $i++)
 
			if(isset($array[$i]))
 
				$outString = $days[$i];
 
	}
 
	return $outString;
 
}
 

	
 
function prettyTime($time){
 
	return substr($time,0,strlen($time)-2) . ":" . substr($time,strlen($time)-2, strlen($time));
 
}
 

	
 
/*
 
 * The below code relies on sessions being started already.
 
 */
 
page::session_start();
 

	
 
$DEBUG = FALSE;
 
if (isset($_GET['debug']))
 
  $DEBUG = $_GET['debug'];
 

	
 
$schedule_store = schedule_store_init();
 

	
 
if(!$DEBUG)
 
  {
 
    $s = FALSE;
 
@@ -117,50 +118,51 @@ if(!$DEBUG)
 
    else
 
      {
 
	/*
 
	 * we probably have input from the user and should interpret
 
	 * it as a schedule to permutate. Then we should redirect the
 
	 * user to the canonical URL for that schedule.
 
	 */
 
		$allClasses = new Schedule($_POST['postData']['name']);
 
	
 
		foreach($_POST['postData'] as $class)
 
		{
 
		  /*
 
		   * Only add classes if the user added at least one
 
		   * 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->addCourse($class['name']);
 
		
 
				foreach($class as $section)
 
				  /* Skip the section name, which isn't a section */
 
					if(is_array($section))
 
					{
 
					  {error_log(print_r($section['days'], TRUE));
 
					  $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']);
 
					  error_log(arrayToDays($section['days'], 'alpha'));
 
					}
 
			}
 
		}
 
		$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)
 
		  $process_php_s = 'process.php?s=';
 
		page::redirect($process_php_s . $schedule_id);
 
		exit;
 
      }
 
  }
 
else
 
  {
 
	echo '<pre>DEBUG OUTPUT: <br /><br />';
 
	foreach($_POST['postData'] as $class) {
 
		echo 'Class: ' . $class['name'] . '<br />';
 
		foreach($class as $section)
 
			if(is_array($section))
scripts/scheduleInput.js
Show inline comments
 
@@ -171,53 +171,54 @@ function genSectionHtml_n(cnum, name, sy
 
				 + genOptionHtml("0720", "7:20 am", etime) + genOptionHtml("0750", "7:50 am", etime)
 
				 + genOptionHtml("0820", "8:20 am", etime) + genOptionHtml("0850", "8:50 am", etime)
 
				 + genOptionHtml("0920", "9:20 am", etime) + genOptionHtml("0950", "9:50 am", etime)
 
				 + genOptionHtml("1020", "10:20 am", etime) + genOptionHtml("1050", "10:50 am", etime)
 
				 + genOptionHtml("1120", "11:20 am", etime) + genOptionHtml("1150", "11:50 am", etime)
 
				 + genOptionHtml("1220", "12:20 pm", etime) + genOptionHtml("1250", "12:50 pm", etime)
 
				 + genOptionHtml("1320", "1:20 pm", etime) + genOptionHtml("1350", "1:50 pm", etime)
 
				 + genOptionHtml("1420", "2:20 pm", etime) + genOptionHtml("1450", "2:50 pm", etime)
 
				 + genOptionHtml("1520", "3:20 pm", etime) + genOptionHtml("1550", "3:50 pm", etime)
 
				 + genOptionHtml("1620", "4:20 pm", etime) + genOptionHtml("1650", "4:50 pm", etime)
 
				 + genOptionHtml("1720", "5:20 pm", etime) + genOptionHtml("1750", "5:50 pm", etime)
 
				 + genOptionHtml("1820", "6:20 pm", etime) + genOptionHtml("1850", "6:50 pm", etime)
 
				 + genOptionHtml("1920", "7:20 pm", etime) + genOptionHtml("1950", "7:50 pm", etime)
 
				 + genOptionHtml("2020", "8:20 pm", etime) + genOptionHtml("2050", "8:50 pm", etime)
 
		    + genOptionHtml("2120", "9:20 pm", etime);
 

	
 
		if (etime.length > 0)
 
		    {
 
			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][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>';
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" ' + (days.f ? 'checked="checked"' : '') + ' /></td>\
 
			<td class="cbrow"><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][5]" value="1" ' + (days.s ? 'checked="checked"' : '') + ' /></td>';
 
		result = result + '<td class="removeCell"><div class="deleteSection"><input type="button" value="x" class="gray" /></div></td><td class="emptyCell">' 
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][location]" value="' + location + '" />'
 
		    + '<input type="hidden" name="postData[' + cnum + '][' + snum + '][type]" value="' + type + '" />'
 
		    + '</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 tooltips for user guidance */
 
function addTips()
 
{
 
  var tr = jQuery('tr');
 
@@ -232,78 +233,78 @@ function addTips()
 
        radius: 4,
 
        color: '#333'
 
      },
 
      name: 'dark',
 
      tip: true
 
    },
 
    show: { effect: { type: 'fade', length: 2000 } },
 
    show: { ready: true }, 
 
/*    hide: { when: { event: 'inactive' } }, */
 
    corner: { target: 'topMiddle', tooltip: 'bottomMiddle' },
 
  });
 
}
 

	
 
/**
 
 * \brief
 
 *   Add a section to a class.
 
 */
 
function add_section_n(cnum, name, synonym, stime, etime, days, prof, location, type)
 
{
 
    jQuery('.pclass'+cnum).after(genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location, type));
 
    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, s: 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, section.type);
 
	}
 
}
 

	
 
	//--------------------------------------------------
 
	// 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 class="nameTip"><input type="text" id="input-course-' + classNum + '" class="classRequired defText className'+classNum+' className" title="Class Name" name="postData[' + classNum + '][name]" value="' + name + '" /></td><td colspan="9"></td><td class="tdInput"><div class="addSection"><input type="button" value="+" class="gray" /></div></td><td class="tdInput"><div class="deleteClass"><input type="button" value="Remove" class="gray" /></div></td></tr>');
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + ' pclass' + classNum + '"><td class="nameTip"><input type="text" id="input-course-' + classNum + '" class="classRequired defText className'+classNum+' className" title="Class Name" name="postData[' + classNum + '][name]" value="' + name + '" /></td><td colspan="10"></td><td class="tdInput"><div class="addSection"><input type="button" value="+" class="gray" /></div></td><td class="tdInput"><div class="deleteClass"><input type="button" value="Remove" class="gray" /></div></td></tr>');
 

	
 
		var class_elem = jQuery('.className' + classNum);
 
		class_elem.autocomplete({ source: "auto.php" });
 
		class_elem.bind('autocompleteselect', {class_num: classNum, class_elem: class_elem},
 
			function(event, ui)
 
			    {
 
				if (!ui.item)
 
				    return;
 

	
 
				if (ui.item.value.indexOf('-') != -1)
 
				    {
 
					jQuery.ajax(
 
						    {
 
							url: 'auto.php',
 
							    data: {'getsections': 1, 'term': ui.item.value},
 
							    context: {'class_num': event.data.class_num},
 
							    success: function(data, textStatus, reqobj)
 
							    {
 
								var new_course_num;
 

	
 
								if (data.sections)
 
								    {
 
									add_sections(this.class_num, data);
 
									new_course_num = add_class();
styles/general.css
Show inline comments
 
@@ -179,48 +179,54 @@ td.center {
 
  border: 1px solid #999;
 
  text-align: center!important;
 
  background: #CCC!important;
 
  cursor:default;
 
}
 
.gray:hover {
 
  background: #DDD!important;
 
}
 

	
 
.green {
 
  border-radius: 5px;
 
  -moz-border-radius: 5px;
 
  -webkit-border-radius: 5px;
 
  border: 1px solid #999;
 
  text-align: center!important;
 
/*  background: #92a689!important; */
 
  background: #EEE;
 

	
 
  cursor:default;
 
}
 
.green:hover {
 
  background: #68a64a!important;
 
}
 

	
 
/* For now, hide Saturday on the input page even though it works perfectly fine */
 
.saturday
 
{
 
  /* http://www.w3.org/TR/CSS/tables.html#columns */
 
  visibility: collapse;
 
}
 

	
 
/* General Classes */
 

	
 
.block
 
{
 
    display: block;
 
}
 
.clear {
 
  clear: both;
 
}
 
.noborder {
 
  border: none!important;
 
}
 
.righttext {
 
  text-align: right;
 
}
 
.centeredtext {
 
  text-align: center;
 
}
 
.graytext {
 
  color: #999;
 
}
 
#sharedialog {
 
  display: none;
0 comments (0 inline, 0 general)