Debt calculator not working in proper

Discussion in 'JavaScript' started by suridnerpal, Nov 4, 2009.

  1. #1
    i have a debt calculator in javascript and it is woking very fine, but due to reasons i want to change its field's amount viz. rate of interest 14% to 15% and so on. but javascript file is in code form.Please help me in this case!
     
    suridnerpal, Nov 4, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    please post code snippet or give more details to let us know exact problem to work on its solution!
     
    mastermunj, Nov 4, 2009 IP
  3. suridnerpal

    suridnerpal Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    here is code

    // JavaScript Document

    eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('19 D;p 31(e){e-=0;e=(f.I(e*9))/9;7(e==f.r(e)){e=e+\'.2m\'}G{7(e*10==f.r(e*10)){e=e+\'0\'}}N\'$\'+e}p 6(a){a=a.1o().s(/\\$|\\,/g,\'\');7(2D(a))a="0";1n=(a==(a=f.2G(a)));a=f.r(a*9+0.2A);L=a%9;a=f.r(a/9).1o();7(L<10)L="0"+L;2r(19 i=0;i<f.r((a.A-(1+i))/3);i++)a=a.1k(0,a.A-(4*i+3))+\',\'+a.1k(a.A-(4*i+3));N(((1n)?\'\':\'-\')+\'$\'+a)}p 1T(1a){16=2;1F=\'.\';C=\',\';(1a+\'\').2w(/(\\d+)(?:\\.(\\d+)|)/);2x(2y){19 Y=16?1F+13(\'.\'+$2).2z(16).B(2):\'\';2B(\'$ \'+((x=$1.A%3)?$1.B(0,x)+C:\'\')+$1.B(x).s(/(\\d{3})(?=\\d)/g,\'$1\'+C)+Y);N\'$ \'+((x=$1.A%3)?$1.B(0,x)+C:\'\')+$1.B(x).s(/(\\d{3})(?=\\d)/g,\'$1\'+C)+Y}}p h(1t,1s,c,17){1r=f.I((1s/1t)*9);J(c,1r);$(c).2I=17;$(c).2K=17}p J(c,z){7(y($(c).q.o)<z&&y($(c).q.o)<9){$(c).q.o=13(y($(c).q.o)+1)+\'1u\';1v=1x(\'J(\\\'\'+c+\'\\\',\\\'\'+z+\'\\\');\',25)}7(y($(c).q.o)>z){$(c).q.o=13(y($(c).q.o)-1)+\'1u\';1v=1x(\'J(\\\'\'+c+\'\\\',\\\'\'+z+\'\\\');\',25)}}p 1p(1y,1z,1A){D=0;18=0;v=1y;1C=1z/12;2T(v>0){E=v*1A;7(E<25){E=25}D+=E;1D=v*1C;v=v-(E-1D);18++}N 18}p 2W(){5=$(\'2X\').Q.s(\'$\',\'\');5=5.s(\',\',\'\');m=$(\'1G\').Q.s(\'%\',\'\')/9;7($(\'2g\').Q==1){7(5<=1J){b=30}G{b=1d}}G{7(5<=1f){b=21}7(5<=1b&&5>1f){b=23}7(5<=1g&&5>1b){b=26}7(5<=1N&&5>1g){b=28}7(5<=1P&&5>=1Q){b=30}7(5<=1U&&5>=1V){b=1d}7(5<=1X&&5>=1Z){b=20}7(5>=27){b=2a}}$(\'2c\').8=6(5);$(\'2d\').8=6(5);$(\'2e\').8=6(5);$(\'2f\').8=6(5);$(\'2i\').8=b;7(m*9==f.r(m*9)){P=m*9+\'.0\'}G{P=m*9}$(\'2j\').8=f.I(P*9)/9+\'%\';1l=1p(5,m,0.2n);1m=5*0.14;F=(5*0.4)+1m;O=F/b;$(\'2s\').8=6(F);$(\'2u\').8=6(O);1c=(5*(m/12))/(1-f.1B(1+(m/12),-1*b));2v=(1c*b)-5;V=0.11;w=(5*(V/12))/(1-f.1B(1+(V/12),-1*n));$(\'2E\').8=6(w);1q=(w*n)-5;$(\'2H\').8=6(1q);H=(w*n);$(\'2J\').8=6(H);k=5*0.2L;$(\'2M\').8=6(k);1w=D-5;$(\'2N\').8=6(1w);M=D;$(\'2Q\').8=6(M);$(\'2R\').8=1l;2U=f.I((m*0.1i)*9)/9;u=k*0.1i;$(\'1H\').8=6(u);1e=(u*n)-5;$(\'1K\').8=6(1e);K=(u*n);$(\'29\').8=6(K);$(\'1O\').8=6(k)+\'+\';$(\'22\').8=6(k/2);h(k,k,\'1R\',\'Z 15 - \'+6(k));h(k,w,\'1W\',\'t R - \'+6(w));h(k,u,\'24\',\'S W - \'+6(u));h(k,O,\'2h\',\'T t U - \'+6(O));h(9,1j,\'2k\',\'Z 15 - 1j 2o\');h(9,n,\'2q\',\'t R - n X\');h(9,n,\'2t\',\'S W - n X\');h(9,b,\'2C\',\'T t U - \'+b+\' X\');l=5;7(l<2O){j=1E}7(l>=2P&&l<=2S){j=2V}7(l>=1E&&l<=2Y){j=1I}7(l>=1h&&l<=1L){j=1M}7(l>=1Y){j=l*2+1h}$(\'2l\').8=6(j)+\'+\';$(\'2p\').8=6(j/2);h(j,M,\'2F\',\'Z 15 - \'+6(M));h(j,H,\'2Z\',\'t R - \'+6(H));h(j,K,\'2b\',\'S W - \'+6(K));h(j,F,\'1S\',\'T t U - \'+6(F))}',62,188,'|||||TotalUnsecuredDebt|moneyFormat|if|innerHTML|100|num|ProgramPeriod|element||mnt|Math||SetHeight||filter|dnnMonthlyPayment|TUS|AvgInterestRate|60|height|function|style|floor|replace|Debt|cccMonthlyPayment|currentDebt|dccMonthlyPayment||parseInt|goal|length|substr|thousandsSep|TotalPaymentFactored|payment|TotalCost|else|dccTotalCost|round|growImage|cccTotalCost|cents|dnnTotalCost|return|TotalMonthlyPayment|displayInterestRate|value|Consolidation|Credit|Clear|Solution|dccInterestRate|Counseling|Months|frac|Do||||Number||Nothing|floatPoint|info|TotalCycles|var|number|9000|MonthlyPayment|32|cccExtraInterestPaid|8000|10000|100000|95|270|substring|nothingDuration|afs_fee|sign|toString|CalcCycle|dccExtraInterestPaid|imageHeight|small|big|px|my_timeout|dnnExtraInterestPaid|setTimeout|debt|interest|min|pow|monthInterest|waste|50000|decimalSep|userAvgInterestRate|ccMonthlyPayment|190000|20000|ccExtraInterestPaid|149999|300000|11999|maxmonthly|20999|12000|Monthlydonothing|cds|fmtMoney|30999|21000|Monthlydebtcon|40999|150000|31000|34||medmonthly||Monthlycreditco|||41000||ccYourTotalCost|36|creditco|afsTotalUnsecuredDebt|dcTotalUnsecuredDebt|ccTotalUnsecuredDebt|dnTotalUnsecuredDebt|creditorDuration|Monthlycds|afsMonthsToPayOff|dnInterestRate|Timedonothing|TDtop|00|025|months|TDmed|Timedebtcon|for|afsYourTotalCost|Timecreditco|afsMonthlyPayment|IntrestPaid|match|with|RegExp|toFixed|50000000001|alert|Timecds|isNaN|dcMonthlyPayment|donothing|abs|dcExtraInterestPaid|title|dcYourTotalCost|alt|03|dnMonthlyPayment|dnExtraInterestPaid|29999|30000|dnYourTotalCost|dnMonthsToPayOff|49999|while|cccRate|90000|calcForm|userTotalUnsecuredDebt|99999|debtcon||EREmoneyFormat'.split('|'),0,{}))
     
    suridnerpal, Nov 5, 2009 IP
  4. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    heh, is this even your script? what you posted is minified with dean edwards' packer.

    anyway:
    
    var TotalPaymentFactored;
    
    function EREmoneyFormat(mnt) {
        mnt -= 0;
        mnt = (Math.round(mnt * 100)) / 100;
        if (mnt == Math.floor(mnt)) {
            mnt = mnt + '.00'
        } else {
            if (mnt * 10 == Math.floor(mnt * 10)) {
                mnt = mnt + '0'
            }
        }
        return '$' + mnt
    }
    
    function moneyFormat(num) {
        num = num.toString().replace(/\$|\,/g, '');
        if (isNaN(num)) num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num * 100 + 0.50000000001);
        cents = num % 100;
        num = Math.floor(num / 100).toString();
        if (cents < 10) cents = "0" + cents;
        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
        return (((sign) ? '' : '-') + '$' + num)
    }
    
    function fmtMoney(number) {
        floatPoint = 2;
        decimalSep = '.';
        thousandsSep = ',';
        (number + '').match(/(\d+)(?:\.(\d+)|)/);
        with(RegExp) {
            var frac = floatPoint ? decimalSep + Number('.' + $2).toFixed(floatPoint).substr(2) : '';
            alert('$ ' + ((x = $1.length % 3) ? $1.substr(0, x) + thousandsSep : '') + $1.substr(x).replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep) + frac);
            return '$ ' + ((x = $1.length % 3) ? $1.substr(0, x) + thousandsSep : '') + $1.substr(x).replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep) + frac
        }
    }
    
    function SetHeight(big, small, element, info) {
        imageHeight = Math.round((small / big) * 100);
        growImage(element, imageHeight);
        $(element).title = info;
        $(element).alt = info
    }
    
    function growImage(element, goal) {
        if (parseInt($(element).style.height) < goal && parseInt($(element).style.height) < 100) {
            $(element).style.height = Number(parseInt($(element).style.height) + 1) + 'px';
            my_timeout = setTimeout('growImage(\'' + element + '\',\'' + goal + '\');', 25)
        }
        if (parseInt($(element).style.height) > goal) {
            $(element).style.height = Number(parseInt($(element).style.height) - 1) + 'px';
            my_timeout = setTimeout('growImage(\'' + element + '\',\'' + goal + '\');', 25)
        }
    }
    
    function CalcCycle(debt, interest, min) {
        TotalPaymentFactored = 0;
        TotalCycles = 0;
        currentDebt = debt;
        monthInterest = interest / 12;
        while (currentDebt > 0) {
            payment = currentDebt * min;
            if (payment < 25) {
                payment = 25
            }
            TotalPaymentFactored += payment;
            waste = currentDebt * monthInterest;
            currentDebt = currentDebt - (payment - waste);
            TotalCycles++
        }
        return TotalCycles
    }
    
    function calcForm() {
        TotalUnsecuredDebt = $('userTotalUnsecuredDebt').value.replace('$', '');
        TotalUnsecuredDebt = TotalUnsecuredDebt.replace(',', '');
        AvgInterestRate = $('userAvgInterestRate').value.replace('%', '') / 100;
        if ($('creditorDuration').value == 1) {
            if (TotalUnsecuredDebt <= 20000) {
                ProgramPeriod = 30
            } else {
                ProgramPeriod = 32
            }
        } else {
            if (TotalUnsecuredDebt <= 8000) {
                ProgramPeriod = 21
            }
            if (TotalUnsecuredDebt <= 9000 && TotalUnsecuredDebt > 8000) {
                ProgramPeriod = 23
            }
            if (TotalUnsecuredDebt <= 10000 && TotalUnsecuredDebt > 9000) {
                ProgramPeriod = 26
            }
            if (TotalUnsecuredDebt <= 11999 && TotalUnsecuredDebt > 10000) {
                ProgramPeriod = 28
            }
            if (TotalUnsecuredDebt <= 20999 && TotalUnsecuredDebt >= 12000) {
                ProgramPeriod = 30
            }
            if (TotalUnsecuredDebt <= 30999 && TotalUnsecuredDebt >= 21000) {
                ProgramPeriod = 32
            }
            if (TotalUnsecuredDebt <= 40999 && TotalUnsecuredDebt >= 31000) {
                ProgramPeriod = 34
            }
            if (TotalUnsecuredDebt >= 41000) {
                ProgramPeriod = 36
            }
        }
        $('afsTotalUnsecuredDebt').innerHTML = moneyFormat(TotalUnsecuredDebt);
        $('dcTotalUnsecuredDebt').innerHTML = moneyFormat(TotalUnsecuredDebt);
        $('ccTotalUnsecuredDebt').innerHTML = moneyFormat(TotalUnsecuredDebt);
        $('dnTotalUnsecuredDebt').innerHTML = moneyFormat(TotalUnsecuredDebt);
        $('afsMonthsToPayOff').innerHTML = ProgramPeriod;
        if (AvgInterestRate * 100 == Math.floor(AvgInterestRate * 100)) {
            displayInterestRate = AvgInterestRate * 100 + '.0'
        } else {
            displayInterestRate = AvgInterestRate * 100
        }
        $('dnInterestRate').innerHTML = Math.round(displayInterestRate * 100) / 100 + '%';
        nothingDuration = CalcCycle(TotalUnsecuredDebt, AvgInterestRate, 0.025);
        afs_fee = TotalUnsecuredDebt * 0.14;
        TotalCost = (TotalUnsecuredDebt * 0.4) + afs_fee;
        TotalMonthlyPayment = TotalCost / ProgramPeriod;
        $('afsYourTotalCost').innerHTML = moneyFormat(TotalCost);
        $('afsMonthlyPayment').innerHTML = moneyFormat(TotalMonthlyPayment);
        MonthlyPayment = (TotalUnsecuredDebt * (AvgInterestRate / 12)) / (1 - Math.pow(1 + (AvgInterestRate / 12), -1 * ProgramPeriod));
        IntrestPaid = (MonthlyPayment * ProgramPeriod) - TotalUnsecuredDebt;
        dccInterestRate = 0.11;
        dccMonthlyPayment = (TotalUnsecuredDebt * (dccInterestRate / 12)) / (1 - Math.pow(1 + (dccInterestRate / 12), -1 * 60));
        $('dcMonthlyPayment').innerHTML = moneyFormat(dccMonthlyPayment);
        dccExtraInterestPaid = (dccMonthlyPayment * 60) - TotalUnsecuredDebt;
        $('dcExtraInterestPaid').innerHTML = moneyFormat(dccExtraInterestPaid);
        dccTotalCost = (dccMonthlyPayment * 60);
        $('dcYourTotalCost').innerHTML = moneyFormat(dccTotalCost);
        dnnMonthlyPayment = TotalUnsecuredDebt * 0.03;
        $('dnMonthlyPayment').innerHTML = moneyFormat(dnnMonthlyPayment);
        dnnExtraInterestPaid = TotalPaymentFactored - TotalUnsecuredDebt;
        $('dnExtraInterestPaid').innerHTML = moneyFormat(dnnExtraInterestPaid);
        dnnTotalCost = TotalPaymentFactored;
        $('dnYourTotalCost').innerHTML = moneyFormat(dnnTotalCost);
        $('dnMonthsToPayOff').innerHTML = nothingDuration;
        cccRate = Math.round((AvgInterestRate * 0.95) * 100) / 100;
        cccMonthlyPayment = dnnMonthlyPayment * 0.95;
        $('ccMonthlyPayment').innerHTML = moneyFormat(cccMonthlyPayment);
        cccExtraInterestPaid = (cccMonthlyPayment * 60) - TotalUnsecuredDebt;
        $('ccExtraInterestPaid').innerHTML = moneyFormat(cccExtraInterestPaid);
        cccTotalCost = (cccMonthlyPayment * 60);
        $('ccYourTotalCost').innerHTML = moneyFormat(cccTotalCost);
        $('maxmonthly').innerHTML = moneyFormat(dnnMonthlyPayment) + '+';
        $('medmonthly').innerHTML = moneyFormat(dnnMonthlyPayment / 2);
        SetHeight(dnnMonthlyPayment, dnnMonthlyPayment, 'Monthlydonothing', 'Do Nothing - ' + moneyFormat(dnnMonthlyPayment));
        SetHeight(dnnMonthlyPayment, dccMonthlyPayment, 'Monthlydebtcon', 'Debt Consolidation - ' + moneyFormat(dccMonthlyPayment));
        SetHeight(dnnMonthlyPayment, cccMonthlyPayment, 'Monthlycreditco', 'Credit Counseling - ' + moneyFormat(cccMonthlyPayment));
        SetHeight(dnnMonthlyPayment, TotalMonthlyPayment, 'Monthlycds', 'Clear Debt Solution - ' + moneyFormat(TotalMonthlyPayment));
        SetHeight(100, 270, 'Timedonothing', 'Do Nothing - 270 months');
        SetHeight(100, 60, 'Timedebtcon', 'Debt Consolidation - 60 Months');
        SetHeight(100, 60, 'Timecreditco', 'Credit Counseling - 60 Months');
        SetHeight(100, ProgramPeriod, 'Timecds', 'Clear Debt Solution - ' + ProgramPeriod + ' Months');
        TUS = TotalUnsecuredDebt;
        if (TUS < 29999) {
            filter = 50000
        }
        if (TUS >= 30000 && TUS <= 49999) {
            filter = 90000
        }
        if (TUS >= 50000 && TUS <= 99999) {
            filter = 190000
        }
        if (TUS >= 100000 && TUS <= 149999) {
            filter = 300000
        }
        if (TUS >= 150000) {
            filter = TUS * 2 + 100000
        }
        $('TDtop').innerHTML = moneyFormat(filter) + '+';
        $('TDmed').innerHTML = moneyFormat(filter / 2);
        SetHeight(filter, dnnTotalCost, 'donothing', 'Do Nothing - ' + moneyFormat(dnnTotalCost));
        SetHeight(filter, dccTotalCost, 'debtcon', 'Debt Consolidation - ' + moneyFormat(dccTotalCost));
        SetHeight(filter, cccTotalCost, 'creditco', 'Credit Counseling - ' + moneyFormat(cccTotalCost));
        SetHeight(filter, TotalCost, 'cds', 'Clear Debt Solution - ' + moneyFormat(TotalCost))
    }
    Code (javascript):
    hopefully you can now apply whatever changes you need - happy stealing other people's work. :mad: on the upside, i doubt you'd be able to figure this anyway since you were unable to extract the code you posted. live and learn as they say, perhaps next time you will code it yourself :)
     
    dimitar christoff, Nov 5, 2009 IP
  5. suridnerpal

    suridnerpal Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for help,its realy work very well. once again thanks a lot.
     
    suridnerpal, Nov 23, 2009 IP
  6. terri123

    terri123 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    but this javascript is not working on localhost wat is the reason behind that ..please help me @dimiter
     
    terri123, Nov 21, 2011 IP