Created
June 16, 2016 14:19
-
-
Save r0hack/9233793bd36bc0a27b9af90ed44e9d7a to your computer and use it in GitHub Desktop.
Calc. Flag. JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var b = $("#text1"), | |
a = $("#slider-range-min"); | |
$("body").change(function(){ | |
$("#text1").focus(); | |
}); | |
a.slider({ | |
// orientation: "vertical", | |
step: 100, | |
range: "min", | |
min: 0, | |
max: 100000, | |
values: 0, | |
change: function(a, c) { | |
b.val(c.value) | |
}, | |
slide: function(a, c) { | |
b.val(c.value) | |
} | |
}); | |
b.val(0).focusin(function() { | |
a.slider("value", this.value) | |
}).focusin() | |
}); | |
$( "#text1" ).val( $( "#slider-range-min" ).slider( "value" ) ); | |
$(document).ready(function() { | |
var flag = 1; | |
var flag1 = 1; | |
$('#exp span').click(function(){ | |
flag = 1; | |
$('#upr').removeClass('active_div'); | |
$('#standart').removeClass('active_div'); | |
$('#mini').removeClass('active_div'); | |
$('#upr span').addClass('span_upr'); | |
$('#standart span').addClass('span_standart'); | |
$('#mini span').addClass('span_mini'); | |
$('#exp').addClass('active_div'); | |
$('#exp span').removeClass('span_exp'); | |
$('.current span').html('Без поручителей'); | |
}); | |
$('#upr span').click(function(){ | |
flag = 0; | |
$('#exp').removeClass('active_div'); | |
$('#standart').removeClass('active_div'); | |
$('#mini').removeClass('active_div'); | |
$('#exp span').addClass('span_exp'); | |
$('#standart span').addClass('span_standart'); | |
$('#mini span').addClass('span_mini'); | |
$('#upr').addClass('active_div'); | |
$('#upr span').removeClass('span_upr'); | |
$('.current span').html('С 1 поручителем'); | |
}); | |
$('#standart span').click(function(){ | |
flag = 2; | |
$('#exp').removeClass('active_div'); | |
$('#upr').removeClass('active_div'); | |
$('#mini').removeClass('active_div'); | |
$('#exp span').addClass('span_exp'); | |
$('#upr span').addClass('span_upr'); | |
$('#mini span').addClass('span_mini'); | |
$('#standart').addClass('active_div'); | |
$('#standart span').removeClass('span_standart'); | |
$('.current span').html('С 2 поручителями'); | |
}); | |
$('#mini span').click(function(){ | |
flag = 3; | |
$('#exp').removeClass('active_div'); | |
$('#upr').removeClass('active_div'); | |
$('#standart').removeClass('active_div'); | |
$('#exp span').addClass('span_exp'); | |
$('#upr span').addClass('span_upr'); | |
$('#standart span').addClass('span_standart'); | |
$('#mini').addClass('active_div'); | |
$('#mini span').removeClass('span_mini'); | |
$('.current span').html('С 3 поручителями'); | |
}); | |
$("#text").click(function(){ | |
if (flag == 1) { | |
var money = document.getElementById("text").value; | |
var percent = (money*30)/100; | |
$("#text1").val(percent) | |
$("#slider-range-min").slider({min: percent,max: (money-percent),}); | |
} | |
if (flag == 0) { | |
var money = document.getElementById("text").value; | |
var percent = (money*30)/100; | |
$("#text1").val(percent) | |
$("#slider-range-min").slider({min: percent,max: (money-percent),}); | |
} | |
if (flag == 2) { | |
var money = document.getElementById("text").value; | |
var percent = (money*25)/100; | |
$("#text1").val(percent) | |
$("#slider-range-min").slider({min: percent,max: (money-percent),}); | |
} | |
if (flag == 3) { | |
var money = document.getElementById("text").value; | |
var percent = (money*25)/100; | |
$("#text1").val(percent) | |
$("#slider-range-min").slider({min: percent,max: (money-percent),}); | |
} | |
}); | |
$('.b-calc_input-pag').bind('click', function() { | |
$('.b-calc_input-pag').each(function(index, val) { | |
$(val).removeClass('active'); | |
}); | |
$(this).addClass('active'); | |
}); | |
$('#b-calc-submit').bind('click', function() { | |
var a, // Срок | |
b, // Цена | |
proc = 0, | |
perv = 0, | |
vznos = 0, | |
ejemes = 0, | |
pereplata = 0, | |
itog = 0; | |
$('.b-calc_input-pag').each(function(index, val) { | |
if ($('.b-calc_input-pag').eq(index).hasClass('active')) { | |
a = index + 1; | |
}; | |
}); | |
// a = parseInt(jQuery('#b-calc_input-srok').val()); | |
b = parseInt(jQuery('#text').val()); | |
if ((a > 0) && (b > 0) ) { | |
if (flag == 1) { | |
if (a == 1) { | |
proc = 0.057143; | |
} | |
else | |
if (a == 2) { | |
proc = 0.114285; | |
} | |
else | |
if (a == 3) { | |
proc = 0.171429; | |
} | |
else | |
if (a == 4) { | |
proc = 0.228571; | |
} | |
else | |
if (a == 5) { | |
proc = 0.2857141; | |
} | |
else { | |
proc = 0.342857; | |
} | |
} | |
else if (flag == 0) { | |
if (a == 1) { | |
proc = 0.04285; | |
} | |
else | |
if (a == 2) { | |
proc = 0.08570; | |
} | |
else | |
if (a == 3) { | |
proc = 0.12855; | |
} | |
else | |
if (a == 4) { | |
proc = 0.17140; | |
} | |
else | |
if (a == 5) { | |
proc = 0.21425; | |
} | |
else { | |
proc = 0.25710; | |
} | |
} | |
else if (flag == 2) { | |
if(b<10000000){ | |
proc = 0.3; | |
}else{ | |
proc = 0.29; | |
} | |
} | |
else { | |
if(b<100000){ | |
proc = 0.225; | |
}else{ | |
proc = 0.215; | |
} | |
} | |
//console.log(proc); | |
perv = parseInt($('#text1').val()); | |
if (flag == 1) { | |
if (perv < (b * 0.30)) { | |
alert("Первоначальный взнос не может быть менее 30%"); | |
} | |
else | |
if (perv > b) { | |
alert("Первоначальный взнос не может быть более 100%"); | |
} | |
else { | |
pereplata = ((b - perv) * proc); | |
ejemes = (b - perv + pereplata) / a; | |
itog = b + pereplata; | |
} | |
} | |
else if (flag == 0) { | |
if (perv < (b * 0.30)) { | |
alert("Первоначальный взнос не может быть менее 30%"); | |
} | |
else | |
if (perv > b) { | |
alert("Первоначальный взнос не может быть более 100%"); | |
} | |
else { | |
pereplata = ((b - perv) * proc); | |
ejemes = (b - perv + pereplata) / a; | |
itog = b + pereplata; | |
} | |
} | |
else if (flag == 2) { | |
if (perv < (b * 0.25)) { | |
alert("Первоначальный взнос не может быть менее 30%"); | |
} | |
else | |
if (perv > b) { | |
alert("Первоначальный взнос не может быть более 100%"); | |
} | |
else { | |
pereplata = ((b - perv) * proc) *a / 12; | |
ejemes = (b - perv + pereplata) / a; | |
itog = b + pereplata; | |
} | |
} | |
else if (flag == 3) { | |
if (perv < (b * 0.25)) { | |
alert("Первоначальный взнос не может быть менее 30%"); | |
} | |
else | |
if (perv > b) { | |
alert("Первоначальный взнос не может быть более 100%"); | |
} | |
else { | |
pereplata = ((b - perv) * proc) *a / 12; | |
ejemes = (b - perv + pereplata) / a; | |
itog = b + pereplata; | |
} | |
} | |
perv = perv.toFixed(0); | |
vznos = vznos.toFixed(0); | |
pereplata = pereplata.toFixed(0); | |
ejemes = ejemes.toFixed(0); | |
itog = itog.toFixed(0); | |
var rub = '<span class="b-calc-rub"> р.</span>'; | |
$('#b-calc_input-ejemes').html(ejemes + rub); | |
$('#b-calc_input-pereplata').html(pereplata + rub); | |
$('#b-calc_input-itog').html(itog + rub); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment