Files
@ d0b954ceb988
Branch filter:
Location: SlatePermutate/input.php - annotation
d0b954ceb988
12.5 KiB
text/x-php
Fixed tracking issues
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe fcd0768aa12d 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d fcd0768aa12d f13987338fbf 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf f13987338fbf 27edaecc0d90 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 f13987338fbf fcd0768aa12d f13987338fbf 9924f8d92ad6 5cce14d5f1c2 5cce14d5f1c2 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe fdf163d26e15 fdf163d26e15 fdf163d26e15 fdf163d26e15 fdf163d26e15 27edaecc0d90 27edaecc0d90 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 185eb297fcfe 27edaecc0d90 185eb297fcfe 27edaecc0d90 185eb297fcfe 7ad078f11fd8 | <?php
session_start();
include_once 'errors.php';
include_once 'class.schedule.php';
include_once 'class.class.php';
include_once 'class.section.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Scheduler</title>
<style type="text/css">
body {
width: 80%;
margin:auto;
font-family: sans-serif;
}
.defaultText {
width: 300px; }
.defaultTextActive {
color: #a1a1a1;
font-style: italic;
}
#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);
}
.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;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript" charset="utf-8">
google.load("jquery", "1.3.2");
google.load("jqueryui", "1.7.2");
</script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.pack.js"></script>
<script type="text/javascript">
/* Set all default error messages to this */
jQuery.each(jQuery.validator.messages, function(i) {
jQuery.validator.messages[i] = "<p class=\"error\">Please fill the field</p>";
});
jQuery.validator.addMethod(
"selectNone",
function(value, element) {
if (element.value == "none")
{
return false;
}
else return true;
},
"<p class=\"error\">Please select a time</p>"
);
/* Doesn't work right now: */ /*
jQuery.validator.addMethod(
"daysRequired",
function(value, element) {
var numChecked = 0;
jQuery(document).find('.daysRequire').each(function () {
jQuery('#scheduleForm').append('<p>Found something!</p>');
if(this.value != "none")
numChecked++;
});
jQuery('#scheduleForm').append('<p>Finished each loop, found ' + numChecked + ' checked boxes</p>');
if (numChecked >= 1)
{
return false;
}
else return true;
},
"<p class=\"error\">Please select one or more days!.</p>"
);
*/
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 = '<td>\
<select name="postData[' + cnum + '][' + snum + '][letter]"><option value="-">-</option><option value="A">A</option><option value="B">B</option>\
<option value="C">C</option><option value="D">D</option><option value="E">E</option><option value="F">F</option><option value="G">G</option>\
<option value="H">H</option><option value="I">I</option><option value="J">J</option><option value="K">K</option></select></td>\
</select></td>\
<td><select class="selectRequired" name="postData[' + cnum + '][' + snum + '][start]"><option value="none"></option>\
<option value="700">7:00 am</option><option value="730">7:30 am</option>\
<option value="800">8:00 am</option><option value="830">8:30 am</option>\
<option value="900">9:00 am</option><option value="930">9:30 am</option>\
<option value="1000">10:00 am</option><option value="1030">10:30 am</option>\
<option value="1100">11:00 am</option><option value="1130">11:30 am</option>\
<option value="1200">12:00 pm</option><option value="1230">12:30 pm</option>\
<option value="1300">1:00 pm</option><option value="1330">1:30 pm</option>\
<option value="1400">2:00 pm</option><option value="1430">2:30 pm</option>\
<option value="1500">3:00 pm</option><option value="1530">3:30 pm</option>\
<option value="1600">4:00 pm</option><option value="1630">4:30 pm</option>\
<option value="1700">5:00 pm</option><option value="1730">5:30 pm</option>\
<option value="1800">6:00 pm</option><option value="1830">6:30 pm</option>\
<option value="1900">7:00 pm</option><option value="1930">7:30 pm</option>\
<option value="2000">8:00 pm</option><option value="2030">8:30 pm</option>\
<option value="2100">9:00 pm</option></select></td>\
<td><select class="selectRequired" name="postData[' + cnum + '][' + snum + '][end]"><option value="none"></option>\
<option value="720">7:20 am</option><option value="750">7:50 am</option>\
<option value="820">8:20 am</option><option value="850">8:50 am</option>\
<option value="920">9:20 am</option><option value="950">9:50 am</option>\
<option value="1020">10:20 am</option><option value="1050">10:50 am</option>\
<option value="1120">11:20 am</option><option value="1150">11:50 am</option>\
<option value="1220">12:20 pm</option><option value="1250">12:50 pm</option>\
<option value="1320">1:20 pm</option><option value="1350">1:50 pm</option>\
<option value="1420">2:20 pm</option><option value="1450">2:50 pm</option>\
<option value="1520">3:20 pm</option><option value="1550">3:50 pm</option>\
<option value="1620">4:20 pm</option><option value="1650">4:50 pm</option>\
<option value="1720">5:20 pm</option><option value="1750">5:50 pm</option>\
<option value="1820">6:20 pm</option><option value="1850">6:50 pm</option>\
<option value="1920">7:20 pm</option><option value="1950">7:50 pm</option>\
<option value="2020">8:20 pm</option><option value="2050">8:50 pm</option>\
<option value="2120">9:20 pm</option></select></td>\
<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][0]" value="1" /></td>\
<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][1]" value="1" /></td>\
<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][2]" value="1" /></td>\
<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][3]" value="1" /></td>\
<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" /></td>';
return result;
}
//--------------------------------------------------
// Adds a new class to the input.
//--------------------------------------------------
function addRow(){
sectionsOfClass[classNum] = 0; // This is class 0, initialize at 0
jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + '"><td><input type="text" class="required defText" title="Class Name" name="postData[' + classNum + '][name]" /></td>' + getCommonInputs(classNum) + '<td><div class="addSection"><input type="button" value="Add section" /></div></td><td><div class="deleteClass"><input type="button" value="Delete" /></div></td></tr>');
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('<tr class="section class' + jQuery(this).parent().parent().attr("title") + '"><td class="none"></td>' + getCommonInputs(jQuery(this).parent().parent().attr("title")) + '<td></td><td><div class="deleteSection"><input type="button" value="Delete" /></div></td></tr>');
});
//--------------------------------------------------
// 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();
});
</script>
</head>
<body>
<div id="header">
<h1>
<em>
SlatePermutate
</em>
- Scheduler
</h1>
</div>
<div id="content">
<p>
<?
if(isset($_SESSION['saved']) && count($_SESSION['saved']) > 0){
echo '<div id="savedBox" ><h3>Saved Schedules:</h3>';
foreach($_SESSION['saved'] as $key => $schedule){
$sch = unserialize($schedule);
echo "<a href=\"process.php?savedkey=$key\">#" . ($key + 1) . " - " . $sch->getName() . "</a> <em><a href=\"process.php?delsaved=$key\"><img src=\"images/close.png\" style=\"border:0;\" /></a></em><br />";
}
echo '</div>';
}
?>
</p>
<form method="post" action="process.php" id="scheduleForm">
<table id="jsrows">
<tr>
<td colspan="11" style="padding-bottom:2em;"><input id="scheduleName" class="defText" type="text" class="required" title="Schedule Name" name="postData[name]" />
<em>(For example: Fall <?php echo Date("Y"); ?>)</em>
</td>
</tr>
<!-- Header -->
<tr>
<td>Class</td>
<td class="center">Letter</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">Add</td>
<td class="center">Delete</td>
</tr>
</table>
<div class="paddingtop" id="classage"><input type="button" value="Add class" /></div>
<div class="paddingtop"><input style="float:left;" type="submit" value="Submit" /></div>
<p>
<br />
</p>
<div class="paddingtop" id="reset"><input style="float:left;" type="button" value="Reset" /></div>
</form>
<p>
<br />
</p>
<h3>TODO:</h3>
<ul>
<li>Form validation to ensure endtime is after starttime, at least one day is checked.</li>
<li>Check the saved schedule function. After input my default schedule, the output was the same
as that of the demo. However, when I went back and clicked the "Saved Schedule 0" link, there
were then 48 possible schedules. It seems that the classes were added twice for some reason.</li>
<li>Is there some way to automatically populate the fields when a user clicks on a saved schedule?
This would probably be very useful, in the case that the individual would like to edit a saved
schedule. Right now, it is only possible to edit the most previous schedule using the back button
in the browser and this still requires the user to add the classes and schedules (although they
already populated as soon as they are added).</li>
</ul>
</div>
<div id="footer">
<h5>
©
<?php echo Date("Y"); ?>
<a href="http://protofusion.org/~nathang/">
Nathan Gelderloos
</a>
<br />
with special thanks to
<a href="http://ethanzonca.com">
Ethan Zonca
</a>
</h5>
</div>
</body>
</html>
|