Changeset - 3a9abbabd125
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2010-10-18 18:36:05
ohnobinki@ohnopublishing.net
Fix up the javascript hack to use a prettier format (bug 49). Also, when clicking ``Add Section'', don't have the selected start/end time be a single colon -- select the empty time.
1 file changed with 52 insertions and 10 deletions:
0 comments (0 inline, 0 general)
scripts/scheduleInput.js
Show inline comments
 
@@ -95,15 +95,18 @@ var sectionsOfClass = new Array();
 
				 + genOptionHtml("1700", "5:00 pm", stime) + genOptionHtml("1730", "5:30 pm", stime)
 
				 + genOptionHtml("1800", "6:00 pm", stime) + genOptionHtml("1830", "6:30 pm", stime)
 
				 + genOptionHtml("1900", "7:00 pm", stime) + genOptionHtml("1930", "7:30 pm", stime)
 
				 + genOptionHtml("2000", "8:00 pm", stime) + genOptionHtml("2030", "8:30 pm", stime)
 
		    + genOptionHtml("2100", "9:00 pm", stime);
 

	
 
		var stime_end = stime.substr(2);
 
		if (stime_end != '00' && stime_end != '30')
 
		    result = result + genOptionHtml(stime, stime.substr(0, 2) + ':' + stime_end, stime);
 
		if (stime.length > 0)
 
		    {
 
			var stime_end = stime.substr(2);
 
			if (stime_end != '00' && stime_end != '30')
 
			    result = result + genOptionHtml(stime, prettyTime(stime), stime);
 
		    }
 

	
 
		result = result + '</select></td>\
 
			<td><select class="selectRequired" name="postData[' + cnum + '][' + snum + '][end]"><option value="none"></option>'
 
				 + 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)
 
@@ -117,15 +120,18 @@ var sectionsOfClass = new Array();
 
				 + 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);
 

	
 
		var etime_end = etime.substr(2);
 
		if (etime_end != '50' && etime_end != '20')
 
		    result = result + genOptionHtml(etime, etime.substr(0, 2) + ':' + etime_end, 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][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>\
 
@@ -211,16 +217,52 @@ function add_sections(cnum, data)
 
function add_class()
 
{
 
    return add_class_n('');
 
}
 

	
 

	
 
    //--------------------------------------------------
 
    // Items bound to pageload/events
 
    //--------------------------------------------------
 
    jQuery(document).ready(function() {
 
/**
 
 * \brief
 
 *   Render a slate_permutate-encoded time-of-day.
 
 *
 
 * \param time_str
 
 *   A four-character representation of a time of day based on a
 
 *   time's 24-hour representation.
 
 * \return
 
 *   A string representing the specified time.
 
 */
 
function prettyTime(time_str)
 
{
 
    var i_hour;
 
    var hour_str;
 
    var m;
 

	
 
    i_hour = time_str.substr(0, 2) * 1;
 
    if (i_hour <= 12)
 
	{
 
	    m = 'a';
 
	}
 
    else
 
	{
 
	    m = 'p';
 
	    i_hour -= 12;
 
	}
 
    hour_str = new String(i_hour);
 
    /* uncomment to have 08:01 instead of 8:01 */
 
    /*
 
    while (hour_str.length < 2)
 
	hour_str = '0' + hour_str;
 
    */
 

	
 
    return hour_str + ':' + time_str.substr(2) + ' ' + m + 'm';
 
}
 

	
 
//--------------------------------------------------
 
// Items bound to pageload/events
 
//--------------------------------------------------
 
jQuery(document).ready(function() {
 

	
 
	//--------------------------------------------------
 
	// Validates the form (pre-submission check)
 
	//--------------------------------------------------
 
		jQuery('#scheduleForm').validate({
 
			debug: false,
0 comments (0 inline, 0 general)