Не могу заставить работать калкулятор расчета доходности. Взят отсюда -
http://hyipstat.top/hyip_page.php?id_hyip=2383
var Calculator = function(config){
this.Init(config);
};
Calculator.prototype = {
plan: null,
timer: null,
loadXhr: false,
config: {
ajax_path: '/ajax/ajax.php',
post_delay: 300
},
Init: function(config){
$.extend(this.config, config);
this.block_plans = $('.tbl_plan:first');
this.block_result = $('.calc-block:first');
this.input = $('#calc-vklad');
this.input.on('keyup', $.proxy(this.DelaySearch, this));
var s = this.block_plans.find('.calc-plan_selected:first');
if( s.length ){ this.plan = s.data(); }
var that = this;
this.block_plans.on('click', '.calc-plan', function(){
var $this = $(this);
if( !$this.hasClass('calc-plan_selected') ){
that.plan = $this.data();
$this.addClass('calc-plan_selected').siblings().removeClass('calc-plan_selected');
var vklad = that.CheckVklad();
if( vklad < that.plan.min_sum || vklad > that.plan.max_sum ){ vklad = that.plan.max_sum; }
that.input.val(vklad);
that.DelaySearch();
}
});
},
CheckVklad: function(){
var vklad = parseFloat(this.input.val().replace(/\,/g, '.'));
return isNaN(vklad) || vklad < 1 ? 0 : vklad;
},
DelaySearch: function(){
if( this.loadXhr ){ this.loadXhr.abort(); }
clearTimeout(this.timer);
this.timer = setTimeout($.proxy(this.GetResult, this), this.config.post_delay);
},
GetResult: function(){
var vklad = this.CheckVklad();
if( vklad >= this.plan.min_sum && vklad <= this.plan.max_sum ){
this.input.val(vklad);
this.loadXhr = $.ajax({
url: this.config.ajax_path,
type: "POST",
dataType: "json",
data: { "calc_profit": this.plan.id_plan, "vklad": vklad },
context: this,
success: function(data){
if( data.error == undefined ){
$('#calc-daysleft', this.block_result).html(data.days);
$('#calc-date', this.block_result).html(data.date);
$('#calc-perday', this.block_result).html(data.per_day);
$('#calc-itog', this.block_result).html(data.itog);
$('#calc-profit', this.block_result).html(data.profit);
}
else{ show_toast(data.error); }
},
complete: function(){ this.loadXhr = false; }
});
}
else{ show_toast('Укажите корректную сумму вклада'); }
}
};
HTML
<table class="tbl_plan" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr class="grey_font">
<td width="16%">процент</td>
<td width="16%">минимум</td>
<td width="17%">максимум</td>
<td width="15%">дней</td>
<td width="17%">начисления</td>
<td width="19%">вклад в выплатах</td>
</tr>
<tr class="calc-plan calc-plan_selected" data-id_plan="4715" data-min_sum="10" data-max_sum="1000">
<td>
<span class="plan_big">2.1</span>
</td>
<td>10 $</td>
<td>1000 $</td>
<td>15</td>
<td>ежедневно</td>
<td>нет</td>
</tr>
<tr class="calc-plan" data-id_plan="4959" data-min_sum="1001" data-max_sum="10000">
<td>
<span class="plan_big">2.3</span>
</td>
<td>1001 $</td>
<td>10000 $</td>
<td>30</td>
<td>ежедневно</td>
<td>нет</td>
</tr>
<tr class="calc-plan" data-id_plan="4960" data-min_sum="100" data-max_sum="1000">
<td>
<span class="plan_big">50</span>
</td>
<td>100 $</td>
<td>1000 $</td>
<td>21</td>
<td>раз в 21 д</td>
<td>нет</td>
</tr>
<tr class="calc-plan" data-id_plan="5421" data-min_sum="100" data-max_sum="1000">
<td>
<span class="plan_big">50</span>
</td>
<td>100 $</td>
<td>1000 $</td>
<td>15</td>
<td>раз в 15 д</td>
<td>нет</td>
</tr>
</tbody>
</table>
<table class="calc-block">
<tbody>
<tr>
<td>
<div class="plan_big">
<input id="calc-vklad" style="border: 1px solid #cccccc; color: inherit; text-align: center; width: 80px; font-size: 20px;" maxlength="10" value="1000" type="text">
<span class="calc-usd-label">$</span>
</div>
<span class="small-font gray">вклад</span>
</td>
<td>
<div id="calc-daysleft" class="plan_big">
15
<span class="small-font">дней</span>
</div>
<span class="small-font gray">до безубытка</span>
</td>
<td>
<div id="calc-date" class="plan_big">
23
<span class="small-font">янв 17</span>
</div>
<span class="small-font gray">дата безубытка</span>
</td>
<td>
<div id="calc-perday" class="plan_big">
21
<span class="calc-usd-label">$</span>
</div>
<span class="small-font gray">в день</span>
</td>
<td>
<div id="calc-itog" class="plan_big">
1315
<span class="calc-usd-label">$</span>
</div>
<span class="small-font gray">итог</span>
</td>
<td>
<div id="calc-profit" class="plan_big">
987
<span class="calc-usd-label">$</span>
</div>
<span class="small-font gray">чистая прибыль</span>
</td>
</tr>
</tbody>
</table>