var loan = { init:function(){ $("#calculate").bind({ "click":function(){ loan.displayBasic(); } }); loan.funcBtn(); loan.inputCheck(); }, displayBasic:function(){ if(loan.formCheck()) { var P = $("#p").val(); var R = $("#r").val()/100; var period = $("#period").val(); P = parseFloat(P); NUM_OF_TERM = parseFloat(period); var monthlyLoanPrincipalPayment = P/NUM_OF_TERM; var monthlyAdministrationFeeHKD = P*R; var monthlyInstallmentAmount = monthlyLoanPrincipalPayment + monthlyAdministrationFeeHKD; var totalRepaymentAmount = loan.calTotalRepaymentAmount(P,R,period); $("#pDisplay").html(extraMath.formatMoney($("#p").val(),2,".",",")); $("#periodDisplay").html($("#period").val()); $("#rDisplay").html(extraMath.formatMoney($("#r").val(),4,".",",")+"%"); $("#MonthlyLoanPrincipalPaymentDisplay").html(extraMath.formatMoney(monthlyLoanPrincipalPayment,2,".",",")); $("#MonthlyAdministrationFeeHKDDisplay").html(extraMath.formatMoney(monthlyAdministrationFeeHKD,2,".",",")); $("#MonthlyInstallmentAmountDisplay").html(extraMath.formatMoney(monthlyInstallmentAmount,2,".",",")); $("#TotalRepaymentAmountDisplay").html(extraMath.formatMoney(totalRepaymentAmount,2,".",",")); } }, calTotalRepaymentAmount:function(P,R,period){ return P + (P * R * period); }, inputCheck:function(){ $("#p,#r").on({ "keyup":function(){ if(!$(this).val()) $(this).val(""); }, "blur":function(){ if(!$(this).val()) $(this).val(""); } }); }, formCheck:function(){ var check = true; var errorText = ""; if($("#p").val().trim()=="") errorText += "- "+loanDisplayText.InputLoanAmount[lang]+"\n"; else if(isNaN($("#p").val())) errorText += "- "+loanDisplayText.InvalidLoanAmount[lang]+"\n"; else if($("#p").val() < 1000 || $("#p").val() > 9999999) errorText += "- "+loanDisplayText.InvalidLoanAmountRange[lang]+"\n"; if($("#period").val().trim()=="") errorText += "- "+loanDisplayText.InputLoanTenor[lang]+"\n"; else if(isNaN($("#period").val()) || !["3","6","12","18","24","36","48","60"].includes($("#period").val())) errorText += "- "+loanDisplayText.InvalidLoanTenor[lang]+"\n"; if($("#r").val().trim()=="") errorText += "- "+loanDisplayText.InputMonthlyAdministrationFee[lang]+"\n"; else if(isNaN($("#r").val())) errorText += "- "+loanDisplayText.InvalidMonthlyAdministrationFee[lang]+"\n"; if(errorText) { errorText = errorText; check = false; alert(errorText) } return check; }, funcBtn:function(){ $(".image").on({ "click":function(){ var node = document.getElementById("imgExportArea"); domtoimage.toPng(node) .then(function (dataUrl) { var link = document.createElement('a'); link.download = 'Image.png'; link.href = dataUrl; link.click(); }) .catch(function (error) { console.error('oops, something went wrong!', error); }); } }); $(".print").on({ "click":function(){ window.print(); } }); } }; var loanDisplayText = { index:function(cd){ $("title").text(loanDisplayText.metaTitle[lang]); $("#header").html(''); $(".LoanAmount").text(loanDisplayText.LoanAmount[lang]); $(".LoanTenor").text(loanDisplayText.LoanTenor[lang]); $(".MonthlyAdministrationFee").text(loanDisplayText.MonthlyAdministrationFee[lang]); $("#calculate").val(loanDisplayText.Calculate[lang]); $("#clear").val(loanDisplayText.Clear[lang]); $(".CalculationResult").text(loanDisplayText.CalculationResult[lang]); $("#YourInput").text(loanDisplayText.YourInput[lang]); $("#MonthlyLoanPrincipalPayment").text(loanDisplayText.MonthlyLoanPrincipalPayment[lang]); $("#MonthlyAdministrationFeeHKD").text(loanDisplayText.MonthlyAdministrationFeeHKD[lang]); $("#MonthlyInstallmentAmount").text(loanDisplayText.MonthlyInstallmentAmount[lang]); $("#TotalRepaymentAmount").text(loanDisplayText.TotalRepaymentAmount[lang]); $("#FuncBtn").html(''+loanDisplayText.SaveAsImage[lang]+' '+loanDisplayText.Print[lang]+''); $(".LoanHeader").text(loanDisplayText.LoanHeader[lang]); $("#note1").html(loanDisplayText.note1[lang]); }, metaTitle:{ "en":"Loan Calculator for Credit Card Cash-in Installment Program and Card Retail Purchase Installment Program", "tc":"信用卡「套現分期計劃」及信用卡「幾時都分期」簽賬計劃之貸款計算機", "sc":"信用卡「套现分期计划」及信用卡「几时都分期」签账计划之贷款计算机" }, LoanHeader:{ "en":"Loan Calculator for Credit Card Cash-in Installment Program and Card Retail Purchase Installment Program", "tc":"信用卡「套現分期計劃」及信用卡「幾時都分期」簽賬計劃之貸款計算機", "sc":"信用卡「套现分期计划」及信用卡「几时都分期」签账计划之贷款计" }, LoanAmount:{ "en":"Loan Amount (HKD)", "tc":"貸款額 (港幣)", "sc":"贷款额 (港币)" }, LoanTenor:{ "en":"Loan Tenor (Months)", "tc":"還款期 (月)", "sc":"还款期 (月)" }, MonthlyAdministrationFee:{ "en":"Monthly Administration Fee (%)", "tc":"每月行政費 (%)", "sc":"每月行政费 (%)" }, Calculate:{ "en":"Calculate", "tc":"計算", "sc":"计算" }, Clear:{ "en":"Clear", "tc":"重新輸入", "sc":"重新输入" }, CalculationResult:{ "en":"Calculation Result", "tc":"計算結果", "sc":"计算结果" }, YourInput:{ "en":"Your Input", "tc":"你的資料", "sc":"你的资料" }, MonthlyLoanPrincipalPayment:{ "en":"Monthly Loan Principal Payment (HKD)", "tc":"每月償還之本金金額 (港幣)", "sc":"每月偿还之本金金额 (港币)" }, MonthlyAdministrationFeeHKD:{ "en":"Monthly Administration Fee (HKD)", "tc":"每月行政費 (港幣)", "sc":"每月行政费 (港币)" }, MonthlyInstallmentAmount:{ "en":"Monthly Installment Amount (HKD)", "tc":"每月還款金額 (港幣)", "sc":"每月还款金额 (港币)" }, TotalRepaymentAmount:{ "en":"Total Repayment Amount (HKD)", "tc":"總還款金額 (港幣)", "sc":"总还款金额 (港币)" }, InputLoanAmount:{ "en":"Please input the Loan Amount.", "tc":"請輸入貸款額。", "sc":"请输入贷款额。" }, InputLoanTenor:{ "en":"Please input the Loan Tenor.", "tc":"請輸入還款期。", "sc":"请输入还款期。" }, InputMonthlyAdministrationFee:{ "en":"Please input the Monthly Administration Fee.", "tc":"請輸入每月行政費。", "sc":"请输入每月行政费。" }, InvalidLoanAmount:{ "en":"The Loan Amount you inputted is invalid. Please re-enter.", "tc":"你所輸入的貸款額不正確,請重新輸入。", "sc":"你所输入的贷款额不正确,请重新输入。" }, InvalidLoanTenor:{ "en":"The Loan Tenor you inputted is invalid. Please re-enter.", "tc":"你所輸入的還款期不正確,請重新輸入。", "sc":"你所输入的还款期不正确,请重新输入。" }, InvalidMonthlyAdministrationFee:{ "en":"The Month Administration Fee you inputted is invalid. Please re-enter.", "tc":"你所輸入的每月行政費不正確,請重新輸入。", "sc":"你所输入的每月行政费不正确,请重新输入。" }, InvalidLoanAmountRange:{ "en":"Loan Amount must be between 1,000 to 9,999,999.", "tc":"貸款額須在1,000至9,999,999內。", "sc":"贷款额须在1,000至9,999,999内。" }, note1:{ "en":"Note: (1) The calculation is based on the information provided by customer and the calculator result is for reference only. The actual repayment liability depends on the actual terms of each borrowing arrangement. (2) Cardmember needs to be aware that early settlement handling fee and all monthly administration fees payable over the remainder of the installment period but not yet charged to the Account and any interest (if applicable) are involved in early settlement of Credit Card Cash-in Installment Program and Card Retail Purchase Installment Program. For details, please refer to Key Facts Statement and loan confirmation letter for Credit Card Cash-in Installment Program and Card Retail Purchase Installment Program. Please check with the Bank about the total repayment amount and consider the handling fee involved before making a decision of repaying early or not.", "tc":"註: (1) 以上的計算結果是根據客戶提供之資料計算及計算結果只供參考。實際還款責任取決於各項借款安排的實際條款。(2) 信用卡客戶需要留意,提前清還信用卡「套現分期計劃」及信用卡「幾時都分期」簽賬計劃必須支付提早償還手續費及所有須支付但尚未記入賬戶之每月行政費及任何利息(如適用)。詳情請參閱信用卡「套現分期計劃」及信用卡「幾時都分期」簽賬計劃之產品資料概要及申請確認信。因此,建議客戶應先向本行查詢提前還款的總金額及考慮所涉及的手續費,才決定是否選擇提前還款。", "sc":"注: (1) 以上的计算结果是根据客户提供之资料计算及计算结果只供参考。实际还款责任取决于各项借款安排的实际条款。 (2) 信用卡客户需要留意,提前清还信用卡「套现分期计划」及信用卡「几时都分期」签账计划必须支付提早偿还手续费及所有须支付但尚未记入账户之每月行政费及任何利息(如适用)。详情请参阅信用卡「套现分期计划」及信用卡「几时都分期」签账计划之产品资料概要及申请确认信。因此,建议客户应先向本行查询提前还款的总金额及考虑所涉及的手续费,才决定是否选择提前还款。" }, SaveAsImage:{ "en":"Save As Image", "tc":"保存圖片", "sc":"保存图片" }, Print:{ "en":"Print", "tc":"列印", "sc":"打印" } };