/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * @author Jonnie Spratley * @copyright 2009 * @version 1.0 * @classDescription Many form building functions * * Format for adding the id to options inputs * * input for type option number misc * txt_calendar_text_option_' + optionNumber + '_last * * Misc ID values are as follows: * * Name: * first * last * * Date: * dateY * dateM * dateD * * Time: * timeH * timeM * timeS * * Address: * addrStreet * addrStree2 * addrState * addrCity * addrZip * addrCountry * * Price: * priceD * priceC * * Email: * * Url: * url * * Phone: * phone1 * phone2 * phone3 * */ /** * Array of objects which hold * the following information about a * option when added to the form. * * name_id - The id of the form item added. * value_id - The id of the form item added. * type - The type of form item added. * */ var optionsCount = 0; var eventOptionsArray = new Array(); /** * I create and add a object to th options array. * @param {Object} optNum - the number option * @param {Object} optType - the type of option */ function jpsPushOption( optNum, optType ) { var obj = new Object(); obj.number = optNum; obj.type = optType; eventOptionsArray.push( obj ); } /** * I return the array of option objects */ function jpsGetOptions() { return eventOptionsArray; } /* =================================================================== * * All Event Option Creator Functions * =================================================================== */ /** * @param {Object} optionNumber */ function jps_createTextOption(optionNumber){ var _textOption = ''; _textOption += '<label for="txt_event_option_value_' + optionNumber + '" class="description" >Value</label>'; _textOption += '<div>'; _textOption += '<textarea id="txt_event_option_value_' + optionNumber + '" name="txt_event_option_value_' + optionNumber + '" class="element textarea medium"></textarea>'; _textOption += '</div>';; return _textOption; } function jps_createPhoneOption(optionNumber) { var _phoneOption = ''; _phoneOption += '<label for="txt_event_option_value_' + optionNumber + '" class="description">Phone </label>'; _phoneOption += '<span>'; _phoneOption += '<input id="txt_event_option_value_' + optionNumber + '_555a" name="txt_event_option_value_' + optionNumber + '_555a" type="text" value="" maxlength="3" size="3" class="element text"/> -'; _phoneOption += '<label for="txt_event_option_value_' + optionNumber + '_555a">(###)</label>'; _phoneOption += '</span>'; _phoneOption += '<span>'; _phoneOption += '<input id="txt_event_option_value_' + optionNumber + '_555" name="txt_event_option_value_' + optionNumber + '_555" type="text" value="" maxlength="3" size="3" class="element text"/> -'; _phoneOption += '<label for="txt_event_option_value_' + optionNumber + '_555">###</label>'; _phoneOption += '</span>'; _phoneOption += '<span>'; _phoneOption += '<input id="txt_event_option_value_' + optionNumber + '_5555" name="txt_event_option_value_' + optionNumber + '_5555" type="text" value="" maxlength="4" size="4" class="element text" />'; _phoneOption += '<label for="txt_event_option_value_' + optionNumber + '_5555">####</label>'; _phoneOption += '</span>'; return _phoneOption; } /** * <li id=""> <label class="description" for="element_2">Time </label> <span> <input id="element_2_1" name="element_2_1" class="element text" size="2" maxlength="2" value="" type="text">: <label>HH</label> </span> <span> <input id="element_2_2" name="element_2_2" class="element text" size="2" maxlength="2" value="" type="text">: <label>MM</label> </span> <span> <input id="element_2_3" name="element_2_3" class="element text" size="2" maxlength="2" value="" type="text"> <label>SS</label> </span> <span> <select class="element select" style="width: 4em;" id="element_2_4" name="element_2_4"> <option value="AM">AM</option> <option value="PM">PM</option> </select> <label>AM/PM</label> </span> </li> * @param {Object} optionNumber */ function jps_createTimeOption(optionNumber){ var _timeOption = ''; _timeOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '">Time </label>'; _timeOption += '<span>'; _timeOption += '<input id="txt_event_option_value_' + optionNumber + '_hh" name="txt_event_option_value_' + optionNumber + '_hh" class="element text" size="2" maxlength="2" value="" type="text">: '; _timeOption += '<label>HH</label>'; _timeOption += '</span>'; _timeOption += '<span>'; _timeOption += '<input id="txt_event_option_value_' + optionNumber + '_mm" name="txt_event_option_value_' + optionNumber + '_mm" class="element text" size="2" maxlength="2" value="" type="text">: '; _timeOption += '<label>MM</label>'; _timeOption += '</span>'; _timeOption += '<span>'; _timeOption += '<input id="txt_event_option_value_' + optionNumber + '_ss" name="txt_event_option_value_' + optionNumber + '_ss" class="element text" size="2" maxlength="2" value="" type="text">'; _timeOption += '<label>SS</label>'; _timeOption += '</span>'; _timeOption += '<span>'; _timeOption += '<select class="element select" style="width: 4em;" id="element_2_4" name="element_2_4">'; _timeOption += '<option value="AM">AM</option>'; _timeOption += '<option value="PM">PM</option>'; _timeOption += '</select>'; _timeOption += '<label>AM/PM</label>'; _timeOption += '</span>'; return _timeOption; } /** <li> <div class="left"> <input id="txt_event_start" name="txt_event_start"/> <label for="txt_event_start">Start </label> </div> <div class="right"> <input id="txt_event_end" name="txt_event_end"/> <label for="txt_event_end">End </label> </div> </li> * @param {Object} optionNumber */ function jps_createDateOption(optionNumber){ var _dateOption = ''; _dateOption += '<label for="txt_event_option_value_' + optionNumber + 'date" class="description">Date</label>'; _dateOption += '<div>'; _dateOption += '<input id="txt_event_option_value_' + optionNumber + 'date" name="txt_event_option_value_' + optionNumber + 'date" class="datepicker"/>'; _dateOption += '</div>'; _dateOption += '<script type="text/javascript">$(".datepicker").datepicker({dateFormat: "yy-mm-dd",showOn: "button", buttonImage: "assets/css/icons/icon_calendar_day.png", buttonImageOnly: true});</script>'; return _dateOption; } /** * <li id="li_5"> <label class="description" for="element_5">Upload a File </label> <div> <input id="element_5" name="element_5" class="element file" type="file"> </div> </li> * @param {Object} optionNumber */ function jps_createAttachmentOption(optionNumber){ var _attachmentOption = ''; _attachmentOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '_file">Upload a File </label>'; _attachmentOption += '<div>'; _attachmentOption += '<input id="txt_event_option_value_' + optionNumber + '_file" name="txt_event_option_value_' + optionNumber + '_file" class="element file" type="file"> </div>'; return _attachmentOption; } /** * <li id="li_3"> <label class="description" for="element_3">Address </label> <div> <input id="element_3_1" name="element_3_1" class="element text large" value="" type="text"> <label for="element_3_1">Street Address</label> </div> <div> <input id="element_3_2" name="element_3_2" class="element text large" value="" type="text"> <label for="element_3_2">Address Line 2</label> </div> <div class="left"> <input id="element_3_3" name="element_3_3" class="element text medium" value="" type="text"> <label for="element_3_3">City</label> </div> <div class="right"> <input id="element_3_4" name="element_3_4" class="element text medium" value="" type="text"> <label for="element_3_4">State / Province / Region</label> </div> <div class="left"> <input id="element_3_5" name="element_3_5" class="element text medium" maxlength="15" value="" type="text"> <label for="element_3_5">Postal / Zip Code</label> </div> <div class="right"> <input id="element_3_4" name="element_3_4" class="element text medium" value="United States" type="text"> <label for="element_3_6">Country</label> </div> </li> * @param {Object} optionNumber */ function jps_createAddressOption(optionNumber){ var _addressOption = ''; _addressOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '_address1">Address </label>'; _addressOption += '<div>'; _addressOption += '<input id="txt_event_option_value_' + optionNumber + '_address1" name="txt_event_option_value_' + optionNumber + '_address1" class="element text large" value="" type="text">'; _addressOption += '<label for="txt_event_option_value_' + optionNumber + '_address1">Street Address</label>'; _addressOption += '</div>'; _addressOption += '<div>'; _addressOption += '<input id="txt_event_option_value_' + optionNumber + '_address2" name="txt_event_option_value_' + optionNumber + '_address2" class="element text large" value="" type="text">'; _addressOption += '<label for="txt_event_option_value_' + optionNumber + '_address2">Address Line 2</label>'; _addressOption += '</div>'; _addressOption += '<div class="left">'; _addressOption += '<input id="txt_event_option_value_' + optionNumber + '_city" name="txt_event_option_value_' + optionNumber + '_city" class="element text medium" value="" type="text">'; _addressOption += '<label for="txt_event_option_value_' + optionNumber + '_city">City</label>'; _addressOption += '</div>'; _addressOption += '<div class="right">'; _addressOption += '<input id="txt_event_option_value_' + optionNumber + '_state" name="txt_event_option_value_' + optionNumber + '_state" class="element text medium" value="" type="text">'; _addressOption += '<label for="txt_event_option_value_' + optionNumber + '_state">State</label>'; _addressOption += '</div>'; _addressOption += '<div class="left">'; _addressOption += '<input id="txt_event_option_value_' + optionNumber + '_zip" name="txt_event_option_value_' + optionNumber + '_zip" class="element text medium" maxlength="15" value="" type="text">'; _addressOption += '<label for="txt_event_option_value_' + optionNumber + '_zip">Zip Code</label>'; _addressOption += '</div>'; _addressOption += '<div class="right">'; _addressOption += '<input id="txt_event_option_value_' + optionNumber + '_country" name="txt_event_option_value_' + optionNumber + '_country" class="element text medium" value="United States" type="text">'; _addressOption += '<label for="txt_event_option_value_' + optionNumber + '_country">Country</label>'; _addressOption += '</div>'; return _addressOption; } /** * <li id="li_7"> <label class="description" for="element_7">Web Site </label> <div> <input id="element_7" name="element_7" class="element text medium" maxlength="255" value="http://" type="text"> </div> </li> * @param {Object} optionNumber */ function jps_createUrlOption(optionNumber){ var _urlOption = ''; _urlOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '">Web Site </label>'; _urlOption += '<div>'; _urlOption += '<input id="txt_event_option_value_' + optionNumber + '_url" name="txt_event_option_value_' + optionNumber + '_url" class="element text medium" maxlength="255" value="http://" type="text"> </div>'; return _urlOption; } /** * * @param {Object} optionNumber */ function jps_createNameOption(optionNumber){ var _nameOption = ''; _nameOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '">Name </label>'; _nameOption += '<span>'; _nameOption += '<input id="txt_event_option_value_' + optionNumber + '_first" name="txt_event_option_value_' + optionNumber + '_first" class="element text" maxlength="255" value="">'; _nameOption += '<label>First</label>'; _nameOption += '</span>'; _nameOption += '<span>'; _nameOption += '<input id="txt_event_option_value_' + optionNumber + '_last" name="txt_event_option_value_' + optionNumber + '_last" class="element text" maxlength="255" value="">'; _nameOption += '<label>Last</label>'; _nameOption += '</span>'; return _nameOption; } /** * <li id="li_4"> <label class="description" for="element_4">Price </label> <span class="symbol">$</span> <span> <input id="element_4_1" name="element_4_1" class="element text currency" size="10" value="" type="text">. <label for="element_4_1">Dollars</label> </span> <span> <input id="element_4_2" name="element_4_2" class="element text" size="2" maxlength="2" value="" type="text"> <label for="element_4_2">Cents</label> </span> </li> * @param {Object} optionNumber */ function jps_createPriceOption(optionNumber){ var _priceOption = ''; _priceOption += '<label class="description" for="element_4">Price </label>'; _priceOption += '<span class="symbol">$</span>'; _priceOption += '<span>'; _priceOption += '<input id="txt_event_option_value_' + optionNumber + '_dd" name="txt_event_option_value_' + optionNumber + '_dd" class="element text currency" size="10" value="" type="text">. '; _priceOption += '<label for="txt_event_option_value_' + optionNumber + '_dd">Dollars</label>'; _priceOption += '</span>'; _priceOption += '<span>'; _priceOption += '<input id="txt_event_option_value_' + optionNumber + '_cc" name="txt_event_option_value_' + optionNumber + '_cc" class="element text" size="2" maxlength="2" value="" type="text">'; _priceOption += '<label for="txt_event_option_value_' + optionNumber + '_cc">Cents</label>'; _priceOption += '</span>'; return _priceOption; } /** * <li id="li_9"> <label class="description" for="element_9">Number </label> <div> <input id="element_9" name="element_9" class="element text medium" maxlength="255" value="" type="text"> </div> </li> * @param {Object} optionNumber */ function jps_createNumberOption(optionNumber){ var _numberOption = ''; _numberOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '_num">Number </label>'; _numberOption += '<div>'; _numberOption += '<input id="txt_event_option_value_' + optionNumber + '_num" name="txt_event_option_value_' + optionNumber + '_num" class="element text medium" maxlength="255" value="" type="text">'; _numberOption += '</div>'; return _numberOption; } /** * <li id="li_6"> <label class="description" for="element_6">Email </label> <div> <input id="element_6" name="element_6" class="element text medium" maxlength="255" value="" type="text"> </div> </li> * @param {Object} optionNumber */ function jps_createEmailOption(optionNumber){ var _emailOption = ''; _emailOption += '<label class="description" for="txt_event_option_value_' + optionNumber + '">Email </label>'; _emailOption += '<div>'; _emailOption += '<input id="txt_event_option_value_' + optionNumber + '_email" name="txt_event_option_value_' + optionNumber + '_email" class="element text medium" maxlength="255" value="@" type="text"></div>'; return _emailOption; } /** * <button id="jps-calendar-options-btn-remove" class="jps-btn-remove" value="Remove"> <span>Remove</span> </button> * @param {Object} optionNumber */ function jps_createRemoveOption(optionNumber){ var _removeOption = ''; _removeOption += '<div class="actions">'; _removeOption += '<a class="btn_option_remove" href="#" title="li_option_row_' + optionNumber + '">'; _removeOption += '<img src="assets/css/icons/icon_minus.png" width="16" height="16" alt="Delete Option ' + optionNumber + '"></a>'; _removeOption += '</div>'; return _removeOption; } /** * I create a name for a custom option, * the other piece is the value. * * @param {Object} optionNumber */ function jps_createOptionNameOption( optionNumber ) { var option = ''; option += '<label class="description">Option Name</label>'; option += '<input id="txt_event_option_name_' + optionNumber + '" name="txt_event_option_name_' + optionNumber + '" type="text" class="element text large" value=""/>'; return option; } /** * I build a new option of name/value. * * @param {Object} optionID - Number of the option */ function jps_createCustomOption(optionNumber){ var option = ''; option += '<label for="txt_event_option_name_' + optionNumber + '_custom" class="description">Option ' + optionNumber + '</label>'; option += '<span>'; option += '<input name="txt_event_option_name_' + optionNumber + '_custom" id="txt_event_option_name_' + optionNumber + '_custom" type="text" class="element text" value=""/>'; option += '<label>Name</label>'; option += '</span>'; option += '<span>'; option += '<input name="txt_event_option_value_' + optionNumber + '_custom" id="txt_event_option_value_' + optionNumber + 'custom_" type="text" class="element text" value=""/>'; option += '<label>Value</label>'; option += '</span>'; return option; } /** * I create a event option, I switch based on the type * of the pre-made option is. * * @param {Object} optionType * @param {Object} optionNumber */ function jps_createEventOption( optionType, optionNumber ) { var type = optionType.toString().toLowerCase(); window.console.log( 'Option #'+ optionNumber + ' Type: ' + type ); jpsPushOption( optionNumber, type ); switch (type) { case 'text': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createTextOption(optionNumber)); break; case 'phone': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createPhoneOption(optionNumber)); break; case 'custom': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createCustomOption(optionNumber)); break; case 'address': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createAddressOption(optionNumber)); break; case 'url': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createUrlOption(optionNumber)); break; case 'person': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createNameOption(optionNumber)); break; case 'price': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createPriceOption(optionNumber)); break; case 'number': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createNumberOption(optionNumber)); break; case 'email': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createEmailOption(optionNumber)); break; case 'attachment': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createAttachmentOption(optionNumber)); break; case 'time': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createTimeOption(optionNumber)); break; case 'date': jpsAddOption('li_option_row_' + optionNumber, optionNumber, jps_createDateOption(optionNumber)); break; default: break; } } /** * I add a option for the div_event_options div. * I highlight the option that just was added * * @param {Object} optionID * @param {Object} optionCnt * @param {Object} optionContents */ function jpsAddOption(optionID, optionCnt, optionContents) { var optionWrapContents = ''; optionWrapContents += '<li id="' + optionID + '" class="event_option" title="Option ' + optionID + '">'; optionWrapContents += jps_createRemoveOption( optionCnt ); optionWrapContents += '<div class="left">'; optionWrapContents += jps_createOptionNameOption( optionCnt ); optionWrapContents += '</div>'; optionWrapContents += '<div class="right">'; optionWrapContents += optionContents; optionWrapContents += '</div>'; optionWrapContents += '</li>'; $('#ul_event_options').append( optionWrapContents ); $('li#' + optionID ).highlightFade( { speed: 800 }); } /** * I get all of the options and return it as name/value pairs. * Whatever the about of options * * Types are: * * address - * Address 1: txt_event_option_value_' + optionNumber + '_address1 * Address 2: txt_event_option_value_' + optionNumber + '_address2 * City: txt_event_option_value_' + optionNumber + '_city * State: txt_event_option_value_' + optionNumber + '_state * Zip: txt_event_option_value_' + optionNumber + '_zip * Country: txt_event_option_value_' + optionNumber + '_country * * text - txt_event_option_value_' + optionNumber + ' * * custom - * Custom Value - txt_event_option_name_' + optionNumber + '_custom * * url - * URL: txt_event_option_value_' + optionNumber + '_url * * person - * First: txt_event_option_value_' + optionNumber + '_first * Last: txt_event_option_value_' + optionNumber + '_last * * price - * Dollars: txt_event_option_value_' + optionNumber + '_dd, * Cents: txt_event_option_value_' + optionNumber + '_cc * * number - * Number: txt_event_option_value_' + optionNumber + '_num * * email - * Email: txt_event_option_value_' + optionNumber + '_email * * attachment - * File: txt_event_option_value_' + optionNumber + '_file * * time - * Hour: txt_event_option_value_' + optionNumber + '_hh * Minute: txt_event_option_value_' + optionNumber + '_mm * Second: txt_event_option_value_' + optionNumber + '_ss * * date - * Date: txt_event_option_value_' + optionNumber + 'date * * */ function getOptionValues() { //Swtich based on option type, in the options array. //Loop every object in the eventOptionsArray, grabbing each number and type. //For every number we need to get the value from the input. //The option name value //The option value value //Depending on what type of option it is //We are going to have to grab those values //After we grab the values, we create a new object //Holding all of our values and push it into a array. //Returning all option values in one array for //The database to insert it. /* * Here is the object structure we are aiming for * * options: { * option_1: { * type: 'address', * name: 'Location', * value: '4834 Main Ave, Fair Oaks, CA, 95628, USA' * }, * option_2: { * type: 'email', * name: 'Contact', * value: '[email protected]' * option_3: { * type: 'name', * name: 'Host', * value: 'Jonnie Spratley' * } * } * * * */ //Options Object var returnArray = new Array(); var options = new Object(); $.each( eventOptionsArray, function( index, obj ){ trace('Option #:'+ obj.number ); //Holds option_ + # option var option = new Object(); //The options object options['option_' + index ] = option; //Each option inside of the options option.type = obj.type; //Object from the pushed option.name = $( '#txt_event_option_name_' + obj.number ).val(); //Switch based on option type to build the values from the different form inputs switch( obj.type ) { case 'address': var a1 = $( '#txt_event_option_value_' + obj.number + '_address1' ).val(); var a2 = $( '#txt_event_option_value_' + obj.number + '_address2' ).val(); var s = $( '#txt_event_option_value_' + obj.number + '_state' ).val(); var c = $( '#txt_event_option_value_' + obj.number + '_city' ).val(); var z = $( '#txt_event_option_value_' + obj.number + '_zip' ).val(); var usa = $( '#txt_event_option_value_' + obj.number + '_country' ).val(); var fullAddress = a1 + ' ' + a2 + ', ' + c + ', ' + s + ' ' + z + ', ' + usa; option.value = fullAddress; break; case 'text': option.value = $( '#txt_event_option_value_' + obj.number ).val(); break; case 'url': option.value = $( '#txt_event_option_value_' + obj.number + '_url').val(); break; case 'person': var fname = $( '#txt_event_option_value_' + obj.number +'_first').val(); var lname = $( '#txt_event_option_value_' + obj.number +'_last').val(); option.value = fname + ' ' + lname; break; case 'price': option.value = '$' + $( '#txt_event_option_value_' + obj.number + '_dd').val() + '.' + $( '#txt_event_option_value_' + obj.number + '_cc').val(); break; case 'number': option.value = $( '#txt_event_option_value_' + obj.number + '_num' ).val(); break; case 'email': option.value = $( '#txt_event_option_value_' + obj.number + '_email').val(); break; case 'time': var h = $( '#txt_event_option_value_' + obj.number + '_hh' ).val(); var m = $( '#txt_event_option_value_' + obj.number + '_mm' ).val(); var s = $( '#txt_event_option_value_' + obj.number + '_ss' ).val(); option.value = h + ':' + m + ':' + s; break; case 'phone': var p1 = $( '#txt_event_option_value_' + obj.number + '_555a' ).val(); var p2 = $( '#txt_event_option_value_' + obj.number + '_555' ).val(); var p3 = $( '#txt_event_option_value_' + obj.number + '_5555' ).val(); option.value = ''+p1+' '+p2+'-'+p3+''; break; case 'date': break; case 'custom': break; case 'attachment': break; default: break; } returnArray.push( option ); } ); trace( $.toJSON( returnArray ) ); return returnArray; } /** * I dump a string to the console * * @param {Object} str - the string to log */ function trace( str ) { window.console.log( str ); } /*========================================================= * Calendar Set Date / Get Date Functions * Set - For setting the date on the form * Get - For getting the values from all of the inputs and * returning a mysql date ========================================================= */ /** * I make a mysql date timestamp * @deprecated - Datepicker used instead * @param {Object} dateobj - a date */ function jps_makeTimestamp( dateobj ) { var date = new Date( dateobj ); var yyyy = date.getFullYear(); var mm = date.getMonth() + 1; var dd = date.getDate(); var hh = date.getHours(); var min = date.getMinutes(); var ss = date.getSeconds(); var mysqlDateTime = yyyy + '-' + mm + '-' + dd + ' ' + hh + ':' + min + ':' + ss; return mysqlDateTime; } /** * I get the date and times from the form, and make a valid * mysql datetime string for posting data. * * @deprecated - Datepicker used instead * @param {Object} id - the start or end date */ function jps_getCalendarFormDate(id){ //txt_event_end_yy var yyyy = $("#txt_event_" + id + "_yy").val(); var mm = $("#txt_event_" + id + "_mm").val(); var dd = $("#txt_event_" + id + "_dd").val(); var hh = $("#txt_event_" + id + "_time_hh").val(); var min = $("#txt_event_" + id + "_time_mm").val(); var ss = $("#txt_event_" + id + "_time_ss").val(); //var mysqlDateTime = yyyy + '-' + mm + '-' + dd + ' ' + hh + ':' + min + ':' + ss; var mysqlDateTime = $("#txt_event_" + id ).val() + ' ' + hh + ':' + min + ':' + ss; return mysqlDateTime; } /** * I set the calendar dates * @deprecated - Datepicker used instead * @param {Object} id * @param {Object} date */ function jps_setCalendarFormDate(id, date){ var yyyy = $("#txt_event_" + id + "_yy").val(date.getFullYear()); var mm = $("#txt_event_" + id + "_mm").val(date.getMonth() + 1); var dd = $("#txt_event_" + id + "_dd").val(date.getDate()); var hh = $("#txt_event_" + id + "_time_hh").val(date.getHours()); var min = $("#txt_event_" + id + "_time_mm").val(date.getMinutes()); var ss = $("#txt_event_" + id + "_time_ss").val(date.getSeconds()); } /** * I clear the calendar dates * @deprecated - Datepicker used instead * @param {Object} id */ function jps_clearCalendarFormDate(id){ $("#txt_event_" + id + "_yy").val(''); $("#txt_event_" + id + "_mm").val(''); $("#txt_event_" + id + "_dd").val(''); $("#txt_event_" + id + "_time_hh").val('00'); $("#txt_event_" + id + "_time_mm").val('00'); $("#txt_event_" + id + "_time_ss").val('00'); } /** * I take a string and create an excerpt from it, returning an object * with the summary and body properties, * @param {Object} str - the string to shorten * @param {Object} limit - the limit of characters */ function jps_shortString( str, limit ) { var body = new String( str ); var summary = new String(str); summary = summary.substr( 0, summary.lastIndexOf( ' ', limit ) ) + '...'; var returnString = new Object({ body: body, summary: summary }); //window.console.log( 'Summary - ' + summary); //window.console.log( 'Body - ' + body); return returnString; } var jps_buildHCalEvent = function( obj ) { var html = ''; html += '<div id="hcalendar-'+obj.title+'" class="vevent">'; html += ' <abbr title="'+obj.start+'" class="dtstart">'+obj.start+'</abbr>, '; html += ' <abbr title="'+obj.end+'" class="dtend">'+obj.end+'</abbr>'; html += ' <span class="summary">'+obj.title+'</span>'; html += ' <span class="location"></span>'; html += ' <div class="description">'; html += ' <p>'+obj.body+'</p>'; html += ' </div>'; html += '</div>'; return html; }