1// Code By Avtec ( https://avtecmedia.com ) 2// Listen for Submit 3document.getElementById("loan-form").addEventListener("submit", function(e) { 4 // Hide Results 5 document.getElementById("result").style.display = "none"; 6 7 // Show Loader 8 document.getElementById("loading").style.display = "block"; 9 10 setTimeout(calculateResults, 2000); 11 12 e.preventDefault(); 13}); 14 15// Calculate Results 16function calculateResults() { 17 18 const amount = document.getElementById("amount"); 19 const interest = document.getElementById("interest"); 20 const years = document.getElementById("years"); 21 const monthlyPayment = document.getElementById("monthly-payment"); 22 const totalPayment = document.getElementById("total-payment"); 23 const totalInterest = document.getElementById("total-interest"); 24 25 const principal = parseFloat(amount.value); 26 const calculatedInterest = parseFloat(interest.value) / 100 / 12; 27 const calculatedPayments = parseFloat(years.value) * 12; 28 29 // Computed Monthly payment 30 const x = Math.pow(1 + calculatedInterest, calculatedPayments); 31 const monthly = (principal * x * calculatedInterest) / (x - 1); 32 33 if (isFinite(monthly)) { 34 monthlyPayment.value = monthly.toFixed(2); 35 totalPayment.value = (monthly * calculatedPayments).toFixed(2); 36 totalInterest.value = (monthly * calculatedPayments - principal).toFixed(2); 37 38 // Show Results 39 document.getElementById("result").style.display = "block"; 40 41 // Hide Loader 42 document.getElementById("loading").style.display = "none"; 43 } else { 44 showError("Please check number inputs"); 45 } 46} 47 48// Show Error 49function showError(error) { 50 // Hide Results 51 document.getElementById("result").style.display = "none"; 52 53 // Hide Loader 54 document.getElementById("loading").style.display = "none"; 55 56 // Create a div 57 const errorDiv = document.createElement("div"); 58 59 // Get Elements 60 const card = document.querySelector(".card"); 61 const heading = document.querySelector(".heading"); 62 63 // Add class 64 errorDiv.className = "alert alert-danger"; 65 66 // Create text node and append div 67 errorDiv.appendChild(document.createTextNode(error)); 68 69 // Insert error above heading 70 card.insertBefore(errorDiv, heading); 71 72 // Clear Error after 3 seconds 73 setTimeout(clearError, 3000); 74 75 // Clear Error 76 function clearError() { 77 document.querySelector(".alert").remove(); 78 } 79}
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.