Skip to content
Browse files

Initial distribution of v2.5 Beta

  • Loading branch information...
1 parent dadcabe commit 482a3ed26ad19db01c5da8b8367d61acd6065bd9 Dr Paul Brewer committed Oct 16, 2012
Showing with 1,822 additions and 423 deletions.
  1. +32 −17 README
  2. +104 −0 TVM.js
  3. +0 −361 UnofficialHampLib2.js
  4. +806 −0 UnofficialHampLib3.js
  5. +339 −0 gpl-2.0.txt
  6. +259 −0 jquery.jqplot.css
  7. +57 −0 jquery.jqplot.min.js
  8. +1 −1 license.html
  9. +180 −44 skin.html
  10. +12 −0 style.css
  11. +32 −0 underscore-min.js
View
49 README
@@ -1,7 +1,18 @@
Unofficial HAMP Calculator
-(c) Dr Paul Brewer 2010
-License: Free Software Foundation's General Public License (GPL) version 3
+(c) Dr Paul Brewer 2010, 2012-
+License: Free Software Foundation's General Public License (GPL) version 2
+or any later version of the FSF General Public License
+Please note that the License to use the software contains a warranty disclaimer
+so that THERE IS NO WARRANTY FOR THIS SOFTWARE and ALL USE IS AT YOUR OWN RISK.
+
+Such a disclaimer is common industry practice with respect to free software.
+
+Note: Dr Paul Brewer is an independent economist and did not work
+for the United States Government or any bank during the creation of this
+software. Also, no government or bank officials were involved in the creation
+or testing of the software. The algorithms involved are worthy of independent
+study, and the Unofficial HAMP Calculator represents such an independent study.
GENERAL BACKGROUND
During the recent credit crisis and recession in the United States, many
@@ -24,14 +35,8 @@ an existing mortgage.
The full details of this algorithm are beyond the scope of this version
of the README file.
-The algorithm is interesting and worthy of independent study
-The UnofficialHAMPCalculator represents such an independent study.
-
-I, Dr Paul Brewer, am a private economist with no ties to the US Government
-or the decision makers who created and implemented the HAMP program. Let's
-make that part clear.
-HAMP ALGORITHM
+AN INTRODUCTION TO THE HAMP ALGORITHM
Keep in mind that this is only one version of the procedure, and not
the whole procedure. The policy must be considered as subject to change.
@@ -59,16 +64,26 @@ to forgive some of this principal, but is not required to.
UNOFFICIAL CALCULATOR IMPLEMENTATION AND USAGE
-The calculator is implemented primarily in two files and uses the
-prototype.js Javascript extension library -- a copy of which is included.
+The calculator uses the folowing javascript extension libraries
+written by others:
+
+JQuery (no copy needed, html includes the Google public CDN copy)
+Underscore.js (copy provided, distrubuted under the MIT License)
+JQPlot (copies provided, distributed under the GNU GPL v2 License)
+
+The skin.html file contains the "skin" of the calculator. If you want
+to test your download of the calculator, open "skin.html" in firefox
+or google chrome.
-The skin.html file contains the "skin" of the calculator.
+The UnofficialHampLib3.js file contains the Javascript program code to implement
+the calculator.
-The UnofficialHampLib2.js file contains the Javascript program code to implement
-the calculator.
+The TVM.js file contains a library of mathematical Time Value of Money and
+Loan functions.
-I am making these files are made available under the Free Software Foundation's
-GNU General Public License version 3.0. However, that does not mean anyone
+I am making these files available under the Free Software Foundation's
+GNU General Public License version 2.0 (or any subsequent version of the license
+as released by the Free Software Foundation). However, that does not mean anyone
can do anything with the files. Please read the license to understand
what is permitted. For example, you may NOT modify this calculator and turn
the result into proprietary software where you control who can further
@@ -84,7 +99,7 @@ prototype.
I believe people have a right to get independent information about
how their mortgages may be modified and I have a website, ArmDisarm.com,
-that I am interested in devoting to benevolent entrepreneurship in this area.
+devoted to benevolent entrepreneurship in this area.
View
104 TVM.js
@@ -0,0 +1,104 @@
+// (c) 2012 Paul Brewer
+// Part of Unofficial HAMP Loan Modification Calculator
+// This File Licensed to the Public under the GNU GPL v2.0 License
+// or any later version
+// see license file: gpl-2.0.txt
+//
+// These six functions are textbook time-value-of-money factors.
+// Go read wikipeia "Time Value of Money" for a crash course on this subject.
+// The original software author, Dr Brewer, taught this subject as part of
+// "Engineering Economics" in Hong Kong for about 4 years.
+//
+// These function convert between
+// present values P, future values F, flow values A
+// rates are 8 for 8%/year, but n is in months so r is scaled at the
+// beginning of each function by 1/1200 so that we can correctly
+// apply the classic formulas.
+//
+
+TVM = {
+ 'PoverA': function PoverA(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? n: ( (1.0 - Math.pow(1.0 + r, -n)) / r);
+ },
+
+ 'AoverP': function AoverP(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? (1/n) : (r / (1.0 - Math.pow(1.0 + r, -n)));
+ },
+
+ 'FoverP': function FoverP(r, n) {
+ r = r / 1200.0;
+ return Math.pow(1.0 + r, n);
+ },
+
+ 'PoverF': function PoverF(r, n) {
+ r = r / 1200.0;
+ return Math.pow(1.0 + r, -n);
+ },
+
+ 'FoverA': function FoverA(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? n : ( (Math.pow(1.0 + r, n) - 1) / r);
+ },
+
+ 'AoverF': function AoverF(r, n) {
+ r = r / 1200.0;
+ return (r<0.000001)? (1/n) : ( r / (Math.pow(1.0 + r, n) - 1) );
+ }
+};
+// end standard time-value-of-money functions
+
+
+TVM.StandardLoanPayment = function StandardLoanPayment(Rate, LoanAmt, TermInMonths) {
+ return TVM.AoverP(Rate, TermInMonths) * LoanAmt;
+};
+
+
+TVM.StandardLoanFutureBalance = function StandardLoanFutureBalance(Rate, LoanAmt, Month, MonthlyPayment) {
+ return TVM.FoverP(Rate, Month) * LoanAmt - TVM.FoverA(Rate, Month) * MonthlyPayment;
+};
+
+TVM.VariableRateLoanPaymentArray=function VariableRateLoanPaymentArray(LoanAmt, TermInMonths, startRate, MonthArray, RateArray) {
+ // This calculates a payment array for a single complex loan.
+ // The payment array is a sparse array and shows the changes in payments.
+ //
+ // Payments at other months match the previous step, the entire payment
+ // profile can be determined as a stairstep function with steps months
+ // given in the MonthArray rates in the RateArray and payments
+ // in the output of this function which we call a PaymentArray
+ //
+ // the loan is for an amortizing, interest-bearing amount LoanAmt
+ // the term is TermInMonths
+ // the initial interest rate is startRate
+ // the MonthArray lists the months when the rates change
+ // this array should be strictly increasing
+ // the RateArray lists what the rates will be
+ // rates may go up or down but the length of the array should match
+ // the length of MonthArray
+ // the output will be an array of identical length giving monthly payments
+ // (to get the start rate monthly payment use "StandardLoanPayment()")
+
+ var changes = MonthArray.length;
+ var payments = new Array(changes);
+
+ // initial state for the for loop; will be updated each iteration
+ var RemainingBalance = LoanAmt;
+ var prevMonth = 0;
+ var prevRate = startRate;
+ var prevPayment = TVM.StandardLoanPayment(prevRate, LoanAmt, TermInMonths);
+ var j=0,newMonth=0,newRate=0;
+
+ for(j = 0; j < changes; ++j) {
+ newMonth = MonthArray[j];
+ newRate = RateArray[j];
+ RemainingBalance = TVM.StandardLoanFutureBalance(prevRate, RemainingBalance, newMonth - prevMonth, prevPayment);
+ payments[j] = TVM.StandardLoanPayment(newRate, RemainingBalance, TermInMonths - newMonth);
+ prevMonth = newMonth;
+ prevRate = newRate;
+ prevPayment = payments[j];
+ }
+
+ return payments;
+
+};
View
361 UnofficialHampLib2.js
@@ -1,361 +0,0 @@
-// Unofficial HAMP Library for Javascript v2
-// (C) 2012 Dr Paul Brewer
-// Licensed under version 3 of the GNU General Public License
-//
-// VARIABLE NAMING CONVENTIONS
-//
-// Hungarian notation prefixes for variable names:
-// bo - borrower
-// ol - original loan
-// fm - Freddie Mac public data
-// ml - modified loan
-// po - policy
-//
-// expected elements in Q hash (case study or UI inputs)
-// boMoGrossIncome -- borrowers monthly gross income
-// boMoMiscHousingExpense -- borrowers (approved) misc housing expense
-// olUnpaid -- original loan unpaid balance
-// olHomeMarketValue -- home value in todays market
-// olMoRemain -- original loan months remaining
-// olRate -- original loan interest rate
-// fmCap -- freddie mac cap rate (30 yr PMMS rate)
-// poDoPR -- 1 for alternative (principal-reduction) waterfall
-// poDoLenderVariation -- check if principal reduction exceeds 5%
-// if so, lengthen loan then reduce rate
-//
-// A HAMP result hash contains these elements (outputs)
-// all result elements are unformatted strings, should be rounded to nearest dollar for dollar values
-// mlTargetAGIPct
-// mlPR = Principal Reduction
-// mlUnpaid = new Unpaid balance = olUnpaid - mlPR
-// mlLTV = 100 * mlUnpaid/olHomeMarketValue
-// mlMoTotalTargetPayment = mlTargetAGIPCT % of bMoGrossIncome
-// mlMoMiscHousingExpense = copied from bMoMiscHousingExpense
-// mlMoTargetPayment = target for loan payment, == total-misc
-// mlRate1to5 -- interest rate first 5 years
-// mlMoPayment1to5 -- modified monthly loan payment first 5 years
-// mlMonths -- term (length) of modified loan in months
-// mlChangeMonths -- months for which rate changes occur -- as a string
-// mlChangeRates -- new rates that take effect on the months above -- as a string
-// mlChangePayments -- new payments that take effect on the months above -- as a string
-// mlBalloon -- balloon payment at the end, if any. if none, return a zero.
-
-
-function noFrames() {
- if(top != self) {
- document.write('');
- alert("The web page you are visiting takes content from www.armdisarm.com and tries to display it as part of their own web page. Pressing OK will attempt to load www.armdisarm.com directly. Thanks -- Dr Paul Brewer armdisarm.com ");
- top.location.replace(self.location.href);
- }
-}
-
-
-UHC = function(){
-
- var ml = {};
- var q = {};
- var animationRunning = 0;
-
- function numerize(x){ var xx=1*x; return (isNaN(xx)?x:xx)}
-
- function roundStep(x, step) {
- // returns x rounded to the nearest step
- return step * Math.round(x / step);
- }
-
-
-// These six functions are textbook time-value-of-money factors.
-// Go read wikipeia "Time Value of Money" for a crash course on this subject.
-// The original software author, Dr Brewer, taught this subject as part of
-// "Engineering Economics" in Hong Kong for about 4 years.
-//
-// These function convert between
-// present values P, future values F, flow values A
-// rates are 8 for 8%/year, but n is in months so r is scaled at the
-// beginning of each function by 1/1200 so that we can correctly
-// apply the classic formulas.
-//
-
-
- function PoverA(r, n) {
- r = r / 1200.0;
- return (1.0 - Math.pow(1.0 + r, -n)) / r;
- }
-
- function AoverP(r, n) {
- r = r / 1200.0;
- return r / (1.0 - Math.pow(1.0 + r, -n));
- }
-
- function FoverP(r, n) {
- r = r / 1200.0;
- return Math.pow(1.0 + r, n);
- }
-
- function PoverF(r, n) {
- r = r / 1200.0;
- return Math.pow(1.0 + r, -n);
- }
-
- function FoverA(r, n) {
- r = r / 1200.0;
- return (Math.pow(1.0 + r, n) - 1) / r;
- }
-
- function AoverF(r, n) {
- r = r / 1200.0;
- return r / (Math.pow(1.0 + r, n) - 1);
- }
-
-// end standard time-value-of-money functions
-
- function StandardLoanPayment(Rate, LoanAmt, TermInMonths) {
- return AoverP(Rate, TermInMonths) * LoanAmt;
- }
-
-
- function StandardLoanFutureBalance(Rate, LoanAmt, Month, MonthlyPayment) {
- return FoverP(Rate, Month) * LoanAmt - FoverA(Rate, Month) * MonthlyPayment;
- }
-
- function VariableRateLoanPaymentArray(LoanAmt, TermInMonths, startRate, MonthArray, RateArray) {
- // This calculates a payment array for a single complex loan.
- // The payment array is a sparse array and shows the changes in payments.
- //
- // Payments at other months match the previous step, the entire payment
- // profile can be determined as a stairstep function with steps months
- // given in the MonthArray rates in the RateArray and payments
- // in the output of this function which we call a PaymentArray
- //
- // the loan is for an amortizing, interest-bearing amount LoanAmt
- // the term is TermInMonths
- // the initial interest rate is startRate
- // the MonthArray lists the months when the rates change
- // this array should be strictly increasing
- // the RateArray lists what the rates will be
- // rates may go up or down but the length of the array should match
- // the length of MonthArray
- // the output will be an array of identical length giving monthly payments
- // (to get the start rate monthly payment use "StandardLoanPayment()")
-
- var changes = MonthArray.length;
- var payments = new Array(changes);
-
- // initial state for the for loop; will be updated each iteration
- var RemainingBalance = LoanAmt;
- var prevMonth = 0;
- var prevRate = startRate;
- var prevPayment = StandardLoanPayment(prevRate, LoanAmt, TermInMonths);
- var j=0,newMonth=0,newRate=0;
-
- for(j = 0; j < changes; ++j) {
- newMonth = MonthArray[j];
- newRate = RateArray[j];
- RemainingBalance = StandardLoanFutureBalance(prevRate, RemainingBalance, newMonth - prevMonth, prevPayment);
- payments[j] = StandardLoanPayment(newRate, RemainingBalance, TermInMonths - newMonth);
- prevMonth = newMonth;
- prevRate = newRate;
- prevPayment = payments[j];
- }
-
- return payments;
-
- }
-
- function mlMergeHAMPfuture() {
- var rate = ml.mlRate1to5;
- if(rate < q.fmCap) {
- var N = Math.floor(q.fmCap - rate);
- var MonthArray = $R(0, N).collect(function(x) {
- return 60 + 12 * x;
- });
- var RateArray = $R(1, N).collect(function(x) {
- return rate + x;
- });
- RateArray.push(q.fmCap);
- var AmortLoan = ml.mlUnpaid - ml.mlBalloon;
- var PaymentChangeArray = VariableRateLoanPaymentArray(AmortLoan, ml.mlMonths, rate, MonthArray, RateArray).collect(Math.round);
- ml.mlChangeMonths = MonthArray.join(' -- ');
- ml.mlChangeRates = RateArray.join(' -- ');
- ml.mlChangePayments = PaymentChangeArray.join(' -- ');
- }
- }
-
- function elementsML(){
- return $$('span[id^="ml"]');
- }
-
- function readML(){
- elementsML().each(function(el){ml[el.id]=numerize(el.innerHTML);});
- return ml;
- }
-
- function writeML(){
- elementsML().each(function(el){el.update(ml[el.id])});
- return ml;
- }
-
- function elementsQ(){
- return $$('input');
- }
-
- function readQ(){
- elementsQ().each(function(el){
- if ((el.type === "text") || (el.type === "hidden")){
- q[el.id]=numerize(el.value);
- } else if (el.type === "checkbox"){
- q[el.id]=(el.checked)?1:0;
- } else {
- q[el.id]='readQException';
- }
- });
- return q;
- }
-
- function getPayment1to5(){
- return Math.round(StandardLoanPayment(ml.mlRate1to5,ml.mlUnpaid-ml.mlBalloon,ml.mlMonths));
- }
-
- function policyLengthBeforeRate(){
-// see MHA Handbook v3.3, p.81, sect 6.4.4 Variation from the Alternative Modification Waterfall
-// lender is allowed to modify length before reducing rate if more than 5% of principal is forgiven
- return (q.poDoPR && q.poDoLenderVariation && ml.mlPR && (ml.mlPR > (0.05*q.olUnpaid)));
- }
-
- function doPrincipalReductionByStep(step,floorLTV){
- if (!ml.mlUnpaid){ ml.mlUnpaid = q.olUnpaid-ml.mlPR; }
- if (ml.mlUnpaid > (floorLTV*q.olHomeMarketValue)){
- ml.mlPR += step;
- ml.mlUnpaid = q.olUnpaid-ml.mlPR;
- ml.mlLTV = Math.round(100*ml.mlUnpaid/q.olHomeMarketValue);
- ml.mlMoPayment1to5 = getPayment1to5();
- mlMergeHAMPfuture();
- ml.mlCalculatorStep = 'Reducing Principal to $'+ml.mlUnpaid;
- return true;
- }
- return false;
- }
-
-
-// see MhaHandbook v3.3, section 6.3.2 Step 2 -- Interest Rate Reduction
-// If the current rate is not at a 0.125 percentage point increment, servicers
-// should _not_ round the interest rate first.
-// Fix applied to Unofficial Calculator -- May 2012
- function doReduceRateByStep(step, floor){
- if(ml.mlRate1to5 > floor) {
- ml.mlRate1to5 = ml.mlRate1to5 - step;
- if (ml.mlRate1to5 < floor){ ml.mlRate1to5 = floor }
- if (ml.mlRate1to5<=0){ ml.mlRate1to5=0.000001;}
- ml.mlMoPayment1to5 = getPayment1to5();
- mlMergeHAMPfuture();
- ml.mlCalculatorStep = 'Reducing Rate to '+ml.mlRate1to5+'%';
- return true;
- }
- return false;
- }
-
-
- function doIncreaseLengthByStep(stepMonths, maxLength) {
- if(ml.mlMonths < maxLength) {
- ml.mlMonths += stepMonths;
- ml.mlMoPayment1to5 = getPayment1to5();
- mlMergeHAMPfuture();
- ml.mlCalculatorStep = 'Increasing time to pay to '+ml.mlMonths+' months';
- return true;
- }
- return false;
- }
-
-
- function doIncreaseBalloonByStep(stepBalloon) {
- if(ml.mlBalloon < ml.mlUnpaid) {
- ml.mlBalloon += stepBalloon;
- ml.mlMoPayment1to5 = getPayment1to5();
- mlMergeHAMPfuture();
- ml.mlCalculatorStep = 'Creating balloon payment of $'+ml.mlBalloon;
- return true;
- }
- return false;
- }
-
- function doAnimationStep(){
- if (q.poDoPR){
- if (doPrincipalReductionByStep(1000,1.15)){ return true; }
- }
- if (policyLengthBeforeRate()){
- if (doIncreaseLengthByStep(1,480)){ return true; }
- if (doReduceRateByStep(0.125, 2.0)){ return true; }
- } else {
- if (doReduceRateByStep(0.125, 2.0)){ return true; }
- if (doIncreaseLengthByStep(1,480)){ return true; }
- }
- if (doIncreaseBalloonByStep(1000)){ return true; }
- ml.mlCalculatorStep = 'Calculations finished -- Final result';
- return false;
- }
-
- function init(){
- readQ();
- if (!q.poTargetAGIPct){ q.poTargetAGIPct = 31; }
- ml = {
- 'mlUnpaid': q.olUnpaid,
- 'mlPR': 0,
- 'mlLTV': Math.round(100*q.olUnpaid/q.olHomeMarketValue),
- 'mlTargetAGIPct': q.poTargetAGIPct,
- 'mlMoTotalTargetPayment': Math.round(q.poTargetAGIPct*q.boMoGrossIncome/100.0),
- 'mlMoMiscHousingExpense': q.boMoMiscHousingExpense,
- 'mlMoTargetPayment': '',
- 'mlRate1to5': q.olRate,
- 'mlMoPayment1to5': '',
- 'mlMonths': q.olMoRemain,
- 'mlChangeMonths': 'no changes',
- 'mlChangeRates': '',
- 'mlChangePayments': '',
- 'mlBalloon': 0.00
- };
- ml.mlMoTargetPayment = Math.round(ml.mlMoTotalTargetPayment-ml.mlMoMiscHousingExpense);
- ml.mlMoPayment1to5 = getPayment1to5();
- writeML();
- return true;
- }
-
- function loanIsAffordable(){
- // supposed to stop before going under Target
- // add small fudge factor to stay close to, but above Target
- return (ml.mlMoPayment1to5 <= (ml.mlMoTargetPayment*1.01));
- }
-
- function startAnimation(){
- if (animationRunning === 0){
- init();
- if ( loanIsAffordable() ){
- ml.mlCalculatorStep = "This loan already affordable: Final result -- no modification";
- writeML();
- } else {
- newAnimation();
- animationRunning=1;
- }
- }
- return true;
- }
-
- function newAnimation(){
- var frameDelay = (q.frameDelay)? q.frameDelay: 0.2;
- animationRunning=1;
- new PeriodicalExecuter(function(pe){
- if ( loanIsAffordable() || (!doAnimationStep())){
- ml.mlCalculatorStep = 'Finished calculations -- Final result';
- animationRunning=0;
- pe.stop();
- }
- writeML();
- }, frameDelay);
- return true;
- }
-
- return {
- 'init': init,
- 'startAnimation': startAnimation
- };
-
-}();
View
806 UnofficialHampLib3.js
@@ -0,0 +1,806 @@
+// Unofficial HAMP Library for Javascript v3
+// (C) 2012 Dr Paul Brewer
+// Licensed under version 2 of the GNU General Public License
+//
+// VARIABLE NAMING CONVENTIONS
+//
+// Hungarian notation prefixes for variable names:
+// bo - borrower
+// ol - original loan
+// fm - Freddie Mac public data
+// ml - modified loan
+// po - policy
+//
+// expected elements in Q hash (case study or UI inputs)
+// boMoGrossIncome -- borrowers monthly gross income
+// boMoMiscHousingExpense -- borrowers (approved) misc housing expense
+// olUnpaid -- original loan unpaid balance
+// olHomeMarketValue -- home value in todays market
+// olMoRemain -- original loan months remaining
+// olRate -- original loan interest rate
+// fmCap -- freddie mac cap rate (30 yr PMMS rate)
+// poDoPR -- 1 for alternative (principal-reduction) waterfall
+// poDoLenderVariation -- check if principal reduction exceeds 5%
+// if so, lengthen loan then reduce rate
+//
+// A HAMP result hash contains these elements (outputs)
+// all result elements are unformatted strings, should be rounded to nearest dollar for dollar values
+// mlTargetAGIPct
+// mlPR = Principal Reduction
+// mlUnpaid = new Unpaid balance = olUnpaid - mlPR
+// mlLTV = 100 * mlUnpaid/olHomeMarketValue
+// mlMoTotalTargetPayment = mlTargetAGIPCT % of bMoGrossIncome
+// mlMoMiscHousingExpense = copied from bMoMiscHousingExpense
+// mlMoTargetPayment = target for loan payment, == total-misc
+// mlRate1to5 -- interest rate first 5 years
+// mlMoPayment1to5 -- modified monthly loan payment first 5 years
+// mlMonths -- term (length) of modified loan in months
+// mlChangeMonths -- months for which rate changes occur -- as a string
+// mlChangeRates -- new rates that take effect on the months above -- as a string
+// mlChangePayments -- new payments that take effect on the months above -- as a string
+// mlBalloon -- balloon payment at the end, if any. if none, return a zero.
+// mlBalloonMax -- servicers not required to exceed max(30% mlUnpaid, <100%LTV)
+// mlTotalPayments -- total of all payments on loan for life of loan
+// mlFail -- 1 if the modification fails some policy test
+// mlFailReason -- string indicating why the modification failes
+
+function noFrames() {
+ if(top != self) {
+ document.write('');
+ alert("The web page you are visiting takes content from www.armdisarm.com and tries to display it as part of their own web page. Pressing OK will attempt to load www.armdisarm.com directly. Thanks -- Dr Paul Brewer armdisarm.com ");
+ top.location.replace(self.location.href);
+ }
+}
+
+function numerize(x){ var xx=1*x; return (isNaN(xx)?x:xx)}
+
+function roundStep(x, step) {
+ // returns x rounded to the nearest step
+ return step * Math.round(x / step);
+}
+
+function tagString(tag,opt){
+ var s = "<";
+ s = s + tag ;
+ for (var k in opt){
+ s = s + ' ' + k + '=' + '"' + opt[k] + '" ';
+ }
+ s = s + '>';
+ return s;
+}
+
+function ArrayPluckHTML(A, H, order, tableOptions){
+ var s = tagString('table',tableOptions);
+ return s.concat('<tr><th>',
+ H.join('</th><th>'),
+ '</th></tr>',
+ (_(A).map(function(r){ return '<tr><td>'+(_(order).map(function(e){ return r[e]; })).join('</td><td>') + '</td></tr>' ; })).join(''),
+ '</table>'
+ );
+}
+
+Tier1HAMP = function(qINPUTS){
+ var ml = {};
+ var mlRate = [];
+ var mlPayment = [];
+ var q = {};
+
+ function mlMergeHAMPfuture() {
+ var rate = ml.mlRate1to5;
+ var N,i,m,MonthArray,RateArray,AmortLoan,PaymentChangeArray;
+ mlRate = [];
+ mlPayment = [];
+ try {
+ if( (rate < q.fmCap) && (ml.mlMonths>60) ) {
+ N = Math.floor(q.fmCap - rate);
+ MonthArray = [];
+ for(i=0; i<=N; ++i){ MonthArray.push(60+12*i); }
+ RateArray = [];
+ for(i=1; i<=N; ++i){ RateArray.push(rate+i); }
+ RateArray.push(q.fmCap);
+ AmortLoan = ml.mlUnpaid - ml.mlBalloon;
+ PaymentChangeArray = _(TVM.VariableRateLoanPaymentArray(AmortLoan, ml.mlMonths, rate, MonthArray, RateArray)).map(Math.round);
+ ml.mlChangeMonths = MonthArray.join(' -- ');
+ ml.mlChangeRates = RateArray.join(' -- ');
+ ml.mlChangePayments = PaymentChangeArray.join(' -- ');
+ for(m=0;m<MonthArray[0];m++){ mlRate[m]=ml.mlRate1to5; mlPayment[m]=ml.mlMoPayment1to5; }
+ ml.mlTotalPayments = ml.mlMonths*ml.mlMoPayment1to5;
+ ml.mlTotalPayments += (PaymentChangeArray[0] - ml.mlMoPayment1to5) * (ml.mlMonths - MonthArray[0]);
+ for(i=1;i<=N;++i){
+ if(ml.mlMonths > MonthArray[i]) {
+ ml.mlTotalPayments += (PaymentChangeArray[i]-PaymentChangeArray[i-1]) * (ml.mlMonths-MonthArray[i]);
+ }
+ }
+ MonthArray.push(ml.mlMonths);
+ for(i=1;i<=N+1;++i){
+ for(m=MonthArray[i-1]; m<Math.min(ml.mlMonths,MonthArray[i]); m++){
+ mlRate[m]=RateArray[i-1];
+ mlPayment[m]=PaymentChangeArray[i-1];
+ }
+ }
+ } else {
+ ml.mlTotalPayments = ml.mlMonths * ml.mlMoPayment1to5;
+ for(m=0;m<ml.mlMonths;m++){ mlRate[m]=ml.mlRate1to5; mlPayment[m]=ml.mlMoPayment1to5; }
+ }
+ } catch(e){ console.log(e); }
+ ml.mlTotalPayments = Math.round(ml.mlTotalPayments+ml.mlBalloon);
+ }
+
+ function getPayment1to5(){
+ return Math.round(TVM.StandardLoanPayment(ml.mlRate1to5,ml.mlUnpaid-ml.mlBalloon,ml.mlMonths));
+ }
+
+ function policyLengthBeforeRate(){
+ // see MHA Handbook v3.3, p.81, sect 6.4.4 Variation from the Alternative Modification Waterfall
+ // lender is allowed to modify length before reducing rate if more than 5% of principal is forgiven
+ return (q.poDoPR && q.poDoLenderVariation && ml.mlPR && (ml.mlPR > (0.05*q.olUnpaid)));
+ }
+
+ function doPrincipalReductionByStep(step,floorLTV){
+ if (!ml.mlUnpaid){ ml.mlUnpaid = q.olUnpaid-ml.mlPR; }
+ try {
+ if (ml.mlUnpaid > (floorLTV*q.olHomeMarketValue)){
+ ml.mlPR += step;
+ // MHA Handbook, v4.0 (6.6.1) says PR counts towards limit
+ if (ml.mlBalloonMax > 0){ ml.mlBalloonMax += -1*step;} else { ml.mlBalloonMax = 0; }
+ ml.mlUnpaid = q.olUnpaid-ml.mlPR;
+ ml.mlLTV = Math.round(100*ml.mlUnpaid/q.olHomeMarketValue);
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Reducing Principal to $'+ml.mlUnpaid;
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+
+ // see MhaHandbook v3.3, section 6.3.2 Step 2 -- Interest Rate Reduction
+ // If the current rate is not at a 0.125 percentage point increment, servicers
+ // should _not_ round the interest rate first.
+ // Fix applied to Unofficial Calculator -- May 2012
+ function doReduceRateByStep(step, floor){
+ try {
+ if(ml.mlRate1to5 > floor) {
+ ml.mlRate1to5 = ml.mlRate1to5 - step;
+ if (ml.mlRate1to5 < floor){ ml.mlRate1to5 = floor }
+ if (ml.mlRate1to5<=0){ ml.mlRate1to5=0.000001;}
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Reducing Rate to '+ml.mlRate1to5+'%';
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+
+ function doIncreaseLengthByStep(stepMonths, maxLength) {
+ try {
+ if(ml.mlMonths < maxLength) {
+ ml.mlMonths += stepMonths;
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Increasing time to pay to '+ml.mlMonths+' months';
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+
+ function doIncreaseBalloonByStep(stepBalloon) {
+ try {
+ if(ml.mlBalloon < ml.mlUnpaid) {
+ ml.mlBalloon += stepBalloon;
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Creating balloon payment of $'+ml.mlBalloon;
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function doCheck(){
+ try {
+ if(ml.mlBalloon && ml.mlBalloonMax && (ml.mlBalloon > ml.mlBalloonMax)){
+ ml.mlFail=1;
+ ml.mlFailReason='Balloon exceeds maximum suggested';
+ return false;
+ }
+ return true;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function doStep(){
+ try {
+ if (!loanIsAffordable()) {
+ if (q.poDoPR){
+ if (doPrincipalReductionByStep(1000,1.15)){ return true; }
+ }
+ if (policyLengthBeforeRate()){
+ if (doIncreaseLengthByStep(1,480)){ return true; }
+ if (doReduceRateByStep(0.125, 2.0)){ return true; }
+ } else {
+ if (doReduceRateByStep(0.125, 2.0)){ return true; }
+ if (doIncreaseLengthByStep(1,480)){ return true; }
+ }
+ if (doIncreaseBalloonByStep(1000)){ return true; }
+ }
+ ml.mlCalculatorStep = 'Finished calculations -- Final result';
+ doCheck();
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function init(qINPUT){
+ try {
+ q = _.clone(qINPUT);
+ if (!q.poTargetAGIPct){ q.poTargetAGIPct = 31; }
+ ml = null;
+ ml = {
+ 'mlUnpaid': q.olUnpaid,
+ 'mlPR': 0,
+ 'mlLTV': Math.round(100*q.olUnpaid/q.olHomeMarketValue),
+ 'mlTargetAGIPct': q.poTargetAGIPct,
+ 'mlMoTotalTargetPayment': Math.round(q.poTargetAGIPct*q.boMoGrossIncome/100.0),
+ 'mlMoMiscHousingExpense': q.boMoMiscHousingExpense,
+ 'mlMoTargetPayment': '',
+ 'mlRate1to5': q.olRate,
+ 'mlMoPayment1to5': '',
+ 'mlMonths': q.olMoRemain,
+ 'mlChangeMonths': 'no changes',
+ 'mlChangeRates': '',
+ 'mlChangePayments': '',
+ 'mlBalloon': 0.00,
+ 'mlBalloonMax': Math.round(Math.max(0.30*q.olUnpaid, (q.olUnpaid-q.olHomeMarketValue))),
+ 'mlFail': 0,
+ 'mlFailReason':''
+ };
+ ml.mlMoTargetPayment = Math.round(ml.mlMoTotalTargetPayment-ml.mlMoMiscHousingExpense);
+ ml.mlMoPayment1to5 = getPayment1to5();
+ ml.mlTotalPayments = ml.mlMonths * ml.mlMoPayment1to5;
+ if ( loanIsAffordable() ){
+ ml.mlCalculatorStep = "This loan already affordable: Final result -- no modification";
+ return false;
+ }
+ return true;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function getML() { return _.clone(ml); }
+ function getQ() { return _.clone(q); }
+
+ function loanIsAffordable(){
+ // supposed to stop before going under Target
+ // add small fudge factor to stay close to, but above Target
+ return (ml.mlMoPayment1to5 <= (ml.mlMoTargetPayment*1.01));
+ }
+
+ function finish(){
+ while (doStep()){ }
+ return ml;
+ }
+
+
+ function scheduleOfPayments(){
+ try {
+ var schedule = [];
+ var firstMonth = {'Month': 1,
+ 'PreviousBalance': q.olUnpaid,
+ 'InterestBearing':ml.mlUnpaid-ml.mlBalloon,
+ 'NonInterestBearing': (ml.mlPR+ml.mlBalloon),
+ 'Payment': mlPayment[0],
+ 'InterestRate': mlRate[0],
+ 'InterestPaid': 0,
+ 'PrincipalPaid': 0,
+ 'PrincipalForgiveness': ml.mlPR,
+ 'NewBalance':0
+ };
+ var row = {};
+ var m = 1;
+ firstMonth.InterestPaid = Math.round(firstMonth.InterestBearing*firstMonth.InterestRate/1200.0);
+ firstMonth.PrincipalPaid = firstMonth.Payment - firstMonth.InterestPaid;
+ firstMonth.NewBalance = firstMonth.PreviousBalance-firstMonth.PrincipalPaid-firstMonth.PrincipalForgiveness;
+ schedule.push(firstMonth);
+ while( m < ml.mlMonths ){
+ row = {'Month':m+1,
+ 'PreviousBalance': schedule[m-1].NewBalance,
+ 'InterestBearing': schedule[m-1].InterestBearing-schedule[m-1].PrincipalPaid,
+ 'NonInterestBearing': schedule[m-1].NonInterestBearing-schedule[m-1].PrincipalForgiveness,
+ 'Payment': mlPayment[m],
+ 'InterestRate': mlRate[m],
+ 'InterestPaid': 0,
+ 'PrincipalPaid': 0,
+ 'PrincipalForgiveness': 0,
+ 'NewBalance':0
+ };
+ row.InterestPaid = Math.round(row.InterestBearing*row.InterestRate/1200.0);
+ row.PrincipalPaid = row.Payment - row.InterestPaid;
+ row.NewBalance = row.PreviousBalance - row.PrincipalPaid - row.PrincipalForgiveness;
+ schedule.push(row);
+ m++;
+ }
+ return schedule;
+ } catch(e){ console.log(e); }
+ return [];
+ }
+
+ function scheduleOfPaymentsHTML(){
+ var headings = ['Month','Previous Balance','Interest Bearing','Non Interest Bearing','Payment','Interest Rate','Interest Payment','Principal Payment','Principal Forgiven','New Balance'];
+ var order = ['Month','PreviousBalance','InterestBearing','NonInterestBearing','Payment','InterestRate','InterestPaid','PrincipalPaid','PrincipalForgiveness','NewBalance'];
+ var preamble = '<html><head><title>Schedule Of Payments</title></head><body>';
+ var post = '</body></html>';
+ return ArrayPluckHTML(scheduleOfPayments(),headings,order,{'border':1, 'style': 'text-align: right;'});
+ }
+
+ // call init with qINPUTS and return an object pointing to functions we can call later
+
+ init(qINPUTS);
+
+ return {'getML': getML,
+ 'getQ': getQ,
+ 'loanIsAffordable': loanIsAffordable,
+ 'doStep': doStep,
+ 'finish': finish,
+ 'scheduleOfPayments': scheduleOfPayments,
+ 'scheduleOfPaymentsHTML': scheduleOfPaymentsHTML
+ };
+
+};
+
+Tier2HAMP = function(qINPUTS){
+ var ml = {};
+ var mlRate = [];
+ var mlPayment = [];
+ var q = {};
+
+ function mlMergeHAMPfuture() {
+ try {
+ mlRate = [];
+ mlPayment = [];
+ ml.mlTotalPayments = ml.mlMonths * ml.mlMoPayment1to5;
+ for(m=0;m<ml.mlMonths;m++){ mlRate[m]=ml.mlRate1to5; mlPayment[m]=ml.mlMoPayment1to5; }
+ ml.mlTotalPayments = Math.round(ml.mlTotalPayments+ml.mlBalloon);
+ } catch(e){ console.log(e); }
+ }
+
+ function getPayment1to5(){
+ return Math.round(TVM.StandardLoanPayment(ml.mlRate1to5,ml.mlUnpaid-ml.mlBalloon,ml.mlMonths));
+ }
+
+ function doReduceRate(){
+ try {
+ var hamp2Rate = (Math.ceil(8.0*q.fmCap)/8.0)+0.5;
+ // hamp 2 rate is defined in MHA Handook v4.0 section 6.3.2.2
+ // hamp 2 Rate = FM 30 YR rate, rounded up to the next 1/8%, plus risk prem of 0.5%
+ if(ml.mlRate1to5 != hamp2Rate) {
+ ml.mlRate1to5 = hamp2Rate;
+ if (ml.mlRate1to5<=0){ ml.mlRate1to5=0.000001;}
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Reducing Rate to '+ml.mlRate1to5+'%';
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+
+ function doIncreaseLength() {
+ try {
+ if(ml.mlMonths < 480) {
+ ml.mlMonths = 480;
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Increasing time to pay to '+ml.mlMonths+' months';
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ var canTryBalloon = 1;
+
+ function doBalloon() {
+ try {
+ if(canTryBalloon) {
+ ml.mlBalloon = Math.round(Math.max(0,Math.min(0.30*q.olUnpaid, (q.olUnpaid-1.15*q.olHomeMarketValue))));
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Creating balloon payment of $'+ml.mlBalloon;
+ canTryBalloon=0;
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ var canTryPR = 1;
+
+ function doPrincipalReduction(){
+ try {
+ if (!ml.mlUnpaid){ ml.mlUnpaid = q.olUnpaid-ml.mlPR; }
+ if (canTryPR){
+ ml.mlPR = Math.round(Math.max(0,Math.min(0.30*q.olUnpaid, (q.olUnpaid-1.15*q.olHomeMarketValue))));
+ ml.mlUnpaid = q.olUnpaid-ml.mlPR;
+ ml.mlLTV = Math.round(100*ml.mlUnpaid/q.olHomeMarketValue);
+ ml.mlMoPayment1to5 = getPayment1to5();
+ mlMergeHAMPfuture();
+ ml.mlCalculatorStep = 'Reducing Principal to $'+ml.mlUnpaid;
+ canTryPR = 0;
+ return true;
+ }
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function doCheck(){
+ try {
+ var totalMoPayment;
+ if ((ml.mlMoPayment1to5+ml.mlMoMiscHousingExpense) > ml.mlMoTotalTargetPaymentHigh){
+ ml.mlFail=1;
+ ml.mlFailReason='Payments exceed target range';
+ return false;
+ }
+ if ((ml.mlMoPayment1to5+ml.mlMoMiscHousingExpense) < ml.mlMoTotalTargetPaymentLow){
+ ml.mlFail=1;
+ ml.mlFailReason='Payments below target range';
+ return false;
+ }
+ return true;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function doStep(){
+ try {
+ if (doReduceRate()){ return true; }
+ if (doIncreaseLength()){ return true; }
+ if (q.poDoPR){
+ if (doPrincipalReduction()){ return true; }
+ } else {
+ if (doBalloon()){ return true; }
+ }
+ ml.mlCalculatorStep = 'Finished calculations -- Final result';
+ doCheck();
+ return false;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function init(qINPUT){
+ try {
+ q = _.clone(qINPUT);
+ if (!q.poH2TargetAGIPctLow){ q.poH2TargetAGIPctLow = 25; }
+ if (!q.poH2TargetAGIPctHigh){ q.poH2TargetAGIPctHigh = 42; }
+ ml = null;
+ ml = {
+ 'mlUnpaid': q.olUnpaid,
+ 'mlPR': 0,
+ 'mlLTV': Math.round(100*q.olUnpaid/q.olHomeMarketValue),
+ 'mlTargetAGIPct': q.poH2TargetAGIPctLow+'-'+q.poH2TargetAGIPctHigh,
+ 'mlMoTotalTargetPaymentLow': Math.round(q.poH2TargetAGIPctLow*q.boMoGrossIncome/100.0),
+ 'mlMoTotalTargetPaymentHigh': Math.round(q.poH2TargetAGIPctHigh*q.boMoGrossIncome/100.0),
+ 'mlMoMiscHousingExpense': q.boMoMiscHousingExpense,
+ 'mlMoTargetPayment': '',
+ 'mlRate1to5': q.olRate,
+ 'mlMoPayment1to5': '',
+ 'mlMonths': q.olMoRemain,
+ 'mlChangeMonths': 'no changes',
+ 'mlChangeRates': '',
+ 'mlChangePayments': '',
+ 'mlBalloon': 0.00,
+ 'mlBalloonMax': 'H2 No Max',
+ 'mlFail': 0,
+ 'mlFailReason':''
+ };
+ ml.mlMoTotalTargetPayment = ml.mlMoTotalTargetPaymentLow+'-'+ml.mlMoTotalTargetPaymentHigh;
+ ml.mlMoTargetPayment = Math.round(ml.mlMoTotalTargetPaymentLow-ml.mlMoMiscHousingExpense) +'-'+Math.round(ml.mlMoTotalTargetPaymentHigh-ml.mlMoMiscHousingExpense);
+ ml.mlMoPayment1to5 = getPayment1to5();
+ ml.mlTotalPayments = ml.mlMonths * ml.mlMoPayment1to5;
+ return true;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+
+ function getML() { return _.clone(ml); }
+ function getQ() { return _.clone(q); }
+
+ function loanIsAffordable(){
+ // in Hamp2 all steps must be completed without regard to affordability
+ // could deal with this in a abstraction layer
+ return false;
+ }
+
+ function finish(){
+ while (doStep()){ }
+ return ml;
+ }
+
+ function scheduleOfPayments(){
+ try {
+ var schedule = [];
+ var firstMonth = {'Month': 1,
+ 'PreviousBalance': q.olUnpaid,
+ 'InterestBearing':ml.mlUnpaid-ml.mlBalloon,
+ 'NonInterestBearing': (ml.mlPR+ml.mlBalloon),
+ 'Payment': mlPayment[0],
+ 'InterestRate': mlRate[0],
+ 'InterestPaid': 0,
+ 'PrincipalPaid': 0,
+ 'PrincipalForgiveness': ml.mlPR,
+ 'NewBalance':0
+ };
+ var row = {};
+ var m = 1;
+ firstMonth.InterestPaid = Math.round(firstMonth.InterestBearing*firstMonth.InterestRate/1200.0);
+ firstMonth.PrincipalPaid = firstMonth.Payment - firstMonth.InterestPaid;
+ firstMonth.NewBalance = firstMonth.PreviousBalance-firstMonth.PrincipalPaid-firstMonth.PrincipalForgiveness;
+ schedule.push(firstMonth);
+ while( m < ml.mlMonths ){
+ row = {'Month':m+1,
+ 'PreviousBalance': schedule[m-1].NewBalance,
+ 'InterestBearing': schedule[m-1].InterestBearing-schedule[m-1].PrincipalPaid,
+ 'NonInterestBearing': schedule[m-1].NonInterestBearing-schedule[m-1].PrincipalForgiveness,
+ 'Payment': mlPayment[m],
+ 'InterestRate': mlRate[m],
+ 'InterestPaid': 0,
+ 'PrincipalPaid': 0,
+ 'PrincipalForgiveness': 0,
+ 'NewBalance':0
+ };
+ row.InterestPaid = Math.round(row.InterestBearing*row.InterestRate/1200.0);
+ row.PrincipalPaid = row.Payment - row.InterestPaid;
+ row.NewBalance = row.PreviousBalance - row.PrincipalPaid - row.PrincipalForgiveness;
+ schedule.push(row);
+ m++;
+ }
+ return schedule;
+ } catch(e){ console.log(e); }
+ return [];
+ }
+
+ function scheduleOfPaymentsHTML(){
+ var headings = ['Month','Previous Balance','Interest Bearing','Non Interest Bearing','Payment','Interest Rate','Interest Payment','Principal Payment','Principal Forgiven','New Balance'];
+ var order = ['Month','PreviousBalance','InterestBearing','NonInterestBearing','Payment','InterestRate','InterestPaid','PrincipalPaid','PrincipalForgiveness','NewBalance'];
+ var preamble = '<html><head><title>Schedule Of Payments</title></head><body>';
+ var post = '</body></html>';
+ return ArrayPluckHTML(scheduleOfPayments(),headings,order,{'border':1, 'style': 'text-align: right;'});
+ }
+
+ // call init with qINPUTS and return an object pointing to functions we can call later
+
+ init(qINPUTS);
+
+ return {'getML': getML,
+ 'getQ': getQ,
+ 'loanIsAffordable': loanIsAffordable,
+ 'doStep': doStep,
+ 'finish': finish,
+ 'scheduleOfPayments': scheduleOfPayments,
+ 'scheduleOfPaymentsHTML': scheduleOfPaymentsHTML
+ };
+
+};
+
+
+AnyTierHAMP = function(qINPUT){
+ var Calculator;
+ if (qINPUT.poHampTier==2){
+ Calculator = Tier2HAMP(qINPUT);
+ } else {
+ Calculator = Tier1HAMP(qINPUT);
+ }
+ return Calculator;
+};
+
+
+function readInputs(){
+ var q = {};
+ var unknownItem = [];
+
+ try {
+ $(':input').each(function(i){
+ try {
+ if ((this.type === "text") || (this.type === "hidden")){
+ q[this.id]=numerize(this.value);
+ } else if (this.type === "checkbox"){
+ q[this.id]=(this.checked)?1:0;
+ } else {
+ unknownItem.push(this.id);
+ }
+ } catch(e) {
+ console.log('readInputs() this.id='+this.id+' Exception:'+e);
+ }
+ });
+
+ _(unknownItem).each(function(item){
+ try {
+ q[item] = $('#'+item+' :selected').val();
+ } catch(e) {
+ if (item.length && item.length>0) { delete q[item]; }
+ }
+ });
+ } catch(e){ console.log(e); }
+
+ return q;
+};
+
+UHC = function(){
+
+ var animationRunning = 0;
+
+// H will hold an instance of AnyTierHAMP to do the calculation
+// but empty for now
+
+ var H;
+ var q = {};
+
+ function writeML(){
+ var ml = H.getML();
+ try {
+ $('span[id^="ml"]').html(function(index,oldhtml){ return ml[this.id] });
+ } catch(e){ console.log(e); }
+ // "this" was set to each el by JQuery html(), see JQuery html() docs
+ return ml;
+ }
+
+ function startAnimation(){
+ q = readInputs();
+ if (animationRunning === 0){
+ H = AnyTierHAMP(q);
+ writeML();
+ if ( !H.loanIsAffordable() ){
+ newAnimation();
+ }
+ }
+ return true;
+ }
+
+ function newAnimation(){
+ animationRunning=1;
+ try {
+ $('#skipDiv').show();
+ $('#popupDiv').hide();
+ } catch(e){ console.log(e); }
+ loopAnimation();
+ try { hampGraph.PopulateXLimits(); } catch(e) {}
+ return true;
+ }
+
+ function loopAnimation(){
+ if ( (animationRunning===0) || (!H.doStep()) ){
+ animationRunning=0;
+ try {
+ $('#skipDiv').hide();
+ $('#popupDiv').show();
+ } catch(e){ console.log(e); }
+ } else {
+ try {
+ _.delay(loopAnimation,1000*( (q.frameDelay)? q.frameDelay: 0.2 ) );
+ } catch(e){ console.log(e); }
+ }
+ writeML();
+ }
+
+ function skipToEnd(){
+ try {
+ if(animationRunning===1){
+ $('#skipDiv').hide();
+ animationRunning=0;
+ H.finish();
+ writeML();
+ }
+ } catch(e){ console.log(e); }
+ }
+
+ function popupScheduleOfPayments(){
+ var w;
+ skipToEnd();
+ try {
+ w=window.open("","","");
+ $(w.document.body).append(H.scheduleOfPaymentsHTML());
+ } catch(e){ console.log(e); }
+ }
+
+ return {
+ 'startAnimation': startAnimation,
+ 'skipToEnd': skipToEnd,
+ 'popupScheduleOfPayments': popupScheduleOfPayments
+ };
+
+}();
+
+hampGraph = {
+ 'PopulateXLimits': function(){
+ var q = readInputs();
+ var center = q[q.gcX];
+ try {
+ $('#gcFrom').val(Math.round(0.7*center));
+ $('#gcTo').val(Math.round(1.3*center));
+ } catch(e){ console.log(e); }
+ },
+ 'Calculate': function(qq){
+ var q = _.clone(qq);
+ var j=0;
+ var points = 20;
+ var data = [];
+ var result;
+ while(j <= points){
+ try {
+ q[q.gcX] = ( (j*q.gcTo) + ((points-j)*q.gcFrom) )/points;
+ result = AnyTierHAMP(q).finish();
+ if ( (result.mlFail===0) || q.gcIgnoreFail ){ data.push([q[q.gcX],result[q.gcY]]); }
+ } catch(e) { console.log(e); }
+ j = j + 1;
+ }
+ return data;
+ },
+ 'Draw': function(qq, divid){
+ var q = _.clone(qq);
+ var d=[],d1NoPR=[],d1PR=[],d1PRLV=[],d2NoPR=[],d2PR=[];
+ try { $('#'+divid).html(""); } catch(e){ console.log(e); }
+ try { $('#'+divid+'Title').html(q.gcY+' vs '+q.gcX); } catch(e){ console.log(e); };
+ try {
+ if (q.gcVaryRules){
+ // vary rules in q to make multiline graph; use different colors
+ q.poHampTier=1;
+ q.poDoPR=0;
+ q.poDoLenderVariation=0;
+ d1NoPR = hampGraph.Calculate(q);
+ q.poDoPR=1;
+ d1PR = hampGraph.Calculate(q);
+ q.poDoLenderVariation=1;
+ d1PRLV = hampGraph.Calculate(q);
+ q.poHampTier=2;
+ q.poDoPR=0;
+ q.poDoLenderVariation=0;
+ d2NoPR = hampGraph.Calculate(q);
+ q.poDoPR=1;
+ d2PR = hampGraph.Calculate(q);
+ d=[d1NoPR,d1PR,d1PRLV,d2NoPR,d2PR];
+ } else {
+ // no variation of rules to make single line graph -- use original rules in q
+ d=[hampGraph.Calculate(q)];
+ }
+ $.jqplot(divid, d);
+ return true;
+ } catch(e){ console.log(e); }
+ return false;
+ },
+ 'Create': function(){
+ var q = readInputs();
+ var allGraphs;
+ try {
+ $("#Graph1, #GraphAll").hide();
+ if (q.gcY !== "almostEverything"){
+ $('#Graph1').show();
+ hampGraph.Draw(q,"Graph1");
+ return true;
+ }
+ $('#GraphAll').show();
+ allGraphs = ['mlTotalPayments','mlMoPayment1to5','mlPR','mlUnpaid','mlRate1to5','mlMonths','mlBalloon'];
+ _.each(allGraphs, function(yvar, i){
+ var ii = i+1;
+ q.gcY = yvar;
+ hampGraph.Draw(q,'GraphAll'+ii);
+ });
+ return true;
+ } catch(e){ console.log(e); }
+ return false;
+ }
+};
+
View
339 gpl-2.0.txt
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
View
259 jquery.jqplot.css
@@ -0,0 +1,259 @@
+/*rules for the plot target div. These will be cascaded down to all plot elements according to css rules*/
+.jqplot-target {
+ position: relative;
+ color: #666666;
+ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
+ font-size: 1em;
+/* height: 300px;
+ width: 400px;*/
+}
+
+/*rules applied to all axes*/
+.jqplot-axis {
+ font-size: 0.75em;
+}
+
+.jqplot-xaxis {
+ margin-top: 10px;
+}
+
+.jqplot-x2axis {
+ margin-bottom: 10px;
+}
+
+.jqplot-yaxis {
+ margin-right: 10px;
+}
+
+.jqplot-y2axis, .jqplot-y3axis, .jqplot-y4axis, .jqplot-y5axis, .jqplot-y6axis, .jqplot-y7axis, .jqplot-y8axis, .jqplot-y9axis, .jqplot-yMidAxis {
+ margin-left: 10px;
+ margin-right: 10px;
+}
+
+/*rules applied to all axis tick divs*/
+.jqplot-axis-tick, .jqplot-xaxis-tick, .jqplot-yaxis-tick, .jqplot-x2axis-tick, .jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick, .jqplot-yMidAxis-tick {
+ position: absolute;
+ white-space: pre;
+}
+
+
+.jqplot-xaxis-tick {
+ top: 0px;
+ /* initial position untill tick is drawn in proper place */
+ left: 15px;
+/* padding-top: 10px;*/
+ vertical-align: top;
+}
+
+.jqplot-x2axis-tick {
+ bottom: 0px;
+ /* initial position untill tick is drawn in proper place */
+ left: 15px;
+/* padding-bottom: 10px;*/
+ vertical-align: bottom;
+}
+
+.jqplot-yaxis-tick {
+ right: 0px;
+ /* initial position untill tick is drawn in proper place */
+ top: 15px;
+/* padding-right: 10px;*/
+ text-align: right;
+}
+
+.jqplot-yaxis-tick.jqplot-breakTick {
+ right: -20px;
+ margin-right: 0px;
+ padding:1px 5px 1px 5px;
+/* background-color: white;*/
+ z-index: 2;
+ font-size: 1.5em;
+}
+
+.jqplot-y2axis-tick, .jqplot-y3axis-tick, .jqplot-y4axis-tick, .jqplot-y5axis-tick, .jqplot-y6axis-tick, .jqplot-y7axis-tick, .jqplot-y8axis-tick, .jqplot-y9axis-tick {
+ left: 0px;
+ /* initial position untill tick is drawn in proper place */
+ top: 15px;
+/* padding-left: 10px;*/
+/* padding-right: 15px;*/
+ text-align: left;
+}
+
+.jqplot-yMidAxis-tick {
+ text-align: center;
+ white-space: nowrap;
+}
+
+.jqplot-xaxis-label {
+ margin-top: 10px;
+ font-size: 11pt;
+ position: absolute;
+}
+
+.jqplot-x2axis-label {
+ margin-bottom: 10px;
+ font-size: 11pt;
+ position: absolute;
+}
+
+.jqplot-yaxis-label {
+ margin-right: 10px;
+/* text-align: center;*/
+ font-size: 11pt;
+ position: absolute;
+}
+
+.jqplot-yMidAxis-label {
+ font-size: 11pt;
+ position: absolute;
+}
+
+.jqplot-y2axis-label, .jqplot-y3axis-label, .jqplot-y4axis-label, .jqplot-y5axis-label, .jqplot-y6axis-label, .jqplot-y7axis-label, .jqplot-y8axis-label, .jqplot-y9axis-label {
+/* text-align: center;*/
+ font-size: 11pt;
+ margin-left: 10px;
+ position: absolute;
+}
+
+.jqplot-meterGauge-tick {
+ font-size: 0.75em;
+ color: #999999;
+}
+
+.jqplot-meterGauge-label {
+ font-size: 1em;
+ color: #999999;
+}
+
+table.jqplot-table-legend {
+ margin-top: 12px;
+ margin-bottom: 12px;
+ margin-left: 12px;
+ margin-right: 12px;
+}
+
+table.jqplot-table-legend, table.jqplot-cursor-legend {
+ background-color: rgba(255,255,255,0.6);
+ border: 1px solid #cccccc;
+ position: absolute;
+ font-size: 0.75em;
+}
+
+td.jqplot-table-legend {
+ vertical-align:middle;
+}
+
+/*
+These rules could be used instead of assigning
+element styles and relying on js object properties.
+*/
+
+/*
+td.jqplot-table-legend-swatch {
+ padding-top: 0.5em;
+ text-align: center;
+}
+
+tr.jqplot-table-legend:first td.jqplot-table-legend-swatch {
+ padding-top: 0px;
+}
+*/
+
+td.jqplot-seriesToggle:hover, td.jqplot-seriesToggle:active {
+ cursor: pointer;
+}
+
+.jqplot-table-legend .jqplot-series-hidden {
+ text-decoration: line-through;
+}
+
+div.jqplot-table-legend-swatch-outline {
+ border: 1px solid #cccccc;
+ padding:1px;
+}
+
+div.jqplot-table-legend-swatch {
+ width:0px;
+ height:0px;
+ border-top-width: 5px;
+ border-bottom-width: 5px;
+ border-left-width: 6px;
+ border-right-width: 6px;
+ border-top-style: solid;
+ border-bottom-style: solid;
+ border-left-style: solid;
+ border-right-style: solid;
+}
+
+.jqplot-title {
+ top: 0px;
+ left: 0px;
+ padding-bottom: 0.5em;
+ font-size: 1.2em;
+}
+
+table.jqplot-cursor-tooltip {
+ border: 1px solid #cccccc;
+ font-size: 0.75em;
+}
+
+
+.jqplot-cursor-tooltip {
+ border: 1px solid #cccccc;
+ font-size: 0.75em;
+ white-space: nowrap;
+ background: rgba(208,208,208,0.5);
+ padding: 1px;
+}
+
+.jqplot-highlighter-tooltip, .jqplot-canvasOverlay-tooltip {
+ border: 1px solid #cccccc;
+ font-size: 0.75em;
+ white-space: nowrap;
+ background: rgba(208,208,208,0.5);
+ padding: 1px;
+}
+
+.jqplot-point-label {
+ font-size: 0.75em;
+ z-index: 2;
+}
+
+td.jqplot-cursor-legend-swatch {
+ vertical-align: middle;
+ text-align: center;
+}
+
+div.jqplot-cursor-legend-swatch {
+ width: 1.2em;
+ height: 0.7em;
+}
+
+.jqplot-error {
+/* Styles added to the plot target container when there is an error go here.*/
+ text-align: center;
+}
+
+.jqplot-error-message {
+/* Styling of the custom error message div goes here.*/
+ position: relative;
+ top: 46%;
+ display: inline-block;
+}
+
+div.jqplot-bubble-label {
+ font-size: 0.8em;
+/* background: rgba(90%, 90%, 90%, 0.15);*/
+ padding-left: 2px;
+ padding-right: 2px;
+ color: rgb(20%, 20%, 20%);
+}
+
+div.jqplot-bubble-label.jqplot-bubble-label-highlight {
+ background: rgba(90%, 90%, 90%, 0.7);
+}
+
+div.jqplot-noData-container {
+ text-align: center;
+ background-color: rgba(96%, 96%, 96%, 0.3);
+}
View
57 jquery.jqplot.min.js
57 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 license.html
@@ -9,7 +9,7 @@
<p>Freddie Mac data iFrame, is property of Freddie Mac, and distributed under permission given by their public syndication policy as downloaded in July 2010
and under the doctrine of fair use. </p>
-<p>The original code of the Unofficial HAMP Loan Modification Calculator is (c) Dr Paul Brewer, and is free software licensed to the public under the <a target=_blank href="http://www.gnu.org/licenses/gpl-3.0.txt">Free Software Foundation's General Public License version 3 </a>, or any later version. <a target=_blank href="gpl-3.0.txt">Backup copy of license</a>.</p>
+<p>The original code of the Unofficial HAMP Loan Modification Calculator is (c) Dr Paul Brewer, and is free software licensed to the public under the <a target=_blank href="http://www.gnu.org/licenses/gpl-2.0.txt">Free Software Foundation's General Public License version 2 </a>, or any later version. <a target=_blank href="gpl-2.0.txt">Backup copy of license</a>.</p>
<p>The software is written in JavaScript. You can examine or download the source code freely at <a href="https://github.com/DrPaulBrewer/Unofficial-Loan-Modification-HAMP">Github DrPaulBrewer/Unofficial-Loan-Modification-HAMP</a>. </p>
View
224 skin.html
@@ -4,7 +4,13 @@
<meta charset="utf-8">
<!-- Unofficial HAMP Loan Modification Calculator (c) 2012 Dr Paul Brewer -->
<!-- This software comes with NO WARRANTY OF ANY KIND. -->
-<!-- This version: May 2012 -->
+<!-- This version: Oct 2012 -->
+<!-- License: GNU GPL v2 -->
+<!-- Note: You may NOT copy this website into your own, tweak it a bit, and claim copyright on the result -->
+<!-- YOU MAY ONLY DO THE THINGS PERMITTED IN THE GNU GENERAL PUBLIC LICENSE -->
+<!-- Change in Sept/Oct 2012 -->
+<!-- Added HAMP Tier 2, Sensitivity Graph, Schedule of Payments -->
+<!-- Changes in May 2012 -->
<!-- Added housing expenses line to calculation -->
<!-- Added Principal Reduction and Lenders' variation to calculation -->
<!-- Reviewed MHA Handbook v3.3 and made several small changes to match procedures -->
@@ -13,13 +19,13 @@
<!-- and end users must accept all risks of using the software. -->
<!-- I hereby license my original work in this file to the public under -->
-<!-- Free Software Foundation's GNU General Public License version 3 -->
+<!-- Free Software Foundation's GNU General Public License version 2 -->
<!-- -->
<!-- The full text of this license can be found at -->
-<!-- http://www.gnu.org/licenses/gpl-3.0.txt -->
+<!-- http://www.gnu.org/licenses/gpl-2.0.txt -->
<!-- -->
<!-- There is a public syndication link (an IFRAME) to Freddie Mac data -->
-<!-- at about line 80. That code is distributed under the doctrine of -->
+<!-- That code is distributed under the doctrine of -->
<!-- fair use and Freddie's explicit permission from its website and -->
<!-- therefore that portion of the code and data is not licensed by the GPL -->
<!-- but has been included in this file and will be removed from future -->
@@ -29,32 +35,47 @@
<!-- drpaulbrewer ( gmail ) -->
<title>The Unofficial HAMP Loan Modification Calculator</title>
-<style type="text/css">
-input {text-align:right}
-button {background-color:#FFD700; font-size:18px}
-#mlCalculatorStep {background-color:#EEC600}
-</style>
-<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
-<script src="UnofficialHampLib2.js"></script>
+<link rel=StyleSheet href="style.css" type="text/css" />
+<link rel="StyleSheet" type="text/css" href="jquery.jqplot.css" />
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
+<script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
+<script src="underscore-min.js"></script>
+<script src="TVM.js"></script>
+<script src="UnofficialHampLib3.js"></script>
<script>
function loadCalculator()
-{ noFrames(); };
+{ $('#skipDiv, #popupDiv, #Graph1, #GraphAll, #Feedback').hide(); };
</script>
</head>
<body onLoad='loadCalculator();'>
-<h1>The Unofficial HAMP Loan Modification Calculator v2.0</h1>
+<h1>The Unofficial HAMP Loan Modification Calculator v2.5-beta</h1>
+<noscript><h2>OH, NO! The calculations require JavaScript, but JavaScript is TURNED OFF.</h2>
+<h3>Ask your favorite computer expert how to turn JavaScript on, or please use a different computer -- Sorry... </h3>
+</noscript>
<ul>
-<li>All results are provided <b>completely free of charge</b>. Free. $0.00. Nada. Use "www.armdisarm.com" or "www.unofficialhampcalculator.com". Please beware of ripoffs!</li>
-<li>Calculations are based on independent research of public documents describing HAMP loan modification procedures, particularly <a target=_blank href="./documents/mhahandbook33.pdf">The MHA Handbook v3.3</a></li>
-<li>This unofficial calculator is not associated with the government or any bank and has not been independently reviewed, certified, or tested. </li>
-<li>Computer experts or enthusaists may examine the calculator program's source code, which I make available under the GNU General Public License. </li>
-<li>The software is offered for your free use WITHOUT WARRANTY OF ANY KIND and you agree that ALL USE IS AT YOUR OWN RISK</li>
-<li>Privacy policy: To protect your privacy, the calculator does not ask for personally identifying information. Javascript performs the calculations on your computer web browser, not our server. The loan INPUTS data are not recorded and exist only on your computer. Items that are logged for understanding the audience include: ip address, city, state or country, type of web browser. </li>
-<li>This version: May 19, 2012</li>
+<li><b>All calculations are provided completely free of charge</b>. Free. $0.00. Nada.
+</li>
+<li>Please <b>beware of scammers and idiots</b> who suggest bizarre schemes like stopping loan payments or signing away your home and leasing it back. </li>
+<li><b>I do not provide personalized help with loan modifications.</b> Free help is available from the governments toll free numbers listed at www.makinghomeaffordable.gov </li>
+<li><b>This unofficial calculator is not associated with the government or any bank </b>. Calculations are based on independent research of public documents describing HAMP loan modification procedures. Docs can be downloaded below.
+</li>
+<li>The calculator is implemented in 100% javascript and may be examined at the <a href="http://github.com/DrPaulBrewer/Unofficial-Loan-Modification-HAMP/tree/v2.0">source code repository</a>. This code is available under the GNU General Public License.</li>
+<li>This free software is <b>WITHOUT WARRANTY OF ANY KIND</b> and you agree that <b>ALL USE IS AT YOUR OWN RISK</b>. </li>
+<li>Calculations shown here may differ from those provided elsewhere for many reasons. Never make public accusations of fraud where a mistake, or different inputs, might also provide an explanation. </li>
+<li><b>Privacy policy: Your name, email, or other personal information is never needed for calculations. </b>Javascript performs the calculations on your computer web browser, not on our server -- therefore calculator inputs and outputs exist only on your computer and are never recorded on our server or transmitted across the internet. By visiting, you agree our web server may record standard technical information useful for measuring audience statistics and resolving technical issues and that Google Analytics may use their tracking cookies and other technologies to record and provide audience statistics.</li>
+<li>This version: Oct 16, 2012</li>
</ul>
-<p>Web sites for official information include: <a target=_blank href="http://makinghomeaffordable.gov">makinghomeaffordable.gov</a> -- <a target=_blank href="http://www.fanniemae.com">Fannie Mae</a> -- <a target=_blank href="http://www.freddiemac.com">Freddie Mac</a></p>
+<p>Web sites for official information include: <a target=_blank href="http://makinghomeaffordable.gov">makinghomeaffordable.gov</a> -- <a target=_blank href="http://www.fanniemae.com">Fannie Mae</a> (<a href="https://www.efanniemae.com/sf/servicing/pdf/loanworkoutfactsheet.pdf" target=_blank>loan workout programs</a>) -- <a target=_blank href="http://www.freddiemac.com">Freddie Mac</a> -- <a target=_blank href="http://www.sigtarp.gov">sigtarp.gov</a> --
+<a target=_blank href="http://keepyourhomecalifornia.org">Keep Your Home CA</a>
+</p>
+</p>
+<p>Cheating? Fraud?
+<a href="https://independentforeclosurereview.com/" target=_blank> Independent Foreclosure Review (ends Dec 31, 2012) </a> -- <a href="https://www.mortgageoversight.com" target=_blank>Office of Mortgage Settlement Oversight</a> --
+<a href="http://preventloanscams.org" target=_blank>preventLoanScams.org</a>
+</p>
+<hr>
<h2>Inputs</h2>
-<table>
+<table id="InputsTable">
<tr>
<td>
<input type=text name=olUnpaid id=olUnpaid value=280000 size=8 />
@@ -70,21 +91,31 @@
<td>Market Value, i.e. home value if sold in todays marketplace</td>
</tr>
<tr>
+<td>
+<select name="poHampTier" id="poHampTier" required=1>
+<option value=1>HAMP Tier 1</option>
+<option value=2>HAMP Tier 2</option>
+</select>
+</td>
+<td>
+Procedure to Calculate Loan Modification. Choose "Tier 1" or "Tier 2". Borrowers who fail HAMP Tier 1 can be considered for HAMP Tier 2.
+</td>
+</tr>
+<tr>
<td><input type=checkbox name=poDoPR id=poDoPR checked=1 value=cb size=8 /></td>
-<td>Calculate Principal Reduction.</td>
+<td>Calculate Principal Reduction. Uncheck this box to calculate without PR. <br/> In opposition to principal reduction, on July 31, 2012 Fannie Mae/Freddie Mac's acting director released a <a target=_ href="./documents/PFStatement73112.pdf">statement</a>, <a target=_ href="./documents/PF_FHFApaper73112.pdf"> research paper</a>, and <a target=_ href="./documents/PF_TechApp73112.pdf">technical appendix</a>.</td>
</tr>
<tr>
<td><input type=checkbox name=poDoLenderVariation id=poDoLenderVariation checked=1 value=cb size=8 /></td>
<td>Calculate Lender's Variation.
-MHA Handbook v3.3, 6.4.3, allows lenders to lengthen loan before reducing rates <br/>
-whenever the forgiven principal exceeds 5% of the unpaid balance
+MHA Handbook v3.3(sect 6.4.3) and v4.0(6.4.4) allows lenders to lengthen loan before reducing rates whenever the forgiven principal exceeds 5% of the unpaid balance
</td>
<tr>
<td>
<input type=text name=boMoGrossIncome id=boMoGrossIncome value=4000 size=8 />
</td>
<td>Borrowers combined Monthly Gross Income<br />
-include all wages, retirement, rental or investment income, before deductions
+include all work, retirement, investment or other income, before deductions
</td>
</tr>
<tr>
@@ -110,26 +141,37 @@
</tr>
<tr>
<td>
-<input type=text name=fmCap id=fmCap value=3.80 size=8 />
+<input type=text name=fmCap id=fmCap value=3.50 size=8 />
</td>
<td>
Freddie Mac 30YR FRM Avg rate in %<br />
Please re-enter by hand from the table below:
</td>
</tr>
</table>
-<p>freddie mac iframe goes here
-see link below to add back into the site</p>
+<!-- BEGIN FREDDIE MAC IFRAME CODE (not GPL) -->
+<iframe
+ style="overflow:hidden; border: 0px"
+ SRC="http://www.freddiemac.com/pmms/pmmsthick.html"
+ TITLE="Freddie Mac Weekly PMMS"
+ width="210"
+ height="160"
+>
+</iframe>
<p style="font-size:10px">
Freddie Mac copyrighted loan market data provided "as is", under a public syndication policy of Freddie Mac and with no warranty of any kind.
<a target=_blank href="http://www.freddiemac.com/pmms/syndication/how_to.html">See how to add Freddie Mac data to your website</a>
</p>
+<!-- END FREDDIE MAC IFRAME CODE (not GPL) -->
+<p>
<button onClick="UHC.startAnimation();">Click to Begin Calculation</button>
- Privacy note: No data is transferred. Calculation occurs within your web browser.
+ Privacy note: No data is transferred. Calculation occurs within your web browser.
+</p>
<div id=Outputs>
<hr>
<h2>Outputs</h2>
-<h3><span id="mlCalculatorStep"></span></h3>
+<h3><span id="mlCalculatorStep"></span> <span id="mlFailReason"></span></h3>
+<div id="skipDiv"><button id="skipButton" onClick="UHC.skipToEnd();">Click To Skip To Final Result</button></div>
<table border=1>
<tr>
<td>
@@ -198,22 +240,114 @@
</tr>
<tr>
<td>
-Balloon payment at end of loan
+Balloon payment at end of loan (suggested max: $<span id=mlBalloonMax></span>)
</td>
<td>
$<span id=mlBalloon></span>
</td>
</tr>
+<tr>
+<td>
+Total of Loan Payments
+</td>
+<td>
+$<span id=mlTotalPayments></span>
+</td>
+</tr>
</table>
+<div id="popupDiv"><button onClick="UHC.popupScheduleOfPayments();">Click to Popup Schedule Of Payments in New Window</button></div>
<p style="font-size:10px">These results are provided "as-is" and with no warranty of any kind. <em>Procedures and calculations are subject to change and should not be relied upon for any particular case. Actual results may vary. If you need advice specific to your case, please consult a legal or financial professional.
</em></p>
</div>
-<hr>
+<hr />
+<div id="Graph1Controls">
+<h2>Sensitivity Analysis</h2>
+<p>
+This tool does multiple calculations, then graphs the results.
+<ol>
+<li>Up top, run a calculation to get a "base" result</li>
+<li>Here, tell it what to vary and what to monitor</li>
+<li>Repeat #2 until you are satisfied you understand what is happening. </li>
+</ol>
+Requires a modern web browser to work properly (Firefox 3.5+, Safari 4+, Chrome 8.0+, IE 9+)<br />
+On Smartphones/Tablets show only <u>single</u> outputs, on "Main 7" it may hang.
+</p>
+<p>
+<input type=checkbox name="gcVaryRules" id="gcVaryRules" checked=1 value=cb onchange="$('#graph1Legend').toggle(); " />Vary Rules
+<input type=checkbox name="gcIgnoreFail" id="gcIgnoreFail" value=cb />Include "bad" mods
+</p>
+<p>
+Vary
+<select id="gcX" required=1 onChange="hampGraph.PopulateXLimits();">
+<option value="boMoGrossIncome">Borrower Mo Gross Income</option>
+<option value="olHomeMarketValue">Home Market Value</option>
+<option value="fmCap">Freddie Mac 30YR FRM Rate (%)</option>
+<option value="olUnpaid">Unpaid Loan Balance</option>
+<option value="boMoMiscHousingExpense">Misc Mo Housing Expense</option>
+<option value="olMoRemain">Months Remaining on Loan</option>
+<option value="olRate">Current Interest Rate for Loan (%)</option>
+</select>
+ From
+<input type=text name="gcFrom" id="gcFrom" size=8 />
+ To
+<input type=text name="gcTo" id="gcTo" size=8 />
+ Show
+<select id="gcY" required=1>
+<option value="almostEverything">The Main 7 Outputs</option>
+<option value="mlTotalPayments">Total of Loan Payments</option>
+<option value="mlPR">Principal Reduction</option>
+<option value="mlLTV">new LTV (%)</option>
+<option value="mlUnpaid">new Unpaid Balance</option>
+<option value="mlRate1to5">Modified Interest Rate first 5 yr</option>
+<option value="mlMoPayment1to5">Modified Monthly Payment first 5 yr</option>
+<option value="mlMonths">Length of Modified Loan (months)</option>
+<option value="mlBalloon">Balloon payment at end of loan</option>
+</select>
+ <button id="Graph1Button" onClick="hampGraph.Create(); ">Create Graph</button>
+</p>
+</div>
+<div id="graph1Legend">
+colors for Tier 1 Calculations:
+<span class="colorT1NoPR">No Principal Reduction</span>,
+<span class="colorT1WithPR">With Principal Reduction</span>,
+<span class="colorT1WithPRLV">With PR + Lender's Variation</span>
+<br />
+colors for Tier 2 Calculations:
+<span class="colorT2NoPR">No Principal Reduction</span>,
+<span class="colorT2WithPR">With Principal Reduction</span>
+</div>
+<div id="Graph1" class="hampGraph" style="height:400px;width:800px; "></div>
+<div id="GraphAll">
+ <div id="GraphAll1" class="hampGraph"></div>
+ <p><span id="GraphAll1Title" ></span></p>
+ <hr />
+ <div id="GraphAll2" class="hampGraph"></div>
+ <p><span id="GraphAll2Title" "></span></p>
+ <hr />
+ <div id="GraphAll3" class="hampGraph"></div>
+ <p><span id="GraphAll3Title" ></span></p>
+ <hr />
+ <div id="GraphAll4" class="hampGraph"></div>
+ <p><span id="GraphAll4Title" ></span></p>
+ <hr />
+ <div id="GraphAll5" class="hampGraph"></div>
+ <p><span id="GraphAll5Title" ></span></p>
+ <hr />
+ <div id="GraphAll6" class="hampGraph"></div>
+ <p><span id="GraphAll6Title" ></span></p>
+ <hr />
+ <div id="GraphAll7" class="hampGraph"></div>
+ <p><span id="GraphAll7Title"></span></p>
+ <hr />
+</div>
+<p style="font-size:10px">
+Graphs utilize <a href="http://www.jqplot.com" target=_blank>jqPlot</a>, free plotting software from Chris Leonello, distributed under the GPLv2 License
+</p>
<hr>