-
Notifications
You must be signed in to change notification settings - Fork 2
/
scripts.min.js
1 lines (1 loc) · 1.95 KB
/
scripts.min.js
1
$(document).ready(function(){function e(){var e=$("#userName").val(),t=0===e.trim().length?"Anonymous":e,a=$("#userIncome").val(),i=Math.min(d,a*r),b=a-Math.min(u*a,m),k=(b-x)*f,z=(b-v)*p+(v-x)*f,j=(b-c)*h+(c-v)*p+(v-x)*f,w=(b-F)*C+(F-c)*h+(c-v)*p+(v-x)*f;if(b>x&&b<=v){var A=(+a).toFixed(2),K=k.toFixed(2),N=(+A-+(O=i.toFixed(2))-+K).toFixed(2);n=K,l=O,o=N}else if(b>v&&b<=c){N=(+(A=(+a).toFixed(2))-+(O=i.toFixed(2))-+(K=z.toFixed(2))).toFixed(2);n=K,l=O,o=N}else if(b>c&&b<=F){N=(+(A=(+a).toFixed(2))-+(O=i.toFixed(2))-+(K=j.toFixed(2))).toFixed(2);n=K,l=O,o=N}else if(b>F){var A=(+a).toFixed(2),O=i.toFixed(2),N=(+A-+O-+(K=w.toFixed(2))).toFixed(2);n=K,l=O,o=N}else a="0.00",n="0.00",l="0.00",o="0.00";g.text(t),y.text(s((+a).toFixed(2))),I.text(s(n)),M.text(s(l)),Y.text(s(o))}function t(){return $("#userIncome").val()<10}function a(){var e=$("#userIncome").val();return/^[1-9]\d+\.?\d?\d?$/.test(e.toString())}function s(e){var t=e.indexOf("."),a=e.slice(t),s=e.slice(0,t);return s.length>=4?i(s)+a:e}function i(e){for(var t=e.split(""),a=[],s=0,i=t.length-1;i>-1;i--)a.push(t[i]),++s%3==0&&0!==i&&a.push(",");return a.reverse().join("")}var n,l,o,r=.05,d=894.61,u=.15,m=255,x=0,v=3300,c=4100,F=6200,f=0,p=.25,h=.3,C=.375,g=$("#results-name"),y=$("#results-user-income"),I=$("#results-paye"),M=$("#results-napsa"),Y=$("#results-net");$("#results-modal").modal(),$("#modal-trigger").on("click",function(){t()?Materialize.toast("<span><i class='material-icons' style='transform: translateY(5px)'>warning</i> Your income must be atleast K10</span>",2750):a()&&!t()?(e(),$("#results-modal").modal("open")):Materialize.toast("<span><i class='material-icons' style='transform: translateY(5px)'>error</i> Please enter a valid amount</span>",2750)});var b=$("#userIncome");b.on("input blur keyup",function(){a()?(b.hasClass("invalid")&&b.removeClass("invalid"),b.hasClass("valid")||b.addClass("valid")):(b.hasClass("valid")&&b.removeClass("valid"),b.hasClass("invalid")||b.addClass("invalid"))})});