This commit is contained in:
2023-10-27 17:19:40 +03:00
parent 02f7edade5
commit b8c282f95f
4 changed files with 281 additions and 226 deletions

View File

@@ -1,135 +1,135 @@
function writeMessage(el){ // function writeMessage(el){
$.ajax({ // $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/user_account/chats/', // url: '/user_account/chats/',
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: formData,
success: function(data){ // success: function(data){
//
// location.href = '/profile' // // location.href = '/profile'
document.querySelector(".info_profile").innerHTML = data.html; // document.querySelector(".info_profile").innerHTML = data.html;
//
let list_div = document.querySelectorAll('.menu_profile div'); // let list_div = document.querySelectorAll('.menu_profile div');
list_div.forEach(el=>{ el.classList.remove('selected'); }); // list_div.forEach(el=>{ el.classList.remove('selected'); });
el.classList.add('selected') // el.classList.add('selected')
let body = document.querySelector("body") // let body = document.querySelector("body")
body.style.overflow = "hidden" // body.style.overflow = "hidden"
//updating the url without reloading // //updating the url without reloading
window.history.pushState(null, null, '/ru/profile/page/chat/') // window.history.pushState(null, null, '/ru/profile/page/chat/')
middleWareJS() // middleWareJS()
//
}, // },
error: function (data, exception){ // error: function (data, exception){
console.log(400) // console.log(400)
//
} // }
}); // });
} // }
//
//
function technicalSupport(el){ // function technicalSupport(el){
$.ajax({ // $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/user_account/support_tickets/', // url: '/user_account/support_tickets/',
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: formData,
success: function(data){ // success: function(data){
//
//
// location.href = '/profile' // // location.href = '/profile'
document.querySelector(".info_profile").innerHTML = data.html; // document.querySelector(".info_profile").innerHTML = data.html;
//
let list_div = document.querySelectorAll('.menu_profile div'); // let list_div = document.querySelectorAll('.menu_profile div');
list_div.forEach(el=>{ el.classList.remove('selected'); }); // list_div.forEach(el=>{ el.classList.remove('selected'); });
el.classList.add('selected') // el.classList.add('selected')
//
//updating the url without reloading // //updating the url without reloading
window.history.pushState(null, null, '/ru/profile/page/support/') // window.history.pushState(null, null, '/ru/profile/page/support/')
middleWareJS() // middleWareJS()
//
}, // },
error: function (data, exception){ // error: function (data, exception){
console.log(400) // console.log(400)
//
} // }
}); // });
} // }
function mySubscription(el){ // function mySubscription(el){
// boris changed // // boris changed
$.ajax({ // $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/subscribes/show_cur_subscribe/', // url: '/subscribes/show_cur_subscribe/',
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: formData,
success: function(data){ // success: function(data){
//
document.querySelector(".info_profile").innerHTML = data.html; // document.querySelector(".info_profile").innerHTML = data.html;
//
// location.href = '/profile' // // location.href = '/profile'
// document.querySelector(".info_profile").innerHTML = data.html; // // document.querySelector(".info_profile").innerHTML = data.html;
//
let list_div = document.querySelectorAll('.menu_profile div'); // let list_div = document.querySelectorAll('.menu_profile div');
list_div.forEach(el=>{ el.classList.remove('selected'); }); // list_div.forEach(el=>{ el.classList.remove('selected'); });
el.classList.add('selected') // el.classList.add('selected')
//
//updating the url without reloading // //updating the url without reloading
window.history.pushState(null, null, '/ru/profile/page/my_subscribe/') // window.history.pushState(null, null, '/ru/profile/page/my_subscribe/')
middleWareJS() // middleWareJS()
//
}, // },
error: function (data, exception){ // error: function (data, exception){
console.log(400) // console.log(400)
//
} // }
}); // });
} // }
function myProfile(el){ // function myProfile(el){
$.ajax({ // $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/user_account/change_profile/', // url: '/user_account/change_profile/',
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: formData,
success: function(data){ // success: function(data){
//
//
// location.href = '/profile' // // location.href = '/profile'
document.querySelector(".info_profile").innerHTML = data.html; // document.querySelector(".info_profile").innerHTML = data.html;
//
let list_div = document.querySelectorAll('.menu_profile div'); // let list_div = document.querySelectorAll('.menu_profile div');
list_div.forEach(el=>{ el.classList.remove('selected'); }); // list_div.forEach(el=>{ el.classList.remove('selected'); });
el.classList.add('selected') // el.classList.add('selected')
//
//updating the url without reloading // //updating the url without reloading
window.history.pushState(null, null, '/ru/profile/page/change_profile/') // window.history.pushState(null, null, '/ru/profile/page/change_profile/')
middleWareJS() // middleWareJS()
//
}, // },
error: function (data, exception){ // error: function (data, exception){
console.log(400) // console.log(400)
//
} // }
}); // });
} // }
// function selectMenuItem() { // function selectMenuItem() {
// let list_div = document.querySelectorAll('.menu_profile div'); // let list_div = document.querySelectorAll('.menu_profile div');
@@ -586,94 +586,96 @@ function OnSelectionChange(el) {
function createRoute(el, owner_type){ // function createRoute(el, owner_type){
let obj = { // let obj = {
'owner_type': owner_type // '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)
// //
// }; // $.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({
error: function (data, exception){ // headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
console.log(101) // url: '/routes/get_routes/',
// type: "POST",
} // // async: true,
}); // cache: false,
} // processData: false,
// contentType: false,
function getRoute(el){ // // enctype: 'json',
$.ajax({ // // data: formData,
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, // success: function(data){
url: '/routes/get_routes/', //
type: "POST", //
// async: true, // // location.href = '/profile'
cache: false, // document.querySelector(".info_profile").innerHTML = data.html;
processData: false, //
contentType: false, // let list_div = document.querySelectorAll('.menu_profile div');
// enctype: 'json', // list_div.forEach(el=>{ el.classList.remove('selected'); });
// data: formData, // el.classList.add('selected')
success: function(data){ //
// window.history.pushState(null, null, '/ru/profile/page/my_routes/')
//
// location.href = '/profile' // middleWareJS()
document.querySelector(".info_profile").innerHTML = data.html; //
// },
let list_div = document.querySelectorAll('.menu_profile div'); // error: function (data, exception){
list_div.forEach(el=>{ el.classList.remove('selected'); }); // console.log(101)
el.classList.add('selected') //
// }
window.history.pushState(null, null, '/ru/profile/page/my_routes/') // });
// }
middleWareJS() // ЛОСЬ ДЫРЯВЫЙ
function editRoute(id) {
},
error: function (data, exception){
console.log(101)
}
});
}function editRoute(id) {
let route_obj = { let route_obj = {
'route_id': id 'route_id': id
} }

View File

@@ -1,5 +1,58 @@
profile_tabs_f_static_map = new Map([
['chats','chat'],
['support_tickets','support'],
['show_cur_subscribe','my_subscribe'],
['change_profile','change_profile'],
['new_route_view_customer','create_route_for_customer'],
['new_route_view_mover','create_route_for_mover']
])
function select_tab_profile (el,url,owner_type=null) {
let data = {}
let confirm_url = `/user_account/${url}/`
if (url.includes('subscribe')){
confirm_url = `/subscribes/${url}/`
} else if (url.includes('new_route')){
data = {
'owner_type': owner_type
}
} else if (url.includes('get_routes')){
confirm_url = `/routes/${url}/`
}
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: confirm_url,
type: "POST",
// async: true,
cache: false,
processData: false,
contentType: false,
// enctype: 'json',
data: JSON.stringify(data),
success: function(data){
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"
if (owner_type){
window.history.pushState(null, null, `/${document.documentElement.lang}/profile/page/${profile_tabs_f_static_map.get(`${url}_${owner_type}`)}/`)
} else {
window.history.pushState(null, null, `/${document.documentElement.lang}/profile/page/${profile_tabs_f_static_map.get(url)}/`)
}
middleWareJS()
},
error: function (data){
console.log(data)
}
});
}
function createTicketShow () { function createTicketShow () {
$.ajax({ $.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },

View File

@@ -11,7 +11,7 @@
</div> </div>
<div <div
id="customer" id="customer"
onclick="createRoute(this)" onclick="select_tab_profile(this,'new_route_view','customer')"
{% if page_name == 'create_route_for_customer' %} {% if page_name == 'create_route_for_customer' %}
class="selected" class="selected"
{% endif %} > {% endif %} >
@@ -20,7 +20,7 @@
</div> </div>
<div <div
id="mover" id="mover"
onclick="createRoute(this)" onclick="select_tab_profile(this,'new_route_view','mover')"
{% if page_name == 'create_route_for_mover' %} {% if page_name == 'create_route_for_mover' %}
class="selected" class="selected"
{% endif %}> {% endif %}>
@@ -29,7 +29,7 @@
</div> </div>
<div <div
id="my_routes_id" id="my_routes_id"
onclick="getRoute(this)" onclick="select_tab_profile(this,'get_routes')"
{% if page_name == 'my_routes' %} {% if page_name == 'my_routes' %}
class="selected" class="selected"
{% endif %}> {% endif %}>
@@ -37,7 +37,7 @@
<a href="#">Мои объявления</a> <a href="#">Мои объявления</a>
</div> </div>
<div <div
onclick="writeMessage(this)" onclick="select_tab_profile(this,'chats')"
{% if page_name == 'chat' %} {% if page_name == 'chat' %}
class="selected" class="selected"
{% endif %}> {% endif %}>
@@ -51,7 +51,7 @@
</a> </a>
</div> </div>
<div <div
onclick="technicalSupport(this)" onclick="select_tab_profile(this,'support_tickets')"
{% if page_name == 'support' %} {% if page_name == 'support' %}
class="selected" class="selected"
{% endif %}> {% endif %}>
@@ -59,7 +59,7 @@
<a href="#">Тех. поддержка</a> <a href="#">Тех. поддержка</a>
</div> </div>
<div <div
onclick="mySubscription(this)" onclick="select_tab_profile(this,'show_cur_subscribe')"
{% if page_name == 'my_subscribe' %} {% if page_name == 'my_subscribe' %}
class="selected" class="selected"
{% endif %}> {% endif %}>
@@ -67,7 +67,7 @@
<a href="#">Моя подписка</a> <a href="#">Моя подписка</a>
</div> </div>
<div <div
onclick="myProfile(this)" onclick="select_tab_profile(this,'change_profile')"
{% if page_name == 'change_profile' %} {% if page_name == 'change_profile' %}
class="selected" class="selected"
{% endif %}> {% endif %}>

View File

@@ -2,7 +2,7 @@
{% load tt_chat %} {% load tt_chat %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="{{ request.LANGUAGE_CODE }}">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=100%,maximum-scale=5,minimum-scale=1,initial-scale=1"> <meta name="viewport" content="width=100%,maximum-scale=5,minimum-scale=1,initial-scale=1">