From e2ff4baef50c247fb71d76dcc16f3b878f3e9e8f Mon Sep 17 00:00:00 2001 From: ArtemB Date: Wed, 9 Aug 2023 15:55:52 +0300 Subject: [PATCH] 0.0.78 update scrip for menu_user_profile --- static/js/user_profile.js | 59 +++++++++++++++++++--------- templates/blocks/b_user_profile.html | 14 +++---- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/static/js/user_profile.js b/static/js/user_profile.js index 6c63705..2406e23 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -1,4 +1,4 @@ -function writeMessage(){ +function writeMessage(el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, url: '/ru/user_account/chats/', @@ -14,6 +14,9 @@ function writeMessage(){ // 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') }, error: function (data, exception){ @@ -24,7 +27,7 @@ function writeMessage(){ } -function technicalSupport(){ +function technicalSupport(el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, url: '/ru/user_account/support_tickets/', @@ -41,6 +44,10 @@ function technicalSupport(){ // 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') + }, error: function (data, exception){ @@ -49,7 +56,7 @@ function technicalSupport(){ } }); } -function mySubscription(){ +function mySubscription(el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, url: '/ru/user_account/subscribe/', @@ -66,6 +73,10 @@ function mySubscription(){ // 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') + }, error: function (data, exception){ @@ -74,7 +85,7 @@ function mySubscription(){ } }); } -function myProfile(){ +function myProfile(el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, url: '/ru/user_account/change_profile/', @@ -91,6 +102,10 @@ function myProfile(){ // 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') + }, error: function (data, exception){ @@ -100,18 +115,18 @@ function myProfile(){ }); } -function selectMenuItem() { - let list_div = document.querySelectorAll('.menu_profile div'); - - list_div.forEach(item =>{ - item.addEventListener('click', (e) =>{ - list_div.forEach(el=>{ el.classList.remove('selected'); }); - item.classList.add('selected') - }) - }) - - -} +// function selectMenuItem() { +// let list_div = document.querySelectorAll('.menu_profile div'); +// +// list_div.forEach(item =>{ +// item.addEventListener('click', (e) =>{ +// list_div.forEach(el=>{ el.classList.remove('selected'); }); +// item.classList.add('selected') +// }) +// }) +// +// +// } @@ -376,7 +391,7 @@ function OnSelectionChange(el) { -function createRoute(){ +function createRoute(el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, @@ -394,6 +409,10 @@ function createRoute(){ // 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') + //get dynamic value @@ -413,7 +432,7 @@ function createRoute(){ }); } -function getRoute(){ +function getRoute(el){ $.ajax({ headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, url: '/ru/routes/get_routes/', @@ -430,6 +449,10 @@ function getRoute(){ // 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') + }, error: function (data, exception){ diff --git a/templates/blocks/b_user_profile.html b/templates/blocks/b_user_profile.html index a831459..d2dbdf8 100644 --- a/templates/blocks/b_user_profile.html +++ b/templates/blocks/b_user_profile.html @@ -1,33 +1,33 @@
{% csrf_token %}