PageSourceSearch

https://mymodernlaw.com/wp-content/plugins/spousal-maintenance-cal…ce-calculator-public.js?ver=1.0.01790914877

js mymodernlaw.com collected 2026-10-02 05:12:22 UTC 7,913 bytes, 230 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31	
32	$(document).ready(function () {
33
34		$("#smc_calculate").on("click", function() {
35			console.log("smc_calculate click");
36			smc_calculation('C');
37		});
38
39		var todaydate = new Date().toLocaleDateString('en-us', { year: "numeric", month: "long", day: "numeric" });
40		window.onload = function () {
41			jQuery("#current_date").val(todaydate)
42			document.getElementById("case_date").innerText = todaydate;
43		}
44
45		$(".spousal-maintenance-calculator-html input, .spousal-maintenance-calculator-html select").change(function(){
46			var field_id = $(this).attr('id');
47			$(".spousal-maintenance-calculator-pdf #"+field_id+"Print").text($("#"+field_id).val());
48		});
49
50		$("#printPDFButton").click(function(){
51			smc_calculation('P');
52		});
53
54		$("#downloadPDFButton").click(function(){
55			smc_calculation('D');
56		});
57
58		$('#FamilySize').on('keypress', function(event) {
59			var inputValue = event.which;
60			// Regular expression pattern to allow only numbers 2 to 5
61			var pattern = /[2-5]/;
62			var inputChar = String.fromCharCode(inputValue);
63			
64			if (!pattern.test(inputChar)) {
65				event.preventDefault();
66			}
67		});
68
69	}); // End Of Ready Document
70  	
71
72  	// Print and Download Calculator Result
73  	function smc_calculation_print_download(flag) {
74  		console.log("smc_calculation_print_download flag==>"+flag);
75
76  		jQuery.ajax({
77			// async: false,
78			type: "POST",
79			url: smc_public.ajaxurl,
80			data: { action : 'custom_pdf_download', case_number : jQuery("#caseNumber").val(), content : jQuery(".pdf-content").get(0).outerHTML }, 
81			beforeSend: function() {
82		    },
83			success: function (data) {
84				var response = JSON.parse(data);
85  				console.log("smc_calculation_print_download response==>"+response);
86				if( flag == 'D' ) {
87		            var a = jQuery("<a />");
88		            a.attr("download", response.pdf_name);
89		            a.attr("href", response.link);
90		            jQuery("body").append(a);
91		            a[0].click();
92		            jQuery("body").remove(a);
93		        } else if( flag == 'P' ){
94		        	window.open(response.link, '_blank');
95		        }
96			},
97			complete: function() {
98		    },
99		});
100  	}
101
102  	// Perform Calculation Based On Spreadsheet/Excel File
103	function smc_calculation(flag) {
104
105		var calc_button = $("#smc_calculate");
106		var printPDFButton = $("#printPDFButton");
107		var downloadPDFButton = $("#downloadPDFButton");
108
109		console.log('Calculate flag==>'+flag);
110		console.log('petitionerActualIncome==>'+$("#petitionerActualIncome").val());
111		
112		if( $("#petitionerActualIncome").val() == '' ){
113			var petitionerActualIncome = 0;
114		}else{
115			var petitionerActualIncome = parseFloat($("#petitionerActualIncome").val());
116		}
117		if( $("#respondentActualIncome").val() == '' ){
118			var respondentActualIncome = 0;
119		}else{
120			var respondentActualIncome = parseFloat($("#respondentActualIncome").val());
121		}
122		if( $("#petitionerAttributedIncome").val() == '' ){
123			var petitionerAttributedIncome = 0;
124		}else{
125			var petitionerAttributedIncome = parseFloat($("#petitionerAttributedIncome").val());
126		}
127		if( $("#respondentAttributedIncome").val() == '' ){
128			var respondentAttributedIncome = 0;
129		}else{
130			var respondentAttributedIncome = parseFloat($("#respondentAttributedIncome").val());
131		}
132		if( $("#familyMortgagePrincipal").val() == '' ){
133			var familyMortgagePrincipal = 0;
134		}else{
135			var familyMortgagePrincipal = parseFloat($("#familyMortgagePrincipal").val());
136		}
137		// var respondentActualIncome = parseFloat($("#respondentActualIncome").val());
138		// var petitionerAttributedIncome = parseFloat($("#petitionerAttributedIncome").val());
139		// var respondentAttributedIncome = parseFloat($("#respondentAttributedIncome").val());
140		// var familyMortgagePrincipal = parseFloat($("#familyMortgagePrincipal").val());
141		// var probabilityIntervalDesired = parseFloat($("#probabilityIntervalDesired").val());
142	  	
143	  	$(".spousal-maintenance-calculator-html .smc-calculate-error").remove();
144	  	if( $("#FamilySize").val() == '' || isNaN($("#FamilySize").val()) ){
145	  		$("#FamilySize").after("<div class='smc-calculate-error'>
145Family Size must be two or more.</div>");
146	  		$('html, body').animate({
147		        scrollTop: $('.spousal-maintenance-calculator-html').offset().top //#DIV_ID is an example. Use the id of your destination on the page
148		    }, 'slow');
149	  		return;
150	  	} else{
151	  		var FamilySize = parseFloat($("#FamilySize").val());
152	  	}
153
154		if (isNaN(petitionerActualIncome) || isNaN(respondentActualIncome) || isNaN(petitionerAttributedIncome) || isNaN(respondentAttributedIncome) || isNaN(familyMortgagePrincipal)) {
155		  	// Handle invalid input values, display an error message, or perform any other necessary action.
156		  	$(".spousal-maintenance-calculator-html").prepend("<div class='smc-calculate-error'>Please enter correct details.</div>");
157		  	return;		  
158		}
159
160	  	jQuery.ajax({
161			// async: false,
162			type: "POST",
163			url: smc_public.ajaxurl,
164			data: { 
165				action : 'smc_calculate_excel_process',
166				FamilySize : FamilySize,
167				petitionerActualIncome : petitionerActualIncome,
168				respondentActualIncome : respondentActualIncome,
169				petitionerAttributedIncome : petitionerAttributedIncome,
170				respondentAttributedIncome : respondentAttributedIncome,
171				familyMortgagePrincipal : familyMortgagePrincipal,
172				// probabilityIntervalDesired : probabilityIntervalDesired
173			}, 
174			beforeSend: function() {
175        		$('#smc-loader').removeClass('hidden')
176				$(document.body).addClass('smc_calculate_loader');
177				$(calc_button).prop( "disabled", true );
178				$(printPDFButton).prop( "disabled", true );
179				$(downloadPDFButton).prop( "disabled", true );
180				console.log(123);
181		    },
182			success: function (data) {
183				var response = JSON.parse(data);
184				console.log("response==>",response);
185
186				$.each(response, function (key,value) {
187					$(".spousal-maintenance-calculator-html #"+key).text(value);
188					$(".spousal-maintenance-calculator-pdf #"+key).text(value);
189				});
190
191				if( flag == 'D' || flag == 'P' ) {
192					smc_calculation_print_download( flag );
193				}
194				$(document.body).addClass('smc_calculate_loader');
195				$(calc_button).prop( "disabled", false );
196				$(printPDFButton).prop( "disabled", false );
197				$(downloadPDFButton).prop( "disabled", false );
198				$('html, body').animate({
199			        scrollTop: $('.CalculationsDiv').offset().top //#DIV_ID is an example. Use the id of your destination on the page
200			    }, 'slow');
201			},
202			complete: function() {
203        		$('#smc-loader').addClass('hidden')
204				$(document.body).addClass('smc_calculate_loader');
205				$(calc_button).prop( "disabled", false );
206				$(printPDFButton).prop( "disabled", false );
207				$(downloadPDFButton).prop( "disabled", false );
208		    },
209		});
210	}
211
212})( jQuery );
213
214
215function isNumber(evt,elem) {
216	evt = (evt) ? evt : window.event;
217	var charCode = (evt.which) ? evt.which : evt.keyCode;
218	var goodNumber = true;
219	if (  charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57) ) {
220		goodNumber = false;
221	}
222
223	let brian = elem.value.split(".");
224	if(brian[1])
225	{
226		if(brian[1].length > 1){goodNumber = false;}
227	}
228
229	return goodNumber;
230}

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.