var rateDecimals = 2; var apyDecimals = 2; jQuery(function(){ jQuery.ajax({ dataType: "json", url: "" + "/rates.json", cache: false, success: function(data) { jQuery.each(data.products, function(index, product){ var productTerm = (typeof this.term == "undefined") ? "0" : this.term; var productClass = this.type + "-" + productTerm; jQuery(".rate-" + productClass).text((100 * this.rate).toFixed(rateDecimals)); jQuery(".apy-" + productClass).text((100 * this.apy).toFixed(apyDecimals)); jQuery(".apy-ab-" + productClass).text((100 * this.apy).toFixed(apyDecimals) + "%"); if (parseInt(productTerm) > 0) { jQuery(".term-" + productClass).text(this.term); jQuery(".term-desc-" + productClass).text(this.term + "-month CD"); } }); jQuery("[name^='effDate']").text(moment(data.date).format("MM/DD/YYYY")); createsCDTable(data.products); createsCDTableAB(data.products); createsCDTableABmobile(data.products); } }); setSessionId(); }); function createsCDTable(products) { jQuery.each(products, function(index, product) { if (typeof this.term != "undefined" && parseInt(this.term) > 0) { jQuery(".rate-table").append("" + this.term + " Month CD" + (100 * this.rate).toFixed(rateDecimals) + "%" + (100 * this.apy).toFixed(apyDecimals) + "%"); } }); } function createsCDTableAB(products) { jQuery.each(products, function(index, product) { if (typeof this.term != "undefined" && parseInt(this.term) > 0) { jQuery(".rate-table-ab").append("" + this.term + " Month CD" + (100 * this.rate).toFixed(rateDecimals) + "%" + (100 * this.apy).toFixed(apyDecimals) + "%"); } }); updateInterestEarned(); updateAnnualInterestEarned(); } function createsCDTableABmobile(products) { jQuery.each(products, function(index, product) { if (typeof this.term != "undefined" && parseInt(this.term) > 0) { jQuery(".rate-table-ab-mobile").append("" + this.term + " Month CD" + (100 * this.rate).toFixed(rateDecimals) + "% / " + (100 * this.apy).toFixed(apyDecimals) + "%" + ""); } }); updateInterestEarned(); updateAnnualInterestEarned(); } var accrualDays = []; accrualDays["3"] = 90; accrualDays["6"] = 180; accrualDays["9"] = 270; accrualDays["12"] = 365; accrualDays["18"] = 545; accrualDays["24"] = 730; accrualDays["36"] = 1095; accrualDays["48"] = 1460; accrualDays["60"] = 1825; function updateInterestEarned() { jQuery("td[data-rates]").each(function() { var term = jQuery(this).attr('data-rates').split("-")[0] * 1; var rate = jQuery(this).attr('data-rates').split("-")[1] * 1; var earned = (depositAmount *(Math.pow( (1+(rate/365)),(accrualDays[term+""]))-1)).toFixed(2); earned = earned.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); jQuery(this).text("jQuery" + earned); }); } function updateAnnualInterestEarned() { var barclaysRate = jQuery("#barclaysRate").text(); var barclaysRate = barclaysRate.replace("%", "") / 100; jQuery("td[data-balance]").each(function() { var balance = jQuery(this).attr('data-balance'); var balance = balance.replace(",", "") * 1; var earned = (barclaysRate * balance).toFixed(2); earned = earned.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); jQuery(this).text("jQuery" + earned); }); } function setSessionId() { var jsessionid = getCookie("jsessionid"); digitalData.session.applicationSessionId = jsessionid; //console.log("cookie " + jsessionid); } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; }