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){
$.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 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');
@@ -586,94 +586,96 @@ function OnSelectionChange(el) {
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)
// 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)
//
// }
// });
// }
},
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) {
// 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
}

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 () {
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },

View File

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

View File

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