1function leapyear(year){ 2 return (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0); 3} 4 5$(document).on('input', '.admissions-calculator .age-form select', function(){ 6 var selectedDay = $( '.admissions-calculator .age-form [name="day"]' ).val(), 7 selectedMonth = $( '.admissions-calculator .age-form [name="month"]' ).val(), 8 selectedYear = $( '.admissions-calculator .age-form [name="year"]' ).val(), 9 isleapyear = leapyear( parseInt(selectedYear) ), 10 dayHTML = '<option value="">DD</option>', 11 x = 0; 12 13 //Update days select options when month or year have been changed 14 if( $(this).attr('name') == 'month' || ($(this).attr('name') == 'year' && selectedMonth == "02") ){ 15 16 //Determine the number of days required based on month and year selections 17 switch( true ) { 18 case ["01", "03", "05", "07", "08", "10", "12"].includes(selectedMonth): 19 // 31 Days 20 x = 31; 21 break; 22 case ["04", "06", "09", "11"].includes(selectedMonth): 23 // 30 Days 24 x = 30; 25 break; 26 case ["02"].includes(selectedMonth) && isleapyear == true: 27 // 29 Days 28 x = 29; 29 break; 30 case ["02"].includes(selectedMonth) && isleapyear == false: 31 // 28 Days 32 x = 28; 33 break; 34 default: 35 } 36 37 //Create the options for the day select 38 for(i = 1; i <= x; i++){ 39 var leading = ''; 40 if(i < 10){ 41 leading = '0'; 42 } 43 dayHTML += '<option value="'+leading+i+'">'+leading+i+'</option>'; 44 } 45 46 //Add the options for the day select 47 $( '.admissions-calculator .age-form [name="day"]' ).html(dayHTML); 48 49 50 if( $( '.admissions-calculator .age-form [name="day"] [value="'+selectedDay+'"]' ).length ){ 51 //If the days have been updated then select the previously selected value 52 $( '.admissions-calculator .age-form [name="day"] [value="'+selectedDay+'"]' ).attr('selected', 'selected'); 53 } else { 54 //If the value was removed (for example 31st then change to February) then select the last value 55 $( '.admissions-calculator .age-form [name="day"] option:last-child' ).attr('selected', 'selected'); 56 } 57 } 58}); 59 60//Cancel form submission but send data over AJAX to obtain relevant tabs 61$(document).on('submit', '.admissions-calculator .age-form', function(e){ 62 e.preventDefault() 63 var ageForm = $(this).closest( '.admissions-calculator').find('.age-form'), 64 selectedDay = ageForm.find('[name="day"]').val(), 65 selectedMonth = ageForm.find('[name="month"]' ).val(), 66 selectedYear = ageForm.find('[name="year"]' ).val(), 67 postID = ageForm.find('[name="post_id"]' ).val(); 68 $(this).find('.error').remove(); 69 70 // alert('this is working'); 71 72 if(selectedDay == '' || selectedMonth == '' || selectedYear == ''){ 73 $(this).append('<div class="error">Please enter your child\'s date of birth.</div>'); 74 return false; 75 } 76 77 78 $.ajax({ 79 url: '/wp-content/themes/st-pauls-school/template-parts/ajax/admissions-calculator.php', 80 type: 'POST', 81 data: 'date='+selectedYear+'-'+selectedMonth+'-'+selectedDay+'&postid='+postID, 82 cache: false, 83 84 success: function (data) { 85 ageForm.closest('.admissions-container').addClass('active'); 86 $('.age-form').replaceWith(data); 87 $('.admissions-calculator .tabs .tab:first-child').trigger('click'); 88 89 if(window.innerWidth < 768){ 90 // $('.scrollbar-inner').scrollbar(); 91 } 92 } 93 94 }); 95 96 return false; 97}); 98 99 100$(document).on('click','.admissions-calculator .tabs .tab', function(){ 101 var tab = $(this).attr('data-tab'), 102 form = $(this).closest('.admissions-calculator').find('.tab_content[data-tab="'+tab+'"]').find('.dynamic-form'), 103 form_id = form.attr('data-id'); 104 105 $(this).siblings().removeClass('current'); 106 $(this).addClass('current'); 107 $(this).closest('.admissions-calculator').find('.tab_content .dynamic-form').html(''); 108 $(this).closest('.admissions-calculator').find('.tab_content').removeClass('current'); 109 $(this).closest('.admissions-calculator').find('.tab_content[data-tab="'+tab+'"]').addClass('current'); 110 111 return false; 112}); 113 114$(document).ready(function() { 115 $('.admissions-calculator select').css('color','gray'); 116 $('.admissions-calculator select').change(function() { 117 var current = $(this).val(); 118 if (current != '') { 119 $(this).css('color','#121746'); 120 } else { 121 $(this).css('color','gray'); 122 } 123 }); 124});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.