// var listener = 0 // var cur_el_ins = null // // function focus_el_ins (el) { // if (el.value.length > 0) { // cur_el_ins = el // } // } // // // function searchTown(el){ // // // document.getElementById('id_from_address_point_txt').style.background = 'white url("/static/img/svg/loader.svg") no-repeat calc(100% - 15px) center'; // // document.getElementById('id_to_address_point_txt').style.background = 'white url("/static/img/svg/loader.svg") no-repeat calc(100% - 15px) center'; // // if(el.value.length >= 3){ // let timer = null // if (timer) { // clearTimeout(timer); // } // let element = el // timer = setTimeout(function(){ // // timer = null; // // let form = el.form; // let type_transport = 'road'; // let search_str = el.value; // let get_address_point = new Object({type_transport, search_str}); // get_address_point['ctrl_name'] = "govno" // get_address_point['for_filter'] = true // // $.ajax({ // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // url: '/ru/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){ // // document.getElementById('id_from_address_point_txt').style.background = 'white url("/static/img/png/icon-arrow.svg") no-repeat calc(100% - 15px) center'; // // document.getElementById('id_to_address_point_txt').style.background = 'white url("/static/img/png/icon-arrow.svg") no-repeat calc(100% - 15px) center'; // // // middleWareJS() // let insert_place_1 = element.nextSibling // let insert_place_2 = insert_place_1.nextSibling // let insert_place = insert_place_2.nextSibling // if (data.res_search_list !== null || data.res_search_list !== ""){ // insert_place.innerHTML = data.res_search_list // insert_place.nextSibling.classList.add("show") // } else { // if (insert_place.classList.contains("show")){ // insert_place.classList.remove("show") // } // } // listener = 0 // // return insertSearchList(data, el.name + '_list'); // // }, // error: function (data){ // // console.log('Error') // listener = 1 // // } // }); // }, 1500); // } // // } // // function show_list_w_places (el){ // let value = el.value // if (value.length > 0){ // if (listener === 0){ // let listener_ev = document.querySelector("body") // listener_ev.setAttribute('onclick',"listen_body(event)") // } // } // } // // function listen_body (event){ // let input_1 = document.querySelector("#inp_form_find_route_w_abbreviation_1") // let input_2 = document.querySelector("#inp_form_find_route_w_abbreviation_2") // let place_1 = document.querySelectorAll(".insert-airports-place")[0] // let place_2 = document.querySelectorAll(".insert-airports-place")[1] // let list_els = [input_1,input_2,place_1,place_2] // let i = 0 // let true_ev = false // list_els.map(function (){ // if (event.target.id === list_els[i].id){ // console.log("true") // true_ev = true // if (cur_el_ins !== event.target){ // let cur_el_insert_1 = event.target.nextSibling // let cur_el_insert_2 = cur_el_insert_1.nextSibling // let cur_el_insert_3 = cur_el_insert_2.nextSibling // let cur_el_insert = cur_el_insert_3.nextSibling // if (cur_el_insert.classList.contains("show")) { // cur_el_insert.classList.remove("show") // } // } // } // i++ // }) // // if (true_ev === false) { // if (input_1.focus() === true){ // if (place_1.classList.contains("show")){ // place_1.remove("show") // listener++ // } // } else if (input_2.focus === true){ // if (place_2.classList.contains("show")){ // place_2.remove("show") // listener++ // } // } else { // console.log("error") // } // } // } // // //