HEX
Server: Apache/2.4.46 (Unix) PHP/7.4.24
System: Linux dc15-w.ht-systems.ru 2.6.32-042stab142.1 #1 SMP Tue Jan 28 23:44:17 MSK 2020 x86_64
User: srv52894 (52894)
PHP: 7.4.24
Disabled: passthru,shell_exec,system,proc_open,popen,show_source
Upload Files
File: /home/srv52894/test/calc/calc-balcon/balkonCalculate.js
function balkonCalculate()
{
	document.write('<form id="calkulator-balkon" action="" name="calkulatorBalkon"><fieldset id="step1"><div class="calk-head">Что рассчитаем?</div><div class="calk-row"><div class="calk-col"><label for="lodzhiya"><div class="calk-lodzhiya"></div></label><p><input type="radio" value="1" name="balcony" class="calk-radio" id="lodzhiya"> <label for="lodzhiya">Лоджию</label></p></div><div class="calk-col"><label for="balcon"><div class="calk-balkon"></div></label><p><input type="radio" value="2" name="balcony" class="calk-radio" id="balcon"> <label for="balcon">Балкон</label></p></div></div><div class="calk-next-step"><a href="#step2">Дальше &gt;</a></div></fieldset><fieldset id="step2"><div class="calk-head">Какие работы Вам нужны?</div><div class="calk-row"><table class="calk-work"><tbody><tr><td class="calk-work-head">Остекление</td><td><input type="radio" name="glazing" value="1" id="al-c" checked><label for="al-c"></label><p><label for="al-c">Алюминиевое раздвижное (холодное)</label></p></td><td><input type="radio" name="glazing" value="2" id="pl-h"><label for="pl-h"></label><p><label for="pl-h">Пластиковое раздвижное (полутеплое)</label></p></td><td><input type="radio" name="glazing" value="3" id="pl-t"><label for="pl-t"></label><p><label for="pl-t">Пластиковое распашное (теплое)</label></p></td></tr><tr><td class="calk-work-head">Сварка</td><td><input type="checkbox" name="welding1" value="1" id="n-sv" checked><label for="n-sv"></label><p><label for="n-sv">Без сварки</label></p></td><td><input type="checkbox" name="welding2" value="2" id="obshivka"><label for="obshivka"></label><p><label for="obshivka">Обшивка профлистом с наружи</label></p></td><td><input type="checkbox" name="welding3" value="3" id="n-krysha"><label for="n-krysha"></label><p><label for="n-krysha">Независимая крыша</label></p></td></tr><tr><td class="calk-work-head">Отделка</td><td><input type="radio" name="decoration" value="1" id="n-otd" checked><label for="n-otd"></label><p><label for="n-otd">Без отделки</label></p></td><td><input type="radio" name="decoration" value="2" id="pl-pan"><label for="pl-pan"></label><p><label for="pl-pan">Пластиковыми панелями</label></p></td><td><input type="radio" name="decoration" value="3" id="der-vag"><label for="der-vag"></label><p><label for="der-vag">Деревянной вагонкой</label></p></td></tr><tr><td class="calk-work-head">Мебель</td><td><input type="radio" name="furniture" value="1" id="n-meb" checked><label for="n-meb"></label><p><label for="n-meb">Без мебели</label></p></td><td><input type="radio" name="furniture" value="2" id="tumba"><label for="tumba"></label><p><label for="tumba">Тумба до подоконника</label></p></td><td><input type="radio" name="furniture" value="3" id="shkaf"><label for="shkaf"></label><p><label for="shkaf">Шкаф до потолка</label></p></td></tr></tbody></table></div><div class="calk-next-step"><a href="#step3">Дальше &gt;</a></div></fieldset><fieldset id="step3"><div class="calk-head">Какие размеры у вашего балкона?</div><div class="calk-row"><div class="calk-img-balcony"><div class="calk-length">Длина <input type="text" value="" name="length" placeholder="мм"></div><div class="calk-height">Высота <input type="text" value="" name="height" placeholder="мм"></div><div class="calk-depth">Глубина <input type="text" value="" name="depth" placeholder="мм"></div><div class="calk-contact-data"><p><label>Комментарий:</label> <textarea  name="comment"> </textarea></p><p><label>Имя:</label> <input type="text" value="" name="fio"></p><p><label>Телефон:</label> <input type="text" value="" name="telephone"></p></div></div></div><div class="calk-next-step"><input type="submit" value="Получить расчет"></div></fieldset><fieldset id="calc_message"></fieldset></form>');
}

function validateStep(name){
	var err = false;
	
	if(name == '#step1'){
		if ( ( document.calkulatorBalkon.balcony[0].checked == false ) && ( document.calkulatorBalkon.balcony[1].checked == false ) )
        {
                alert ( "Пожалуйста, выберите: балкон или лоджия?" );
                err = true;
        }
		
		return err;
	}
	
	if(name == '#step2'){
		if ( ( document.calkulatorBalkon.glazing[0].checked == false ) && ( document.calkulatorBalkon.glazing[1].checked == false ) && ( document.calkulatorBalkon.glazing[2].checked == false ) )
        {
                alert ( "Пожалуйста, выберите вид остекления!" );
                err = true;								
        }
		
		if ( ( document.calkulatorBalkon.welding1.checked == false ) && ( document.calkulatorBalkon.welding2.checked == false ) && ( document.calkulatorBalkon.welding3.checked == false ) )
        {
                alert ( "Пожалуйста, укажите нужна ли сварка!" );
                err = true;								
        }
		
		if ( ( document.calkulatorBalkon.decoration[0].checked == false ) && ( document.calkulatorBalkon.decoration[1].checked == false ) && ( document.calkulatorBalkon.decoration[2].checked == false ) )
        {
                alert ( "Пожалуйста, выберите вид отделки!" );
                err = true;								
        }
		
		if ( ( document.calkulatorBalkon.furniture[0].checked == false ) && ( document.calkulatorBalkon.furniture[1].checked == false ) && ( document.calkulatorBalkon.furniture[2].checked == false ) )
        {
                alert ( "Пожалуйста, укажите нужна ли мебель!" );
                err = true;								
        }
		
		return err;
	}
	
	if(name == '#step3'){
		$(name + " :input").each(function(){
				if($(this).val() == '')
				{
					$(this).addClass('error');
					err = true;
				} else {
					$(this).removeClass('error');
				}
			}
		)
	}
	
    return err;
}

function calcHideMessage(){
	$('#calc_message').hide();
	document.calkulatorBalkon.reset();
	$('#step1').fadeIn(800);
}

$(document).ready(function(){ 
	var calc_form = $('#calkulator-balkon');
	var next_step = $('.calk-next-step a');
	var submit_button = $('.calk-next-step input[type=submit]');
	var currentStep = '#step1';

	$(next_step).on('click', function(e) {
		if(!validateStep(currentStep))
		{
			$(currentStep).hide();
			currentStep = $(this).attr('href');
			$(currentStep).fadeIn(800);
		}
	});
	
	$(submit_button).on('click', function(e) {
		if(!validateStep(currentStep))
		{
			var data = calc_form.serialize();
			$.ajax({
				type: "POST",
				url: "/calc-balcon/send-form.php",
				data: data,
				success: function(msg) {
					if(msg == 'OK') {
						$(currentStep).hide();
						currentStep = '#calc_message';
						$(currentStep).html('<h1 class="calc-h1">Ваша заявка получена! Скоро с вами свяжутся!</h1>');
						$(currentStep).fadeIn(800);
						setTimeout(calcHideMessage, 3000);
						currentStep = '#step1';
					}
					else{
						alert(msg);
						$(currentStep).hide();
						currentStep = '#step1';
						$(currentStep).fadeIn(800);
					} 
						
				}
			});					
		}else
			alert('Заполните все поля!');
		
		return false;
	});
	
	$('#obshivka').on('click', function(e) {
		if($(this).is(":checked")) {
			$('#n-sv').removeAttr("checked");
		}	
	});
	
	$('#n-krysha').on('click', function(e) {
		if($(this).is(":checked")){
			$('#n-sv').removeAttr("checked");
		}
	});
	
	$('#n-sv').on('click', function(e) {
		if($(this).is(":checked")){
			$('#n-krysha').removeAttr("checked");
			$('#obshivka').removeAttr("checked");
		}
	});
	
});