diff --git a/static/js/user_profile.js b/static/js/user_profile.js index a9e4172..aec893b 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -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 } diff --git a/static/js/user_profile_2.js b/static/js/user_profile_2.js index 2292685..d2fdc96 100644 --- a/static/js/user_profile_2.js +++ b/static/js/user_profile_2.js @@ -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() }, diff --git a/templates/blocks/b_user_profile.html b/templates/blocks/b_user_profile.html index b2acc72..b16b0bc 100644 --- a/templates/blocks/b_user_profile.html +++ b/templates/blocks/b_user_profile.html @@ -11,7 +11,7 @@