0.0.22 autocomlitev2.js
This commit is contained in:
@@ -3,6 +3,6 @@ django-ckeditor==6.5.1
|
||||
psycopg2-binary==2.9.6
|
||||
requests
|
||||
Pillow
|
||||
django-modeltranslation=0.18.10
|
||||
django-modeltranslation
|
||||
overpass
|
||||
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){
|
||||
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({
|
||||
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
||||
url: '/ru/routes/create_route/',
|
||||
url: '/reference_data/get_address_point/',
|
||||
type: "POST",
|
||||
// async: true,
|
||||
cache: false,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
// enctype: 'json',
|
||||
data: formData,
|
||||
data: get_address_point,
|
||||
success: function(data){
|
||||
console.log('data received')
|
||||
// location.href = '/profile'
|
||||
document.querySelector(".info_profile").innerHTML = data.html
|
||||
return data;
|
||||
},
|
||||
error: function (data, exception){
|
||||
document.querySelector(".button_register").innerHTML = data.responseJSON.html
|
||||
error: function (data){
|
||||
console.log('++')
|
||||
// document.querySelector(".button_register").innerHTML = data.responseJSON.html
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -45,7 +47,7 @@ var ac = $('#id_from_country')
|
||||
.on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
})
|
||||
.on('focus keyup', search)
|
||||
.on('keyup', search)
|
||||
.on('keydown', onKeyDown);
|
||||
|
||||
var wrap = $('<div>')
|
||||
@@ -93,13 +95,15 @@ function search(e) {
|
||||
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);
|
||||
// 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 +'">'
|
||||
+ '<div><b>'+ r.iata +'</b> - '+ r.name +'</div>'
|
||||
+ '<div class="autocomplete-location">'+ r.city +', '+ r.country +'</div>'
|
||||
|
||||
@@ -11,7 +11,7 @@ function createRoute(){
|
||||
// enctype: 'json',
|
||||
// data: {},
|
||||
success: function(data){
|
||||
console.log('data received')
|
||||
// console.log('data received')
|
||||
// location.href = '/profile'
|
||||
document.querySelector(".info_profile").innerHTML = data.html
|
||||
|
||||
|
||||
@@ -17,9 +17,21 @@ function sendRoute(el){
|
||||
console.log('data received')
|
||||
// location.href = '/profile'
|
||||
document.querySelector(".info_profile").innerHTML = data.html
|
||||
|
||||
},
|
||||
error: function (data, exception){
|
||||
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>
|
||||
<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 %}
|
||||
<span>{{ form.errors.from_country }}</span>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<section class="register">
|
||||
<h1>Регистрация</h1>
|
||||
|
||||
<form name="registration_form" method="post">
|
||||
<form name="registration_form" method="POST">
|
||||
{% csrf_token %}
|
||||
|
||||
{# <div class="switch">#}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<script src='{% static "js/sendRoute.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/autocomplete.js" %}'> </script>
|
||||
<script src='{% static "js/autocomlitev2.js" %}'> </script>
|
||||
|
||||
<link rel="stylesheet" href="{% static 'css/ion.rangeSlider.min.css' %}">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user