0.0.22 autocomlitev2.js
This commit is contained in:
@@ -3,6 +3,6 @@ django-ckeditor==6.5.1
|
|||||||
psycopg2-binary==2.9.6
|
psycopg2-binary==2.9.6
|
||||||
requests
|
requests
|
||||||
Pillow
|
Pillow
|
||||||
django-modeltranslation=0.18.10
|
django-modeltranslation
|
||||||
overpass
|
overpass
|
||||||
geopy
|
geopy
|
||||||
53
static/js/autocomlitev2.js
Normal file
53
static/js/autocomlitev2.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
function searchTown(el){
|
||||||
|
let form = el.form;
|
||||||
|
let type_transport = form['type_transport'].value;
|
||||||
|
let search_str = el.value;
|
||||||
|
let get_address_point = new Object({type_transport, search_str})
|
||||||
|
|
||||||
|
|
||||||
|
$.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: get_address_point,
|
||||||
|
success: function(data){
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
error: function (data){
|
||||||
|
console.log('++')
|
||||||
|
// document.querySelector(".button_register").innerHTML = data.responseJSON.html
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function search(e) {
|
||||||
|
|
||||||
|
let ac = document.querySelector("#id_from_country")
|
||||||
|
|
||||||
|
if (ac.value.length > 0) {
|
||||||
|
|
||||||
|
let results = searchTown(ac);
|
||||||
|
|
||||||
|
var divs = results.map()(function(r, i) {
|
||||||
|
return '<div class="autocomplete-result" data-index="'+ i +'">'
|
||||||
|
+ '<div><b>'+ r.iata +'</b> - '+ r.name +'</div>'
|
||||||
|
+ '<div class="autocomplete-location">'+ r.city +', '+ r.country +'</div>'
|
||||||
|
+ '</div>';
|
||||||
|
});
|
||||||
|
|
||||||
|
selectedIndex = -1;
|
||||||
|
list.html(divs.join(''))
|
||||||
|
.attr('data-highlight', selectedIndex);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
numResults = 0;
|
||||||
|
list.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,25 +18,27 @@
|
|||||||
|
|
||||||
function searchTown(el){
|
function searchTown(el){
|
||||||
let form = el.form;
|
let form = el.form;
|
||||||
let formData = new FormData(form);
|
let type_transport = form['type_transport'].value;
|
||||||
|
let search_str = el.value;
|
||||||
|
let get_address_point = new Object({type_transport, search_str})
|
||||||
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||||||
url: '/ru/routes/create_route/',
|
url: '/reference_data/get_address_point/',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
// async: true,
|
// async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
// enctype: 'json',
|
// enctype: 'json',
|
||||||
data: formData,
|
data: get_address_point,
|
||||||
success: function(data){
|
success: function(data){
|
||||||
console.log('data received')
|
return data;
|
||||||
// location.href = '/profile'
|
|
||||||
document.querySelector(".info_profile").innerHTML = data.html
|
|
||||||
},
|
},
|
||||||
error: function (data, exception){
|
error: function (data){
|
||||||
document.querySelector(".button_register").innerHTML = data.responseJSON.html
|
console.log('++')
|
||||||
|
// document.querySelector(".button_register").innerHTML = data.responseJSON.html
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -45,7 +47,7 @@ var ac = $('#id_from_country')
|
|||||||
.on('click', function(e) {
|
.on('click', function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
})
|
})
|
||||||
.on('focus keyup', search)
|
.on('keyup', search)
|
||||||
.on('keydown', onKeyDown);
|
.on('keydown', onKeyDown);
|
||||||
|
|
||||||
var wrap = $('<div>')
|
var wrap = $('<div>')
|
||||||
@@ -93,13 +95,15 @@ function search(e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ac.val().length > 0) {
|
let ac = document.querySelector("#id_from_country")
|
||||||
|
|
||||||
|
if (ac.value.length > 0) {
|
||||||
// results = _.take(fuse.search(ac.val()), 7);
|
// results = _.take(fuse.search(ac.val()), 7);
|
||||||
// numResults = results.length;
|
// numResults = results.length;
|
||||||
|
|
||||||
results = searchTown.success(data);
|
let results = searchTown(ac);
|
||||||
|
|
||||||
var divs = results.map(function(r, i) {
|
var divs = results.map()(function(r, i) {
|
||||||
return '<div class="autocomplete-result" data-index="'+ i +'">'
|
return '<div class="autocomplete-result" data-index="'+ i +'">'
|
||||||
+ '<div><b>'+ r.iata +'</b> - '+ r.name +'</div>'
|
+ '<div><b>'+ r.iata +'</b> - '+ r.name +'</div>'
|
||||||
+ '<div class="autocomplete-location">'+ r.city +', '+ r.country +'</div>'
|
+ '<div class="autocomplete-location">'+ r.city +', '+ r.country +'</div>'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function createRoute(){
|
|||||||
// enctype: 'json',
|
// enctype: 'json',
|
||||||
// data: {},
|
// data: {},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
console.log('data received')
|
// console.log('data received')
|
||||||
// location.href = '/profile'
|
// location.href = '/profile'
|
||||||
document.querySelector(".info_profile").innerHTML = data.html
|
document.querySelector(".info_profile").innerHTML = data.html
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,21 @@ function sendRoute(el){
|
|||||||
console.log('data received')
|
console.log('data received')
|
||||||
// location.href = '/profile'
|
// location.href = '/profile'
|
||||||
document.querySelector(".info_profile").innerHTML = data.html
|
document.querySelector(".info_profile").innerHTML = data.html
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function (data, exception){
|
error: function (data, exception){
|
||||||
document.querySelector(".info_profile").innerHTML = data.responseJSON.html
|
document.querySelector(".info_profile").innerHTML = data.responseJSON.html
|
||||||
|
|
||||||
|
$('#id_weight').ionRangeSlider({
|
||||||
|
skin: "round",
|
||||||
|
type: "single",
|
||||||
|
min: 0,
|
||||||
|
max: 1000,
|
||||||
|
from: 500,
|
||||||
|
step: 1,
|
||||||
|
grid: true,
|
||||||
|
grid_num: 5,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<div class="from_to_country">
|
<div class="from_to_country">
|
||||||
<div>
|
<div>
|
||||||
<label for="id_from_country">{{ form.fields.from_country.label }}</label>
|
<label for="id_from_country">{{ form.fields.from_country.label }}</label>
|
||||||
<input type="text" name="from_country"{% if form.fields.from_country.required %} required{% endif %} id="id_from_country">
|
<input oninput="search(this)" type="text" name="from_country"{% if form.fields.from_country.required %} required{% endif %} id="id_from_country">
|
||||||
{% if form.errors and form.errors.from_country %}
|
{% if form.errors and form.errors.from_country %}
|
||||||
<span>{{ form.errors.from_country }}</span>
|
<span>{{ form.errors.from_country }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<section class="register">
|
<section class="register">
|
||||||
<h1>Регистрация</h1>
|
<h1>Регистрация</h1>
|
||||||
|
|
||||||
<form name="registration_form" method="post">
|
<form name="registration_form" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{# <div class="switch">#}
|
{# <div class="switch">#}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<script src='{% static "js/sendRoute.js" %}'></script>
|
<script src='{% static "js/sendRoute.js" %}'></script>
|
||||||
<script src='{% static "js/jquery_v3_6_4.js" %}'> </script>
|
<script src='{% static "js/jquery_v3_6_4.js" %}'> </script>
|
||||||
<script src='{% static "js/ion.rangeSlider.min.js" %}'> </script>
|
<script src='{% static "js/ion.rangeSlider.min.js" %}'> </script>
|
||||||
<script src='{% static "js/autocomplete.js" %}'> </script>
|
<script src='{% static "js/autocomlitev2.js" %}'> </script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="{% static 'css/ion.rangeSlider.min.css' %}">
|
<link rel="stylesheet" href="{% static 'css/ion.rangeSlider.min.css' %}">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user