var hasTouch = "ontouchstart" in window || window.DocumentTouch, START_EV = hasTouch ? "touchstart" : "mousedown", MOVE_EV = hasTouch ? "touchmove" : "mousemove", END_EV = hasTouch ? "touchend" : "mouseup", business_rate_data = { date_141122: [5.6, 6, 6, 6.15], date_120706: [6, 6.15, 6.4, 6.55], date_120608: [6.31, 6.4, 6.65, 6.8], date_150301: [5.35, 5.75, 5.75, 5.9], date_150511: [5.1, 5.5, 5.5, 5.65], date_150628: [4.85, 5.25, 5.25, 5.4], date_150826: [4.6, 5, 5, 5.15], date_151023: [4.35,4.75,4.75,4.9] }, fund_rate_data = { date_141122: ["3.75", "4.25"], date_120706: ["4.00", "4.50"], date_120608: ["4.20", "4.70"], date_150301: ["3.50", "4.00"], date_150511: ["3.25", "3.75"], date_150628: ["3.00", "3.50"], date_150826: ["2.75", "3.25"], date_151023: ["2.75","3.25"] }; function isTextValid() { var valid = true; $('input[role="text-number"]').each(function () { var $this = $(this); if ($this.height() > 0 && $.trim($(this).val()) === "") { $this.closest(".daikuan_total_inputbox").addClass("error_tips"); $('.error_msg[data-for="' + $this.attr("id") + '"]').show(); valid = false } }); if (!valid) { if ($(".error_tips").offset().top < $("body").scrollTop()) { scroll($(".error_tips").first().offset().top - 5, 100) } } return valid } function formatNum(strNum) { if (strNum.length <= 3) { return strNum } if (!/^(\+|-)?(\d+)(\.\d+)?$/.test(strNum)) { return strNum } var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3; var re = new RegExp(); re.compile("(\\d)(\\d{3})(,|$)"); while (re.test(b)) { b = b.replace(re, "$1,$2$3") } return a + "" + b + "" + c } function trimEnd(str, characters) { if (str == null) { return "" } characters = "[" + characters + "]"; var result = String(str).replace(new RegExp(characters + "+$"), ""); if (result.indexOf(".") == result.length - 1) { result = result.substr(0, result.length - 1) } return result } function getMonthMoney1(lilv, total, month) { var lilv_month = lilv / 12; return total * lilv_month * Math.pow(1 + lilv_month, month) / (Math.pow(1 + lilv_month, month) - 1) } function scroll(scrollTo, time) { var scrollFrom = parseInt(document.body.scrollTop), i = 0, runEvery = 17; scrollTo = parseInt(scrollTo); time /= runEvery; var interval = setInterval(function () { i++; document.body.scrollTop = (scrollTo - scrollFrom) / time * i + scrollFrom; if (i >= time) { clearInterval(interval) } }, runEvery) } function getMonthMoney2(lilv, total, month, cur_month) { var lilv_month = lilv / 12; var benjin_money = total / month; return (total - benjin_money * cur_month) * lilv_month + benjin_money }