1317 lines
38 KiB
JavaScript
1317 lines
38 KiB
JavaScript
// function writeMessage(el){
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// url: '/user_account/chats/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// // data: formData,
|
||
// success: function(data){
|
||
//
|
||
// // location.href = '/profile'
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
//
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
// let body = document.querySelector("body")
|
||
// body.style.overflow = "hidden"
|
||
// //updating the url without reloading
|
||
// window.history.pushState(null, null, '/ru/profile/page/chat/')
|
||
// middleWareJS()
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// console.log(400)
|
||
//
|
||
// }
|
||
// });
|
||
// }
|
||
//
|
||
//
|
||
// function technicalSupport(el){
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// url: '/user_account/support_tickets/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// // data: formData,
|
||
// success: function(data){
|
||
//
|
||
//
|
||
// // location.href = '/profile'
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
//
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
//
|
||
// //updating the url without reloading
|
||
// window.history.pushState(null, null, '/ru/profile/page/support/')
|
||
// middleWareJS()
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// console.log(400)
|
||
//
|
||
// }
|
||
// });
|
||
// }
|
||
// function mySubscription(el){
|
||
// // boris changed
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// url: '/subscribes/show_cur_subscribe/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// // data: formData,
|
||
// success: function(data){
|
||
//
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
//
|
||
// // location.href = '/profile'
|
||
// // document.querySelector(".info_profile").innerHTML = data.html;
|
||
//
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
//
|
||
// //updating the url without reloading
|
||
// window.history.pushState(null, null, '/ru/profile/page/my_subscribe/')
|
||
// middleWareJS()
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// console.log(400)
|
||
//
|
||
// }
|
||
// });
|
||
// }
|
||
// function myProfile(el){
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// url: '/user_account/change_profile/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// // data: formData,
|
||
// success: function(data){
|
||
//
|
||
//
|
||
// // location.href = '/profile'
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
//
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
//
|
||
// //updating the url without reloading
|
||
// window.history.pushState(null, null, '/ru/profile/page/change_profile/')
|
||
// middleWareJS()
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// console.log(400)
|
||
//
|
||
// }
|
||
// });
|
||
// }
|
||
|
||
// function selectMenuItem() {
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
//
|
||
// list_div.forEach(item =>{
|
||
// item.addEventListener('click', (e) =>{
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// item.classList.add('selected')
|
||
// })
|
||
// })
|
||
//
|
||
//
|
||
// }
|
||
|
||
|
||
|
||
function removeRoute(el,route_id ) {
|
||
let remove_item = route_id
|
||
let remove_data = {}
|
||
let name_route = 'route_id'
|
||
remove_data[name_route] = remove_item
|
||
|
||
// console.log(remove_item)
|
||
|
||
$.ajax({
|
||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
url: '/routes/del_route/',
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
data: JSON.stringify(remove_data) ,
|
||
success: function(data){
|
||
|
||
|
||
// location.href = '/profile'
|
||
document.querySelector(".info_profile").innerHTML = data.html;
|
||
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
|
||
//updating the url without reloading
|
||
window.history.pushState(null, null, '/ru/profile/page/my_routes/')
|
||
|
||
middleWareJS()
|
||
},
|
||
error: function (data, exception){
|
||
console.log(400)
|
||
|
||
}
|
||
});
|
||
|
||
|
||
}
|
||
|
||
function cancelRemove(route_id) {
|
||
let confirm_remove = document.getElementById('confirm_remove_'+ route_id);
|
||
let cancel_remove = document.getElementById('cancel_remove_'+ route_id);
|
||
let hide_edit_button = document.getElementById('edit_route_'+ route_id)
|
||
|
||
hide_edit_button.classList.toggle('hide')
|
||
confirm_remove.classList.remove('show');
|
||
cancel_remove.classList.remove('show');
|
||
|
||
let remove_btn = document.getElementById('remove_route_'+route_id);
|
||
remove_btn.classList.remove('hide');
|
||
}
|
||
|
||
function hideBlock(el) {
|
||
|
||
el.classList.add('hide')
|
||
|
||
|
||
let clear_form = document.querySelector('.clear_form');
|
||
if(clear_form){
|
||
clear_form.reset();
|
||
}
|
||
|
||
|
||
let clear_form_com = document.querySelector('.commercial_offer');
|
||
|
||
if(clear_form_com){
|
||
clear_form_com.reset();
|
||
}
|
||
|
||
|
||
|
||
let disable_btn = document.getElementById('send_feedback_form');
|
||
|
||
if(disable_btn){
|
||
disable_btn.removeAttribute('disabled');
|
||
|
||
}
|
||
|
||
|
||
|
||
let disable_btn_r = document.getElementById('request_btn');
|
||
if(disable_btn_r){
|
||
disable_btn_r.removeAttribute('disabled');
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
function confirmRemove(el, route_id) {
|
||
|
||
|
||
let hide_edit_button = document.getElementById('edit_route_'+ route_id);
|
||
let confirm_remove = document.getElementById('confirm_remove_'+ route_id);
|
||
let cancel_remove = document.getElementById('cancel_remove_'+ route_id);
|
||
hide_edit_button.classList.toggle('hide')
|
||
confirm_remove.classList.add('show');
|
||
cancel_remove.classList.add('show');
|
||
|
||
let remove_btn = document.getElementById('remove_route_'+route_id);
|
||
remove_btn.classList.add('hide');
|
||
|
||
}
|
||
|
||
function loader_place_ins_boris (el,type=null){
|
||
if (el && !window.location.href.includes("profile")){
|
||
|
||
let loader_place = document.querySelector(".abbreviation_airport_in_search")
|
||
let cur_loader_place = el.nextElementSibling
|
||
if (type){
|
||
cur_loader_place.innerHTML = ""
|
||
changeWidthEL(el)
|
||
} else {
|
||
if (loader_place){
|
||
|
||
if (cur_loader_place.innerHTML === '<img src="/static/img/svg/loader.svg" style="height: 30px;padding-top: 17px;padding-left: 15px;">'){
|
||
cur_loader_place.innerHTML = ""
|
||
} else {
|
||
cur_loader_place.innerHTML = "<img src='/static/img/svg/loader.svg' style='height: 30px;padding-top: 17px;padding-left: 15px;'>"
|
||
}
|
||
changeWidthEL(el)
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
function searchTown(el){
|
||
|
||
if (el.value.length > 2){
|
||
el.style.background = 'white url("/static/img/svg/loader.svg") no-repeat calc(100% - 15px) center';
|
||
|
||
|
||
|
||
}else {
|
||
el.style.background = 'white url("/static/img/png/icon-arrow.svg") no-repeat calc(100% - 15px) center';
|
||
}
|
||
|
||
if(el.value.length>=3){
|
||
let timer = null
|
||
if (timer) {
|
||
clearTimeout(timer);
|
||
}
|
||
timer = setTimeout(function(){
|
||
loader_place_ins_boris(el)
|
||
timer = null;
|
||
let form = el.form;
|
||
let type_transport_el = form['type_transport'];
|
||
let type_transport = ""
|
||
if(type_transport_el){
|
||
type_transport = type_transport_el.value
|
||
}
|
||
let search_str = el.value;
|
||
let get_address_point = new Object({type_transport, search_str});
|
||
get_address_point['ctrl_name'] = el.name;
|
||
|
||
$.ajax({
|
||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
url: '/reference_data/get_address_point/',
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
data: JSON.stringify(get_address_point),
|
||
success: function(data){
|
||
el.style.background = 'white url("/static/img/png/icon-arrow.svg") no-repeat calc(100% - 15px) center';
|
||
loader_place_ins_boris(el,"el")
|
||
|
||
|
||
|
||
|
||
return insertSearchList(data, el.name + '_list');
|
||
middleWareJS()
|
||
},
|
||
error: function (data){
|
||
|
||
console.log('Error')
|
||
|
||
}
|
||
});
|
||
}, 500);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
function selectItemAddrPoint(id, name, ctrl_name,){
|
||
let input_list = document.getElementsByName(ctrl_name + '_list')[0];
|
||
let tap_txt_cont = document.querySelector("#id_" + ctrl_name);
|
||
tap_txt_cont.value = name;
|
||
tap_txt_cont.setAttribute('title',name)
|
||
let tap_cont = document.querySelector("#id_" + ctrl_name.slice(0, -4));
|
||
tap_cont.value = id;
|
||
if (tap_txt_cont.classList.contains('red_text')){
|
||
tap_txt_cont.classList.remove('red_text')
|
||
}
|
||
|
||
if (!window.location.href.includes("profile")){
|
||
changeWidthEL(tap_txt_cont)
|
||
}
|
||
input_list.classList.remove('show');
|
||
|
||
}
|
||
|
||
|
||
function insertSearchList(data, ctrl_name) {
|
||
|
||
let input_list = document.getElementsByName(ctrl_name)[0];
|
||
let divs = data.res_search_list;
|
||
|
||
if (divs.length > 0) {
|
||
input_list.classList.add("show");
|
||
input_list.innerHTML = divs;
|
||
} else {
|
||
input_list.classList.remove("show");
|
||
}
|
||
|
||
}
|
||
|
||
|
||
function showSearchList(el) {
|
||
if(el.classList.contains('from_address_point_txt')){
|
||
let input_list = document.querySelectorAll('.input_list')
|
||
let value = input_list[0].classList.contains('show')
|
||
if(value === false && input_list[0].childElementCount > 0){
|
||
input_list[0].classList.add("show");
|
||
}
|
||
}else if (el.classList.contains('to_address_point_txt')) {
|
||
let input_list = document.querySelectorAll('.input_list')
|
||
let value = input_list[1].classList.contains('show')
|
||
if(value === false && input_list[1].childElementCount > 0){
|
||
input_list[1].classList.add("show");
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
function onblurInputField(event,el){
|
||
|
||
// if(el.classList.contains("from_country_container")){
|
||
let search_list = document.getElementsByName(el.name + '_list')[0];
|
||
let parent_event = $(event.explicitOriginalTarget).parents('.input_list' );
|
||
if(!parent_event || parent_event[0] !== search_list){
|
||
|
||
search_list.classList.remove('show')
|
||
}
|
||
|
||
// }
|
||
}
|
||
|
||
function clearID(el) {
|
||
|
||
el.select();
|
||
|
||
if(el.value !== "" && el.id === 'id_from_address_point_txt' ){
|
||
document.getElementById('id_from_address_point').value = ''
|
||
el.value = ''
|
||
// el.classList.add('red_text')
|
||
} else if(el.value !== "" && el.id === 'id_to_address_point_txt'){
|
||
document.getElementById('id_to_address_point').value = ''
|
||
el.value = ''
|
||
|
||
|
||
// el.classList.add('red_text')
|
||
}
|
||
|
||
}
|
||
|
||
|
||
// function hideErrorMsg(el) {
|
||
// let hide_element = document.querySelector()
|
||
// if(el.value !== 0){
|
||
// hide_element.classList.add('hide')
|
||
// }
|
||
//
|
||
// }
|
||
|
||
function sliderInit() {
|
||
|
||
let $range = $("#id_weight"),
|
||
$input = $(".js-input"),
|
||
instance,
|
||
min = 0,
|
||
max = 1000,
|
||
start_value = document.querySelector(".range-slider").value;
|
||
|
||
$range.ionRangeSlider({
|
||
skin: "round",
|
||
type: "single",
|
||
min: min,
|
||
max: max,
|
||
from: start_value,
|
||
step: 1,
|
||
grid: true,
|
||
grid_num: 5,
|
||
onStart: function(data) {
|
||
if(data.from > 0){
|
||
$input.prop("value", data.from);
|
||
}
|
||
},
|
||
onChange: function(data) {
|
||
$input.prop("value", data.from);
|
||
}
|
||
});
|
||
|
||
instance = $range.data("ionRangeSlider");
|
||
|
||
$input.on("change keyup", function() {
|
||
let val = $(this).prop("value");
|
||
|
||
// validate
|
||
if (val < min) {
|
||
val = min;
|
||
} else if (val > max) {
|
||
val = max;
|
||
}
|
||
|
||
instance.update({
|
||
from: val
|
||
});
|
||
});
|
||
|
||
|
||
}
|
||
|
||
function sendRoute(el, routeID = null){
|
||
event.preventDefault()
|
||
el.disabled = true
|
||
|
||
|
||
// let list_of_elements_form = document.querySelectorAll(".el_form_b_new_route");
|
||
// let checked_cargo_type = document.querySelectorAll('.cargo_check');
|
||
//
|
||
// let obj_w_el_form = {}
|
||
//
|
||
//
|
||
// for (let n = 0;n < checked_cargo_type.length; n++){
|
||
// let checked_cargo = checked_cargo_type[n]
|
||
// if(checked_cargo.checked === true){
|
||
// let name_cargo = checked_cargo.name
|
||
// let value_cargo = checked_cargo_type[n].value
|
||
// obj_w_el_form[name_cargo] = value_cargo
|
||
//
|
||
//
|
||
// }
|
||
// }
|
||
//
|
||
//
|
||
//
|
||
//
|
||
// for (let i = 0; i < list_of_elements_form.length ;i++) {
|
||
// // let id_el = list_of_elements_form[i].id
|
||
// // if (id_el){
|
||
// // if (id_el === "")
|
||
// // }
|
||
//
|
||
//
|
||
//
|
||
// let name_attr = list_of_elements_form[i].attributes["name"]
|
||
// if (name_attr) {
|
||
// let name_el = name_attr.value
|
||
// let value_el = list_of_elements_form[i].value
|
||
// obj_w_el_form[name_el] = value_el
|
||
// }
|
||
// }
|
||
//
|
||
//
|
||
//
|
||
// let selected_owner_type = document.querySelectorAll("#customer, #mover")
|
||
//
|
||
// selected_owner_type.forEach(function(item) {
|
||
// if (item.classList.contains('selected')) {
|
||
// let { id, innerText } = item
|
||
// obj_w_el_form['owner_type'] = id
|
||
// }
|
||
// });
|
||
//
|
||
// if (selected_owner_type[0].classList.contains('selected')){
|
||
//
|
||
// }else{}
|
||
let owner_type_value = document.getElementById('hide_owner_type').value
|
||
|
||
let form = el.form
|
||
let formData = new FormData(form);
|
||
let owner_type = owner_type_value
|
||
formData.set('owner_type', owner_type)
|
||
|
||
let url = '/routes/create_or_change_route/'
|
||
if (routeID !== null){
|
||
url = '/routes/change_route/' + routeID + '/'
|
||
}
|
||
|
||
$.ajax({
|
||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
url: url,
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
// data: JSON.stringify(obj_w_el_form),
|
||
data: formData,
|
||
success: function(data){
|
||
|
||
let data_route_id = data.route_id
|
||
// location.href = '/profile'
|
||
document.querySelector(".info_profile").innerHTML = data.html
|
||
|
||
|
||
|
||
let el_route = document.querySelector(`[data-number-of-route="${data_route_id}"]`);
|
||
if (routeID){
|
||
el_route = document.querySelector(`[data-number-of-route="${routeID}"]`);
|
||
}
|
||
el_route.scrollIntoView({
|
||
behavior:"smooth",
|
||
block:'start',
|
||
inline:'start'
|
||
});
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// document.querySelector(".tab_user_messanger.select").scrollIntoView({behavior: "smooth",block:'nearest',inline:'nearest'});
|
||
|
||
|
||
let list_div = document.querySelectorAll('.menu_profile div');
|
||
let my_routes = document.getElementById("my_routes_id")
|
||
list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
my_routes.classList.add('selected')
|
||
middleWareJS()
|
||
|
||
},
|
||
error: function (data, exception){
|
||
document.querySelector(".info_profile").innerHTML = data.responseJSON.html;
|
||
// $(el).attr('disabled', 'false')
|
||
|
||
document.getElementById('id_type_transport').scrollIntoView({behavior: "smooth",block:'nearest',inline:'nearest'});
|
||
|
||
sliderInit();
|
||
init_departure_DT()
|
||
init_arrival_DT()
|
||
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
function confirmUpgrade(el, routeID){
|
||
event.preventDefault()
|
||
el.disabled = true
|
||
|
||
let form = el.form
|
||
let formData = new FormData(form);
|
||
formData.set('route_id', routeID)
|
||
let url = '/routes/'
|
||
let checkboxes = document.querySelectorAll('input[name="route_option"]');
|
||
|
||
|
||
for (let i = 0; i < checkboxes.length; i++) {
|
||
|
||
if (checkboxes[i].checked && checkboxes[i].id === "highlight_route" ) {
|
||
url = '/routes/highlight_route/'
|
||
}else if(checkboxes[i].checked && checkboxes[i].id === "raise_route"){
|
||
url = '/routes/raise_route/'
|
||
}
|
||
}
|
||
|
||
$.ajax({
|
||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
url: url,
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
// data: JSON.stringify(obj_w_el_form),
|
||
data: formData,
|
||
success: function(data){
|
||
|
||
let data_route_id = data.route_id
|
||
// location.href = '/profile'
|
||
// document.querySelector(".info_profile").innerHTML = data.html
|
||
|
||
|
||
|
||
let el_route = document.querySelector(`[data-number-of-route="${data_route_id}"]`);
|
||
if (routeID){
|
||
el_route = document.querySelector(`[data-number-of-route="${routeID}"]`);
|
||
}
|
||
el_route.scrollIntoView({
|
||
behavior:"smooth",
|
||
block:'start',
|
||
inline:'start'
|
||
});
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// document.querySelector(".tab_user_messanger.select").scrollIntoView({behavior: "smooth",block:'nearest',inline:'nearest'});
|
||
|
||
|
||
let list_div = document.querySelectorAll('.menu_profile div');
|
||
let my_routes = document.getElementById("my_routes_id")
|
||
list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
my_routes.classList.add('selected')
|
||
middleWareJS()
|
||
|
||
},
|
||
error: function (data, exception){
|
||
document.querySelector(".info_profile").innerHTML = data.responseJSON.html;
|
||
// $(el).attr('disabled', 'false')
|
||
|
||
document.getElementById('id_type_transport').scrollIntoView({behavior: "smooth",block:'nearest',inline:'nearest'});
|
||
|
||
sliderInit();
|
||
init_departure_DT()
|
||
init_arrival_DT()
|
||
|
||
|
||
}
|
||
});
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
// function validate(el) {
|
||
// if (el.checked) {
|
||
// console.log('cheked', el.id);
|
||
// } else {
|
||
// console.log("You didn't check it! Let me check it for you.", el.id);
|
||
// }
|
||
// }
|
||
|
||
function setIcon(el) {
|
||
if(el.id === 'id_departure_DT' ){
|
||
document.getElementById('id_departure_DT').style.background = 'url("/static/img/svg/IconCalendar.svg") white 98% no-repeat';
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
//cleaning route inputs after selection changes
|
||
function OnSelectionChange(el) {
|
||
event.preventDefault()
|
||
let form = el.form;
|
||
|
||
// if (customer.classList.contains('selected')) {
|
||
// owner_type = form.dataset['customer']
|
||
// } else if (mover.classList.contains('selected')) {
|
||
// owner_type = form.dataset['customer']
|
||
// }
|
||
let owner_type_value = document.getElementById('hide_owner_type').value
|
||
|
||
|
||
|
||
let formData = new FormData(form);
|
||
let owner_type = owner_type_value
|
||
formData.set('owner_type', owner_type)
|
||
|
||
// formData.set('owner_type', owner_type)
|
||
|
||
// let data = {};
|
||
// data['csrfmiddlewaretoken'] = $('input[name="csrfmiddlewaretoken"]')[0].value;
|
||
// data['type_transport'] = $('select[name="type_transport"]')[0].value;
|
||
|
||
$.ajax({
|
||
headers: {"X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val()},
|
||
url: '/user_account/new_route_view/',
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
// data: JSON.stringify(data),
|
||
data: formData,
|
||
success: function (data) {
|
||
console.log('data.html');
|
||
// location.href = '/profile'
|
||
document.querySelector(".info_profile").innerHTML = data.html
|
||
//
|
||
// let checkbox_width = document.querySelector('.checkbox_cargo_type');
|
||
// if(checkbox_width.childElementCount === 4){
|
||
// checkbox_width.classList.add('width')
|
||
// }
|
||
sliderInit();
|
||
|
||
init_arrival_DT()
|
||
init_departure_DT()
|
||
|
||
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
// function createRoute(el, owner_type){
|
||
// let obj = {
|
||
// 'owner_type': owner_type
|
||
// }
|
||
//
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// url: '/user_account/new_route_view/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// data: JSON.stringify(obj),
|
||
// success: function(data){
|
||
//
|
||
//
|
||
// // location.href = '/profile'
|
||
// document.querySelector(".info_profile").innerHTML = data.html
|
||
//
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
//
|
||
// //updating the url without reloading
|
||
// if(el.id == 'customer'){
|
||
// window.history.pushState(null, null, '/ru/profile/page/create_route_for_customer/')
|
||
// } else {
|
||
// window.history.pushState(null, null, '/ru/profile/page/create_route_for_mover/')
|
||
// }
|
||
// middleWareJS()
|
||
//
|
||
//
|
||
//
|
||
// //get dynamic value
|
||
// // let fromCountry = document.getElementById('id_from_country');
|
||
// // let toCounytry = document.getElementById('id_to_country')
|
||
// //
|
||
// // toCounytry.oninput = function (){
|
||
// // console.log(toCounytry.value)
|
||
// // }
|
||
// // fromCountry.oninput = function (){
|
||
// // console.log(fromCountry.value)
|
||
// //
|
||
// // };
|
||
//
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// console.log(101)
|
||
//
|
||
// }
|
||
// });
|
||
// }
|
||
|
||
// function getRoute(el){
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// url: '/routes/get_routes/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// // data: formData,
|
||
// success: function(data){
|
||
//
|
||
//
|
||
// // location.href = '/profile'
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
//
|
||
// let list_div = document.querySelectorAll('.menu_profile div');
|
||
// list_div.forEach(el=>{ el.classList.remove('selected'); });
|
||
// el.classList.add('selected')
|
||
//
|
||
// window.history.pushState(null, null, '/ru/profile/page/my_routes/')
|
||
//
|
||
// middleWareJS()
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// console.log(101)
|
||
//
|
||
// }
|
||
// });
|
||
// }
|
||
|
||
function editRoute(id) {
|
||
let route_obj = {
|
||
'route_id': id
|
||
}
|
||
|
||
$.ajax({
|
||
headers: {"X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val()},
|
||
url: '/routes/edit_route/',
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
data: JSON.stringify(route_obj),
|
||
success: function (data) {
|
||
|
||
// location.href = '/profile'
|
||
document.querySelector(".info_profile").innerHTML = data.html;
|
||
if(data.html){
|
||
let changeTextButton = document.getElementById('registration')
|
||
changeTextButton.innerText = data.btn_title
|
||
window.scrollTo({
|
||
top: 0,
|
||
left: 0,
|
||
behavior: "smooth"
|
||
});
|
||
}
|
||
|
||
init_departure_DT()
|
||
init_arrival_DT()
|
||
sliderInit();
|
||
|
||
|
||
|
||
},
|
||
error: function (data, exception) {
|
||
console.log(101)
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
function showMenu(el, event) {
|
||
let menu = document.querySelector('.dropdown-content');
|
||
|
||
if(menu.classList.contains('show')){
|
||
menu.classList.remove('show')
|
||
} else {
|
||
menu.classList.add('show')
|
||
}
|
||
}
|
||
|
||
function showControlFrame(el, route_id){
|
||
let menu = document.getElementById('control_frame_'+ route_id );
|
||
|
||
if(menu.classList.contains('show')){
|
||
menu.classList.remove('show')
|
||
} else {
|
||
menu.classList.add('show')
|
||
}
|
||
}
|
||
|
||
|
||
function showLang(el) {
|
||
let lang = document.querySelector('.dropdown-content-lang');
|
||
if(lang.classList.contains('show')){
|
||
lang.classList.remove('show')
|
||
} else {
|
||
lang.classList.add('show')
|
||
}
|
||
|
||
}
|
||
|
||
// function hideMenu(event) {
|
||
// let menu = document.querySelector('.dropdown-content')
|
||
// if(event.currentTarget !== event.relatedTarget && event.relatedTarget != null){
|
||
// menu.classList.remove('show')
|
||
// }
|
||
//
|
||
// }
|
||
|
||
function checkDate() {
|
||
let dateDeparture = document.getElementById('id_departure_DT');
|
||
let dateArrival = document.getElementById('id_arrival_DT');
|
||
let DateStart = new Date(dateDeparture.value);
|
||
let DateEnd = new Date(dateArrival.value);
|
||
if (DateEnd < DateStart) {
|
||
|
||
// alert("End date cannot be less than Start date.");
|
||
dateArrival.value = ""
|
||
|
||
// let arrivalDiv = document.getElementById('arrival_div')
|
||
// let errorMessage = document.createElement('span');
|
||
// // errorMessage.textContent = "Дата прибытия, не может быть установлена раньше даты отправки"
|
||
// errorMessage.classList.add('errorlist')
|
||
// arrivalDiv.appendChild(errorMessage);
|
||
}
|
||
else if (DateEnd > DateStart){
|
||
let arrivalDiv = document.getElementById('arrival_div');
|
||
let errorMessage = document.querySelector('.errorlist');
|
||
arrivalDiv.removeChild((errorMessage))
|
||
}
|
||
|
||
}
|
||
|
||
|
||
// const form = document.querySelector('form');
|
||
// document.querySelector('[type="button"]').addEventListener('click', e => {
|
||
// if (!form.checkValidity()) {
|
||
// alert('Хьюстон, у нас проблемы!');
|
||
// }
|
||
// });
|
||
|
||
function RequestCommercialOffer (el){
|
||
|
||
el.style.background = '#FF613A url("/static/img/svg/loader_white.svg") no-repeat center';
|
||
el.style.contentVisibility = 'hidden';
|
||
|
||
event.preventDefault()
|
||
|
||
let disable_btn = document.getElementById('send_feedback_form');
|
||
let disable_btn_req = document.getElementById('request_btn');
|
||
let disable_btn_f = document.getElementById('footer_input_button');
|
||
|
||
if(el.id === 'footer_input_button'){
|
||
disable_btn_f.setAttribute('disabled', true);
|
||
} else {
|
||
if(disable_btn){
|
||
disable_btn.setAttribute('disabled', true);
|
||
}
|
||
|
||
if(disable_btn_req){
|
||
disable_btn_req.setAttribute('disabled', true);
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
let form = el.form;
|
||
let formData = new FormData(form);
|
||
let form_name = form.dataset['name']
|
||
formData.set('form_name',form_name)
|
||
|
||
|
||
$.ajax({
|
||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
url: '/user_account/send_message/',
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
data: formData,
|
||
success: function(data){
|
||
|
||
// el.style.background = '#FF613A';
|
||
el.removeAttribute('style')
|
||
|
||
|
||
|
||
if(el.id !== 'footer_input_button'){
|
||
let insert_text = document.querySelector(".clear_form")
|
||
if(insert_text){
|
||
$(data.html).insertBefore(insert_text)
|
||
}
|
||
|
||
let insert_text_2 = document.querySelector(".commercial_offer")
|
||
if(insert_text_2){
|
||
|
||
$(data.html).insertBefore(insert_text_2)
|
||
}
|
||
} else {
|
||
let disable_btn_f = document.getElementById('footer_input_button');
|
||
disable_btn_f.removeAttribute('disabled');
|
||
let clear_footer_form = document.getElementById('clear_input');
|
||
|
||
clear_footer_form.reset();
|
||
|
||
let hide_error_msg = document.getElementById('error_footer').classList.add('hide')
|
||
}
|
||
|
||
},
|
||
error: function (data, exception){
|
||
// document.querySelector(".login").innerHTML = data.responseJSON.html
|
||
|
||
if(el.id !== 'footer_input_button'){
|
||
let feedback_form = document.querySelector('.feedback_form')
|
||
if(feedback_form){
|
||
feedback_form.innerHTML = data.responseJSON.html;
|
||
// let incorrect_block = document.querySelectorAll('.inputs_l')
|
||
|
||
}
|
||
|
||
let commercial_offer = document.querySelector('.commercial_offer')
|
||
if(commercial_offer){
|
||
commercial_offer.innerHTML = data.responseJSON.html;
|
||
}
|
||
} else {
|
||
let footer_form = document.querySelector('.insert_form').innerHTML = data.responseJSON.html;
|
||
|
||
// $(data.responseJSON.html).insertBefore(footer_form)
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
|
||
|
||
}
|
||
});
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
function subscribeNewsletter (el){
|
||
|
||
el.style.background = '#FF613A url("/static/img/svg/loader_white.svg") no-repeat center';
|
||
el.style.contentVisibility = 'hidden';
|
||
|
||
event.preventDefault()
|
||
|
||
let disable_btn_f = document.getElementById('footer_input_button');
|
||
|
||
disable_btn_f.setAttribute('disabled', true);
|
||
|
||
|
||
let form = el.form;
|
||
let formData = new FormData(form);
|
||
let form_name = form.dataset['name']
|
||
formData.set('form_name',form_name)
|
||
|
||
|
||
$.ajax({
|
||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
url: '/user_account/mailing_subscribe/',
|
||
type: "POST",
|
||
// async: true,
|
||
cache: false,
|
||
processData: false,
|
||
contentType: false,
|
||
// enctype: 'json',
|
||
data: formData,
|
||
success: function(data){
|
||
|
||
// el.style.background = '#FF613A';
|
||
el.removeAttribute('style')
|
||
|
||
if(data.status === 'sended' && data.del_form === true){
|
||
|
||
document.querySelector('.footer_input_wrap').innerHTML = data.html;
|
||
|
||
} else if(data.redirect_url){
|
||
window.sessionStorage.setItem('email', data.email)
|
||
window.sessionStorage.setItem('mailingSubscribeRequired','true')
|
||
window.location.replace(data.redirect_url)
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
if(el.id !== 'footer_input_button'){
|
||
let insert_text = document.querySelector(".clear_form")
|
||
if(insert_text){
|
||
$(data.html).insertBefore(insert_text)
|
||
}
|
||
|
||
let insert_text_2 = document.querySelector(".commercial_offer")
|
||
if(insert_text_2){
|
||
$(data.html).insertBefore(insert_text_2)
|
||
}
|
||
} else {
|
||
let disable_btn_f = document.getElementById('footer_input_button');
|
||
if(disable_btn_f){
|
||
disable_btn_f.removeAttribute('disabled');
|
||
}
|
||
|
||
let clear_footer_form = document.getElementById('clear_input');
|
||
|
||
clear_footer_form.reset();
|
||
|
||
let hide_error_msg = document.getElementById('error_footer').classList.add('hide')
|
||
}
|
||
|
||
},
|
||
error: function (data, exception){
|
||
// document.querySelector(".login").innerHTML = data.responseJSON.html
|
||
|
||
if(el.id !== 'footer_input_button'){
|
||
let feedback_form = document.querySelector('.feedback_form')
|
||
if(feedback_form){
|
||
feedback_form.innerHTML = data.responseJSON.html;
|
||
// let incorrect_block = document.querySelectorAll('.inputs_l')
|
||
|
||
}
|
||
|
||
let commercial_offer = document.querySelector('.commercial_offer')
|
||
if(commercial_offer){
|
||
commercial_offer.innerHTML = data.responseJSON.html;
|
||
}
|
||
} else {
|
||
let footer_form = document.querySelector('.insert_form').innerHTML = data.responseJSON.html;
|
||
|
||
// $(data.responseJSON.html).insertBefore(footer_form)
|
||
}
|
||
|
||
// document.querySelector(".info_profile").innerHTML = data.html;
|
||
}
|
||
});
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
function hideErrors(el) {
|
||
let error_feeedback_text = document.getElementById('error_feedback_text')
|
||
let error_feeedback = el.nextElementSibling
|
||
let counter_text = document.querySelector('.counter-text')
|
||
let footer_button = document.getElementById('footer_input_button')
|
||
let error_footer = document.getElementById('error_footer')
|
||
let agree_error = document.getElementById('reg_agree_error')
|
||
let error_departure_DT = document.getElementById('error_departure_DT')
|
||
let error_arrival_DT = document.getElementById('error_arrival_DT')
|
||
let error_from_address_point = document.getElementById('error_from_address_point')
|
||
let error_to_address_point = document.getElementById('error_to_address_point')
|
||
let error_cargo_type = document.getElementById('error_cargo_type')
|
||
let error_id_phone = document.getElementById('error_id_phone')
|
||
|
||
|
||
|
||
|
||
|
||
if(error_feeedback === counter_text && error_feeedback !== null && error_feeedback_text !== null ){
|
||
error_feeedback_text.classList.add('hide')
|
||
} else if(error_feeedback === footer_button && error_footer !== null ){
|
||
error_footer.classList.add('hide')
|
||
} else if(el.id === 'agreement_check'){
|
||
agree_error.classList.add('hide')
|
||
} else if(el.id === 'id_arrival_DT' && error_arrival_DT !== null){
|
||
error_arrival_DT.classList.add('hide')
|
||
}else if(el.id === 'id_departure_DT' && error_departure_DT !== null){
|
||
error_departure_DT.classList.add('hide')
|
||
} else if(el.id === 'id_from_address_point_txt' && error_from_address_point !== null ){
|
||
error_from_address_point.classList.add('hide')
|
||
}else if(el.id === 'id_to_address_point_txt' && error_to_address_point !== null ){
|
||
error_to_address_point.classList.add('hide')
|
||
} else if(el.id === 'id_cargo_lable' && error_cargo_type !== null){
|
||
error_cargo_type.classList.add('hide')
|
||
} else if(el.id === 'id_phone' && error_id_phone !==null){
|
||
error_id_phone.classList.add('hide')
|
||
}
|
||
|
||
else if(error_feeedback !== null) {
|
||
error_feeedback.classList.add('hide')
|
||
}
|
||
|
||
}
|
||
|
||
// function SendFeedbackForm (el){
|
||
//
|
||
// event.preventDefault()
|
||
// let form = el.form;
|
||
// let formData = new FormData(form);
|
||
// let form_name = form.dataset['name']
|
||
// formData.set('form_name',form_name)
|
||
//
|
||
//
|
||
//
|
||
//
|
||
// $.ajax({
|
||
// headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||
// // url: '/user_account/request_offer/',
|
||
// type: "POST",
|
||
// // async: true,
|
||
// cache: false,
|
||
// processData: false,
|
||
// contentType: false,
|
||
// // enctype: 'json',
|
||
// data: formData,
|
||
// success: function(data){
|
||
//
|
||
// // location.href = '/profile'
|
||
//
|
||
//
|
||
// },
|
||
// error: function (data, exception){
|
||
// // document.querySelector(".login").innerHTML = data.responseJSON.html
|
||
// }
|
||
// });
|
||
// }
|
||
|
||
|
||
|
||
function counterText(evt) {
|
||
const counter = document.querySelector('.counter-text__current');
|
||
const maxlength = 360;
|
||
counter.textContent = evt.value.length;
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
function showTabBtn(el) {
|
||
|
||
let mover_info = document.getElementById('content-1')
|
||
let customer_info = document.getElementById('content-2')
|
||
let tab_btn_1 = document.querySelector('.tab-btn-1')
|
||
let tab_btn_2 = document.querySelector('.tab-btn-2')
|
||
|
||
if (el.classList.contains('tab-btn-1')){
|
||
mover_info.classList.add('show')
|
||
customer_info.classList.remove('show')
|
||
|
||
tab_btn_1.classList.add('tab-btn-active')
|
||
tab_btn_2.classList.remove('tab-btn-active')
|
||
|
||
|
||
} else if(el.classList.contains('tab-btn-2')){
|
||
customer_info.classList.add('show')
|
||
mover_info.classList.remove('show')
|
||
|
||
tab_btn_2.classList.add('tab-btn-active')
|
||
tab_btn_1.classList.remove('tab-btn-active')
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|