Tax calculator

by JThomas

HTML

<div class="dialog" title="Estimate Taxes">
    <label>Value after work:
        <input id="valueChange" type="text" value="0" />
    </label>
    <div> <span>Estimated taxes:</span>
 <span id="estimate">$0</span>

    </div>
</div>
<div>
    <button id="ShowMeTheTaxes">Estimate Property Taxes</button>
</div>

CSS

html, body {
    font-size: 1em;
    line-height:1.68;
    font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
}
input {
    padding: 5px;
    margin: 5px;
}
label {
    cursor: pointer;
}
.dialog {
    display: none;
}
}

JavaScript

//levi is per $1000: 38.26789/1000 = 0.03826789
//Build formula dynamically based on variables from database with calculator builder
//data object is what the web service would return after passing class and tax district
var data = {
    "formula": "((((rollback * totalAdjusted) - homeCredit) - militaryCredit) * (levi / 1000)) ",
        "levi": "38.26789",
        "rollback": "0.5282166",
        "homeCredit": "4850",
        "militaryCredit": "1852"
};

$("#valueChange").keyup(function (e) {
    var target = $(e.target);

    //Default to 0 if no value is provided
    if (target.val() == "") target.val(0);

    var baseValue = 200000,
        totalAdjusted = parseInt($(e.target).val()) + baseValue,
        levi = data.levi,
        rollback = data.rollback,
        homeCredit = data.homeCredit,
        militaryCredit = data.militaryCredit;

    $("#estimate").html("$" + eval(data.formula).toFixed());
});

$("#ShowMeTheTaxes").click(function () {
    $(".dialog").dialog({
        modal: true,
        height: 300,
        width: 600
    });
});