var k_form_rand_210=Math.random()+"_"+(new Date()).getTime(); // Уникальный id формы, используется в файлах и для получения ответа анкеты var k_upload_in_progress=0; var k_answer_hide_form210=1; var k_was_submited210=0; var k_210_curr_hash = ''; var k_link_behavior = 1;
function k_addHandler_date(id)
{
var d=new Date();
var obj = document.getElementById('k_input_field_'+id);
if ((obj.value=="[cur.date]")||(obj.value=="[current_date]"))
{
day = d.getDate(); if (day<10) day = "0" + day;
month = d.getMonth()+1; if (month<10) month = "0" + month;
obj.value=day+"."+month+"."+d.getFullYear();
}
if ((obj.value=="[current_time]")||(obj.value=="[cur.time]"))
{
day = d.getDate(); if (day<10) day = "0" + day;
month = d.getMonth()+1; if (month<10) month = "0" + month;
hours = d.getHours(); if (hours<10) hours = "0" + hours;
minute = d.getMinutes(); if (minute<10) minute = "0" + minute;
obj.value=day+"."+month+"."+d.getFullYear()+" "+hours+":"+minute+":00";
}
k_addHandler(obj,"onkeydown", k_onkeydown_date);
if ($(obj).attr('size') == "19") {
$(obj).datetimepicker({
timeFormat: "HH:mm",
showOn:"button",
showAlways: true,
buttonImage: "https://vkipo-dpo.ru/images/calbtn.png",
buttonImageOnly: true,
buttonText: "Calendar",
showAnim: ((''=='v')?"":"show"), // в ie не включаем анимацию, тормозит
})
} else {
$(obj).datepicker({
showOn:"button",
showAlways: true,
buttonImage: "https://vkipo-dpo.ru/images/calbtn.png",
buttonImageOnly: true,
buttonText: "Calendar",
showAnim: ((''=='v')?"":"show"), // в ie не включаем анимацию, тормозит
})
}
$('#k_input_calend_'+id).append($('#k_input_field_'+id+' + img')); // перемещаем календарь
$('#k_input_calend_'+id+' img').css('cursor', 'pointer');
};
function k_onkeydown_date(event)
{
var obj=event.target; if (!obj) obj=event.srcElement;
if ((event.keyCode == 0xA)||(event.keyCode == 0xD))
{
if (window.event)
{
window.event.cancelBubble=true;
window.event.returnValue = false;
}
else
{
event.stopPropagation();
event.cancelBubble=true;
event.returnValue = false;
}
// Если нажат enter отменяем событие, и сохраняем значение
this.blur();
return false;
}
}
// Загрузка файла
var k_upload_files_list;
function k_add_file(obj)
{
var page_charset=window.document.charset;
if (!page_charset) page_charset=window.document.characterSet;
var i_c=obj.getAttribute('i_c');
var field_id=obj.getAttribute('field_id');
var value=obj.value;
var progress_span="";
k_upload_files_list=[];
if (obj.files)
{ // Новый режим многофайловость
var i;
for (i=0;i ");
var m_p =document.getElementById('add_file_url'+i_c);
$(new_line).insertBefore(m_p);
var f_info=new Object();
f_info.name=value;
f_info.obj=new_line;
f_info.field_id=field_id;
k_upload_files_list.push(f_info);
}
}
else
{ // Старый режим
// Если указан полный путь оставляем только имя файла
var last_slash=-1;
var last_slash_p1=0;
var last_slash_p2=-1;
while (1)
{
last_slash_p2=value.indexOf('\\',last_slash_p1);
if (last_slash_p2==-1) break;
last_slash_p1=last_slash_p2+1;
last_slash=last_slash_p2;
}
if (last_slash!=-1)
{
value=value.substr(last_slash+1,1024*1024);
};
var new_line=$(" function k_del_file(obj)
{
var field_id = obj.getAttribute('field_id');
var f_name = obj.getAttribute('f_name');
var page_charset=window.document.charset;
if (!page_charset) page_charset=window.document.characterSet;
document.getElementById("k_sbmt_file_210_"+field_id).action="https://localhost/cb_distr/questionare.php?sel=del_file&qst_id=210&field_id="+field_id+"&f_name="+encodeURIComponent(f_name)+"&page_charset="+page_charset+"&k_rand="+k_form_rand_210;
document.getElementById("k_sbmt_file_210_"+field_id).submit();
$('[data-value = "'+field_id+"_"+f_name+'"]').remove();
var was_upload = +document.getElementById('k_sbmt_file_210_'+field_id).getAttribute('was_upload');
document.getElementById('k_sbmt_file_210_'+field_id).setAttribute('was_upload', was_upload - 1);
} function k_save_qst210()
{
k_answer_hide_form210=1;
var page_charset=window.document.charset;
if (!page_charset) page_charset=window.document.characterSet; if (typeof(custom_save_qst210) == 'function') {
if (!custom_save_qst210()) return ;
}
if (k_was_submited210) return;
k_was_submited210=1;
document.getElementById('k_savebutton210').disabled=true;
document.getElementById('k_savebutton210').style.cursor='default'; var qst_form=document.createElement("form");
qst_form.setAttribute('enctype', 'multipart/form-data');
qst_form.setAttribute('action', 'https://vkipo-dpo.ru/questionare.php?page_charset='+page_charset+'&ts'+new Date().getTime());
qst_form.setAttribute('target', 'k_frame_upload_210');
qst_form.setAttribute('method', 'post');
document.body.appendChild(qst_form);
var qst_input;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10690');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10690').value;
if (!qst_input.value) {alert('Заполните, пожалуйста, поле: "Телефон"'); document.getElementById('k_savebutton210').disabled=''; k_was_submited210=0; return;}
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10700');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10700').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10720');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10720').value;
if (!qst_input.value) {alert('Заполните, пожалуйста, поле: "Гражданство"'); document.getElementById('k_savebutton210').disabled=''; k_was_submited210=0; return;}
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10730');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10730').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10750');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10750').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_9680');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_9680').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10760');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10760').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10770');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10770').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10780');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10780').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10790');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10790').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10800');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10800').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10810');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10810').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10820');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10820').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10830');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10830').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10840');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10840').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10850');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10850').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10860');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10860').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10870');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10870').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10880');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10880').value;
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_input_field_210_10890');qst_form.appendChild(qst_input);
qst_input.value=document.getElementById('k_input_field_210_10890').value;
;
if(k_210_curr_hash != '') {
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','hash');qst_form.appendChild(qst_input);
qst_input.value=k_210_curr_hash;
} else {
if(document.location.href.split('hash=')[1]) {
if(document.location.href.split('hash=')[1].split('.').length>1) {
qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','hash');qst_form.appendChild(qst_input);
qst_input.value=document.location.href.split('hash=')[1].split('.')[0];
}
}
} qst_input=document.createElement('input');qst_input.setAttribute('type','hidden');qst_input.setAttribute('name','k_rand_210');qst_form.appendChild(qst_input);
qst_input.value=k_form_rand_210;
qst_form.submit();
document.body.removeChild(qst_form);
};
function k_save_resp210(event)
{
if (document.getElementById('k_frame_upload_210').src=='') return ; // Выходим если загрузки не было var page_charset=window.document.charset;
if (!page_charset) page_charset=window.document.characterSet;
if (k_upload_in_progress)
{ // Загрузка файлов
var obj=event.target; if (!obj) obj=event.srcElement;
// Убираем значек загрузки
$(".k_upload_progress").removeClass('k_upload_progress_img');
// Необходима проверка - загружен ли файл
for (var i = 0; i < k_upload_files_list.length; i++)
{
var f_name=k_upload_files_list[i].name;
var f_obj =k_upload_files_list[i].obj;
var rnd_sess=Math.floor(Math.random()*10000);
var ss = document.createElement('script');
ss.src="https://vkipo-dpo.ru/questionare.php?sel=test_upload&qst_id=210&k_rand="+k_form_rand_210+"&k_resp="+rnd_sess+"&f_name="+f_name+"&page_charset="+page_charset;
ss.setAttribute('i_pos',i);
ss.setAttribute('rnd_sess',rnd_sess);
var done = false;
ss.onload=ss.onreadystatechange=function(){
if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") )
{
done = true;
var i=this.getAttribute("i_pos");
var rnd_sess=this.getAttribute("rnd_sess");
var f_name=k_upload_files_list[i].name;
var f_obj =k_upload_files_list[i].obj
var field_id =k_upload_files_list[i].field_id;
eval("var data=k_resp"+rnd_sess+";");
if (data.indexOf(' uploaded.')!=-1)
{
var size = parseInt(data)+"";
size=size.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
// Отображем размер
f_obj.find(".k_upload_progress").html(" - "+size+" B" +
" "+
"");
var was_upload = +document.getElementById('k_sbmt_file_210_'+field_id).getAttribute('was_upload');
document.getElementById('k_sbmt_file_210_'+field_id).setAttribute('was_upload', was_upload + 1);
}
else
{
f_obj.find(".k_upload_progress").html(" - Провалено");
} ss.onload = ss.onreadystatechange = null;
document.body.removeChild(ss);
}
}
document.body.appendChild(ss);
}
k_upload_in_progress=0;
return ;
}
if (document.getElementById('k_frame_upload_210').getAttribute('second_load'))
{
if (!k_was_submited210) return;
k_was_submited210=0;
//document.getElementById('k_savebutton210').style.display='none';
document.getElementById('k_savebutton210').disabled=false;
if (typeof(custom_qst_res210) == 'function') {
custom_qst_res210();
}
else
{
// Получаем результат формы
var ss = document.createElement('script');
ss.src="https://vkipo-dpo.ru/questionare.php?sel=get_answer&qst_id=210&k_rand="+k_form_rand_210;
var done = false;
ss.onload=ss.onreadystatechange=function(){
if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") )
{
done = true; try {
var data = JSON.parse(k_answer210);
} catch (e) {
var data = k_answer210;
} delete k_answer210; if (data.error !== undefined)
{
$('#k_qst_err_res_210').html('');
if (data.error != ' ')
$('#k_qst_err_res_210').append(data.error);
data = false;
k_answer_hide_form210 = 0;
document.getElementById('k_savebutton210').style.display = '';
}
else if (data !== undefined && data != '' && data != ' ')
{
if (data != ' ')
$('#k_qst_res_210').append(data);
document.getElementById('k_savebutton210').style.display='';
}
else
{
//document.getElementById('k_qst_res_210').innerHTML='Информация успешно сохранена. Спасибо!';
}
if (k_answer_hide_form210)
{
//обработка ответ, если в нем есть переменные
var new_qst_text = 'Информация успешно сохранена. Спасибо!';
$.ajax({
method: 'POST',
url: 'https://vkipo-dpo.ru/questionare.php',
async: false,
data: { qst_text: new_qst_text,qst_id:'210' }
})
.done(function( msg ) {
new_qst_text = msg ;
}); document.getElementById('k_qst_210').style.display='none';
location.href='#qst_res_link210';
if ($('#k_qst_res_210').text()=='') document.getElementById('k_qst_res_210').innerHTML=new_qst_text;
} ss.onload = ss.onreadystatechange = null;
document.body.removeChild(ss);
}
}
document.body.appendChild(ss);
}
document.getElementById('k_frame_upload_210').src=""; // Четвертый уровень защиты от повторной загрузки
}
else
document.getElementById('k_frame_upload_210').setAttribute('second_load',1);
}
$(function(){
if(document.getElementById('k_frame_upload_210').onload == null) {
$('#k_frame_upload_210').on('load', function(event) { k_save_resp210(event); });
}
if (window.k_qst210_def_value10690) $('#k_input_field_210_10690').val(window.k_qst210_def_value10690);
if (window.k_qst210_def_value10700) $('#k_input_field_210_10700').val(window.k_qst210_def_value10700);
if (window.k_qst210_def_value10720) $('#k_input_field_210_10720').val(window.k_qst210_def_value10720);
if (window.k_qst210_def_value10730) $('#k_input_field_210_10730').val(window.k_qst210_def_value10730);
if (window.k_qst210_def_value10750) $('#k_input_field_210_10750').val(window.k_qst210_def_value10750);
if (window.k_qst210_def_value9680) $('#k_input_field_210_9680').val(window.k_qst210_def_value9680);
if (window.k_qst210_def_value10760) $('#k_input_field_210_10760').val(window.k_qst210_def_value10760);
if (window.k_qst210_def_value10770) $('#k_input_field_210_10770').val(window.k_qst210_def_value10770);
if (window.k_qst210_def_value10780) $('#k_input_field_210_10780').val(window.k_qst210_def_value10780);
if (window.k_qst210_def_value10790) $('#k_input_field_210_10790').val(window.k_qst210_def_value10790);
if (window.k_qst210_def_value10800) $('#k_input_field_210_10800').val(window.k_qst210_def_value10800);
if (window.k_qst210_def_value10810) $('#k_input_field_210_10810').val(window.k_qst210_def_value10810);
if (window.k_qst210_def_value10820) $('#k_input_field_210_10820').val(window.k_qst210_def_value10820);
if (window.k_qst210_def_value10830) $('#k_input_field_210_10830').val(window.k_qst210_def_value10830);
if (window.k_qst210_def_value10840) $('#k_input_field_210_10840').val(window.k_qst210_def_value10840);
if (window.k_qst210_def_value10850) $('#k_input_field_210_10850').val(window.k_qst210_def_value10850);
if (window.k_qst210_def_value10860) $('#k_input_field_210_10860').val(window.k_qst210_def_value10860);
if (window.k_qst210_def_value10870) $('#k_input_field_210_10870').val(window.k_qst210_def_value10870);
if (window.k_qst210_def_value10880) $('#k_input_field_210_10880').val(window.k_qst210_def_value10880);
if (window.k_qst210_def_value10890) $('#k_input_field_210_10890').val(window.k_qst210_def_value10890);
if (window.k_qst210_def_value13750) $('#k_input_field_210_13750').val(window.k_qst210_def_value13750); });
Добавить