1(function ($) { 2 3 'use strict'; 4 5 6 function number_format (number, decimals, decPoint, thousandsSep) { 7 8 number = (number + '').replace(/[^0-9+\-Ee.]/g, '') 9 var n = !isFinite(+number) ? 0 : +number 10 var prec = !isFinite(+decimals) ? 0 : Math.abs(decimals) 11 var sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep 12 var dec = (typeof decPoint === 'undefined') ? '.' : decPoint 13 var s = '' 14 15 var toFixedFix = function (n, prec) { 16 var k = Math.pow(10, prec) 17 return '' + (Math.round(n * k) / k) 18 .toFixed(prec) 19 } 20 21 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.') 22 if (s[0].length > 3) { 23 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep) 24 } 25 if ((s[1] || '').length < prec) { 26 s[1] = s[1] || '' 27 s[1] += new Array(prec - s[1].length + 1).join('0') 28 } 29 30 return s.join(dec) 31 } 32 33 34 //Main output Function 35 function mcOutputFunc(){ 36 37 // Getting output div id 38 var outputDiv = $("#mc-output"); 39 40 // Getting total amount value from user 41 var mcTotalAmount = parseFloat( $("#mc-total-amount").val() ); 42 43 //Getting down payment value from user 44 var mcDownPayment = parseFloat( $("#mc-down-payment").val() ); 45 46 //Getting interest rate value from user 47 var mcInterestRate = parseFloat( $("#mc-interest-rate").val() ); 48 49 //Getting mortgage period value from user 50 var mcAmortizationPeriod = parseFloat( $("#mc-mortgage-period").val() ); 51 52 //Calculating principal amount by subtracting down payment from total amount 53 var principal = mcTotalAmount - mcDownPayment; 54 55 if ( 0 !== mcInterestRate ){ 56 57 //Calculating r by this formula ( (InterestRate/100)/12 ) 58 var r = ((mcInterestRate / 100) / 12); 59 60 // Power calculating by this formula Math.pow(base, exponent) 61 var power = Math.pow((1 + r), (mcAmortizationPeriod * 12)); 62 63 // Calculating total mortgage 64 var monthlyMortgage = principal * ((r * power) / (power - 1)); 65 66 } else { 67 68 var monthlyMortgage = principal / ( mcAmortizationPeriod * 12 ); 69 } 70 71 72 //Total mortgage with interest 73 var tmwi = monthlyMortgage * mcAmortizationPeriod * 12; 74 75 //Total with down payment 76 var tmwdp = tmwi + mcDownPayment; 77 78 // Getting localize php strings 79 var outPutString = mc_strings.mc_output_string; 80 81 //Currency sign 82 var mcCurrencySign = mc_strings.mc_currency_sign; 83 84 // Decimal numbers 85 var decimalNumbers = mc_strings.mc_number_of_decimals; 86 87 //Decimal Separator 88 var decimalSeparator = mc_strings.mc_decimal_separator; 89 90 //Thousand Separator 91 var thousandSeparator = mc_strings.mc_thousand_separator; 92 93 //Currency Sign Position 94 var currencySignPosition = mc_strings.mc_currency_sign_position; 95 96 //Formatting principal amount 97 principal= number_format( principal, decimalNumbers, decimalSeparator, thousandSeparator ); 98 99 //Assigning currency sign position to principal 100 principal = (currencySignPosition == 'before') ? mcCurrencySign+principal : principal+mcCurrencySign; 101 102 //Formatting monthly mortgage amount 103 monthlyMortgage= number_format( monthlyMortgage, decimalNumbers, decimalSeparator, thousandSeparator ); 104 105 //Assigning currency sign position to monthly Mortgage 106 monthlyMortgage = (currencySignPosition == 'before') ? mcCurrencySign+monthlyMortgage : monthlyMortgage+mcCurrencySign; 107 108 //Formatting monthly mortgage with interest amount 109 tmwi= number_format( tmwi, decimalNumbers, decimalSeparator, thousandSeparator ); 110 111 //Assigning currency sign position to monthly mortgage with interest amount 112 tmwi = (currencySignPosition == 'before') ? mcCurrencySign+tmwi : tmwi+mcCurrencySign; 113 114 //Formatting total mortgage with down payment 115 tmwdp= number_format( tmwdp, decimalNumbers, decimalSeparator, thousandSeparator ); 116 117 //Assigning currency sign position to total mortgage with down payment 118 tmwdp = (currencySignPosition == 'before') ? mcCurrencySign+tmwdp : tmwdp+mcCurrencySign; 119 120 outPutString = outPutString.replace( "[mortgage_amount]", principal); 121 outPutString = outPutString.replace( "[amortization_years]", mcAmortizationPeriod ); 122 outPutString = outPutString.replace( "[mortgage_payment]", monthlyMortgage ); 123 outPutString = outPutString.replace( "[total_mortgage_interest]", tmwi ); 124 outPutString = outPutString.replace( "[total_mortgage_down_payment]", tmwdp ); 125 outPutString = outPutString + ' <a href="#" onclick="jQuery(\'#mc_mlc_form\').submit(); return false;">Amortization Schedule</a>'; 126 127 //Displaying output div 128 outputDiv.html( "<p>
128"+outPutString+"</p>").stop(true, true).slideDown(); 129 outputDiv.html(outputDiv.html().replace(new RegExp("LINEBREAK","g"),"<br>")); 130 } 131 132 133 // Form validation and submission 134 if ( jQuery().validate ) { 135 $("#mc-form").validate({ 136 rules: { 137 field: { 138 number: true, 139 min:0 140 } 141 }, 142 submitHandler: function() { 143 mcOutputFunc(); 144 } 145 }); 146 } 147 148 // Amortization schedule 149 var iframeHeight = 578; 150 var mlcalcFrameIsShown = false; 151 if(!$('#MLCalcHolder, #MLCalcShader, #MLCalcClose').length){ 152 $('body').prepend('<div id="MLCalcHolder"></div><div id="MLCalcShader"></div><div id="MLCalcClose" style="display:none">X</div>'); 153 }; 154 155 $("#mc_mlc_form").submit(function(){ 156 // Getting total amount value from user 157 var mcTotalAmount = parseFloat( $("#mc-total-amount").val() ); 158 159 //Getting down payment value from user 160 var mcDownPayment = parseFloat( $("#mc-down-payment").val() ); 161 162 //Getting interest rate value from user 163 var mcInterestRate = parseFloat( $("#mc-interest-rate").val() ); 164 165 //Getting mortgage period value from user 166 var mcAmortizationPeriod = parseFloat( $("#mc-mortgage-period").val() ); 167 168 //Calculating principal amount by subtracting down payment from total amount 169 var principal = mcTotalAmount - mcDownPayment; 170 171 $("#mc_mlc_form INPUT[name=ma]").val(mcTotalAmount); 172 $("#mc_mlc_form INPUT[name=dp]").val(Number.parseInt(mcDownPayment/mcTotalAmount*100)); 173 $("#mc_mlc_form INPUT[name=mt]").val(mcAmortizationPeriod); 174 $("#mc_mlc_form INPUT[name=ir]").val(mcInterestRate); 175 initFloatLayer(iframeHeight); 176 }); 177 178})(jQuery); 179 180function initFloatLayer(iframeHeight){ 181 var viewportWidth = jQuery(window).width(); 182 var viewportHeight = jQuery(window).height(); 183 184 var documentWidth = 0; 185 var documentHeight = 0; 186 var viewportLeft = 0; 187 var viewportTop = 0; 188 189 if(document.body){ 190 documentWidth = document.body.scrollWidth; 191 documentHeight = document.body.scrollHeight; 192 viewportLeft = document.body.scrollLeft; 193 viewportTop = document.body.scrollTop; 194 }; 195 if(document.documentElement){ 196 documentWidth = Math.min(documentWidth, document.documentElement.scrollWidth); 197 documentHeight = Math.max(documentHeight, document.documentElement.scrollHeight); 198 viewportLeft = Math.max(viewportLeft, document.documentElement.scrollLeft); 199 viewportTop = Math.max(viewportTop, document.documentElement.scrollTop); 200 }; 201 202 var viewWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 203 var frameWidth = Math.min(viewWidth, 740); 204 205 var shaderWidth = Math.max(documentWidth, viewportWidth); 206 var shaderHeight = Math.max(documentHeight, viewportHeight); 207 jQuery('#MLCalcShader') 208 .css({ 209 width:shaderWidth, 210 height:shaderHeight, 211 top:0, 212 left:0, 213 opacity:'0.5' 214 }) 215 .show() 216 .click(function(){ 217 mlcalcHideAll(); 218 }); 219 220 var holderLeft = parseInt((viewportWidth - frameWidth) / 2) + viewportLeft; 221 var holderTop = parseInt((viewportHeight - iframeHeight) / 2) + viewportTop; 222 if(holderLeft < 0) holderLeft = 0; 223 if(holderTop < 0) holderTop = 0; 224 mlcalcFrameIsShown = true; 225 jQuery('#MLCalcHolder') 226 .css({ 227 width:frameWidth, 228 height:iframeHeight, 229 top:holderTop, 230 left:holderLeft 231 }) 232 .show(); 233 234 if(jQuery('#MLCalcHolder #MLCalcFrame').length < 1){ 235 jQuery('#MLCalcHolder').html('<iframe src="#" scrolling="no" id="MLCalcFrame" name="MLCalcFrame" width="0" height="0" frameborder="0" allowtransparency="true" style="background-color: transparent; display: none"></iframe><iframe id="garbageFrame" style="display:none"></iframe>') 236 }; 237 jQuery(document).keyup(function(e) { 238 if (e.keyCode == 27) mlcalcHideAll(); 239 }); 240 jQuery('#MLCalcHolder').find('#MLCalcFrame').css({width:frameWidth, height:iframeHeight}).on('load', function(){ 241 jQuery(this).show(); 242 jQuery('#MLCalcHolder #garbageFrame').attr('src', ''); 243 jQuery('#MLCalcClose').show().css({height:25, width:25}).css({top:holderTop, left:holderLeft+jQuery('#MLCalcHolder').width()-2-jQuery('#MLCalcClose').width()}) 244 .click(function(){ 245 mlcalcHideAll(); 246 }) 247 .hover(function(){ 248 jQuery(this).css({background:'#F5F5F5', color:'#808080'}); 249 }, function(){ 250 jQuery(this).css({background:'#D5D5D5', color:'#F5F5F5'}); 251 }); 252 }); 253}; 254function mlcalcHideAll(){ 255 if(!mlcalcFrameIsShown) return false;
256 mlcalcFrameIsShown = false; 257 jQuery('#MLCalcShader').fadeOut(300); 258 jQuery('#MLCalcHolder, #MLCalcClose').hide(); 259 jQuery('#MLCalcFrame').remove(); 260};
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.