diff --git a/inc/class.page.php b/inc/class.page.php --- a/inc/class.page.php +++ b/inc/class.page.php @@ -1,20 +1,18 @@ var _gaq = _gaq || []; @@ -27,14 +25,6 @@ class page { })(); '; // Google analytics ga.js tracking code - public $tablestripe = ''; - private $title = ''; // Title of page private $scripts = ''; // Scripts to include on page @@ -43,6 +33,10 @@ class page { $this->scripts .= $nscripts; if($ntitle != "NOHEAD") $this->head(); + + $headCode['jquery'] = ''; + $headCode['jValidate'] = ''; + $headCode['schedInput'] = ''; } private function top(){ @@ -54,38 +48,33 @@ class page { // Public functions/vars - public function head(){ + private function head(){ session_start(); - - // @TODO: Add capability to load additional javascripts and stylesheets in array form - $this->pageGenTime = round(microtime(), 3); echo 'doctype . '> htmlargs . '> ' . $this->title . ' :: ' . $this->base_title . ' - - '; + '; - echo $this->scripts; - echo ' + // Write out all passed scripts + foreach ($this->scripts as $script) + echo $headCode[$script]; + + echo ' bodyargs.' >'; echo $this->top(); // Write out top } - public function foot(){ echo ''; $this->pageGenTime = round(microtime(), 3); - echo ''; + echo ''; echo $this->trackingcode; echo ''; } - public function secondsToCompound($seconds) { $ret = ""; $hours = intval(intval($seconds) / 3600); diff --git a/input.php b/input.php --- a/input.php +++ b/input.php @@ -6,279 +6,13 @@ include_once 'errors.php'; include_once 'class.schedule.php'; include_once 'class.class.php'; include_once 'class.section.php'; -?> - - - - Scheduler - - - - - - - - - - - - - - - -
-

+

0){ @@ -349,23 +83,6 @@ if(isset($_SESSION['saved']) && count($_ already populated as soon as they are added). -

- - - - - - +foot(); +?> \ No newline at end of file diff --git a/scripts/scheduleInput.js b/scripts/scheduleInput.js new file mode 100644 --- /dev/null +++ b/scripts/scheduleInput.js @@ -0,0 +1,183 @@ + /* Set all default error messages to this */ + jQuery.each(jQuery.validator.messages, function(i) { + jQuery.validator.messages[i] = "

Please fill the field

"; + }); + + jQuery.validator.addMethod( + "selectNone", + function(value, element) { + if (element.value == "none") + { + return false; + } + else return true; + }, + "

Please select a time

" + ); + +/* Doesn't work right now: */ /* + jQuery.validator.addMethod( + "daysRequired", + function(value, element) { + var numChecked = 0; + jQuery(document).find('.daysRequire').each(function () { + jQuery('#scheduleForm').append('

Found something!

'); + if(this.value != "none") + numChecked++; + }); + jQuery('#scheduleForm').append('

Finished each loop, found ' + numChecked + ' checked boxes

'); + + if (numChecked >= 1) + { + return false; + } + else return true; + }, + "

Please select one or more days!.

" + ); +*/ + + jQuery.validator.addClassRules("selectRequired", { + selectNone: true + }); + + jQuery.validator.addClassRules("daysRequire", { + daysRequired: true + }); + + jQuery(document).ready(function() { + //-------------------------------------------------- + // Validates the form (pre-submission check) + //-------------------------------------------------- + jQuery('#scheduleForm').validate({ + debug: false, + }); + + + var classNum = 0; + var sectionsOfClass = new Array(); // holds number of sections for each class + + //-------------------------------------------------- + // Returns the common inputs for each new section. + //-------------------------------------------------- + function getCommonInputs(cnum) { + var snum = sectionsOfClass[cnum]; + + var result = '\ + \ + \ + \ + \ + \ + \ + \ + \ + '; + + return result; + } + + //-------------------------------------------------- + // Adds a new class to the input. + //-------------------------------------------------- + function addRow(){ + sectionsOfClass[classNum] = 0; // This is class 0, initialize at 0 + jQuery('#jsrows').append('' + getCommonInputs(classNum) + '
'); + classNum++; + }; + + addRow(); // Add initial row + + //-------------------------------------------------- + // Adds a new class when the add class button is + // clicked. + //-------------------------------------------------- + jQuery('#classage').click(function() { + addRow(); + }); + + //-------------------------------------------------- + // Deletes the selected class from input. + //-------------------------------------------------- + jQuery('.deleteClass').live('click', function() { + jQuery('.class'+ jQuery(this).parent().parent().attr("title")).remove(); + }); + + //-------------------------------------------------- + // Deletes the selected section from the input. + //-------------------------------------------------- + jQuery('.deleteSection').live('click', function() { + sectionsOfClass[jQuery(this).parent().parent().attr("title")]--; // TODO: this only decreases the number of classes, so php should loop until this number of classes is found in the array + jQuery(this).parent().parent().remove(); + }); + + //-------------------------------------------------- + // Adds a section to the selected class. + //-------------------------------------------------- + jQuery('.addSection').live('click', function() { + sectionsOfClass[jQuery(this).parent().parent().attr("title")]++; // Increases sectionsOfClass[classNum] + jQuery(this).parent().parent().after('' + getCommonInputs(jQuery(this).parent().parent().attr("title")) + '
'); + }); + + //-------------------------------------------------- + // Resets the form + //-------------------------------------------------- + jQuery('#reset').click(function() { + jQuery('#scheduleForm').resetForm(); + }); + + //-------------------------------------------------- + // Default text stuff + //-------------------------------------------------- + jQuery(".defText").focus(function(srcc) + { + if (jQuery(this).val() == jQuery(this)[0].title) + { + jQuery(this).removeClass("defaultTextActive"); + jQuery(this).val(""); + } + }); + jQuery(".defText").blur(function() + { + if (jQuery(this).val() == "") + { + jQuery(this).addClass("defaultTextActive"); + jQuery(this).val($(this)[0].title); + } + }); + jQuery(".defText").blur(); + +}); + diff --git a/styles/general.css b/styles/general.css --- a/styles/general.css +++ b/styles/general.css @@ -3,12 +3,54 @@ margin:auto; font-family: sans-serif; } - #header { - text-align: left; - background: rgb(220,220,220); /* IE fallback */ - background: rgba(200,200,200, .3); - } - #footer { - text-align: right; - background: rgb(220,220,220); /* IE fallback */ - background: rgba(200,200,200, .3); + #savedBox { + width: 15em; + padding: 1em; + border: 1px solid #000; + float:right; + background: #DDD; + font-size: .8em; + } + #header { + text-align: left; + background: rgb(220,220,220); /* IE fallback */ + background: rgba(200,200,200, .3); + } + #footer { + text-align: right; + background: rgb(220,220,220); /* IE fallback */ + background: rgba(200,200,200, .3); + } + .defaultText { + width: 300px; } + .defaultTextActive { + color: #a1a1a1; + font-style: italic; + } + .error { + color: #F00; /* For validation errors */ + } + .error p { + padding: 0; + margin: 0; + font-size: .7em; + } + td.center { + text-align:center; + } + .section:nth-child(even) { + background: #DDDDDD; + } + .none { + background: #fff; + } + .class { + background: #99FF99; + } + #classage { + float:left; + } + .paddingtop { + padding: .5em; + padding-top: .8em; + }