@@ -70,15 +70,14 @@ function checkUserConsent() {
7070 mixpanel . opt_out_tracking ( ) ;
7171 // disable google analytics
7272 window [ "ga-disable-UA-139926191-1" ] = true ;
73- showOptOutSettings ( ) ;
7473 } else {
7574 // enable mixpanel tracking
7675 mixpanel . opt_in_tracking ( ) ;
7776 // enable google analytics
7877 window [ "ga-disable-UA-139926191-1" ] = false ;
7978 // show settings
80- showOptInSettings ( ) ;
8179 }
80+ showConsentSettings ( ) ;
8281 }
8382}
8483
@@ -95,36 +94,31 @@ function hideConsentBanner() {
9594function setConsentTrue ( ) {
9695 localStorage . setItem ( "user_consent" , "true" ) ;
9796 hideConsentBanner ( ) ;
98- showOptInSettings ( ) ;
97+ showConsentSettings ( ) ;
9998}
10099
101100function setConsentFalse ( ) {
102101 localStorage . setItem ( "user_consent" , "false" ) ;
103102 hideConsentBanner ( ) ;
104- showOptOutSettings ( ) ;
103+ showConsentSettings ( ) ;
105104}
106105
107- function showOptInSettings ( ) {
106+ function showConsentSettings ( ) {
108107 showTrackingSettings ( ) ;
108+ let user_consent = localStorage . getItem ( "user_consent" ) ;
109+ user_consent = JSON . parse ( user_consent ) ;
110+
109111 let opt_in_settings = document . getElementById ( "consent-settings-opt-in" ) ;
110- if ( opt_in_settings != null ) {
111- opt_in_settings . style . display = "block" ;
112- }
113112 let opt_out_settings = document . getElementById ( "consent-settings-opt-out" ) ;
114- if ( opt_out_settings != null ) {
113+ if ( user_consent === true ) {
114+ opt_in_settings . style . display = "block" ;
115115 opt_out_settings . style . display = "none" ;
116- }
117- }
118-
119- function showOptOutSettings ( ) {
120- showTrackingSettings ( ) ;
121- let opt_in_settings = document . getElementById ( "consent-settings-opt-in" ) ;
122- if ( opt_in_settings != null ) {
116+ } else if ( user_consent === false ) {
123117 opt_in_settings . style . display = "none" ;
124- }
125- let opt_out_settings = document . getElementById ( "consent-settings-opt-out" ) ;
126- if ( opt_out_settings != null ) {
127118 opt_out_settings . style . display = "block" ;
119+ } else {
120+ opt_in_settings . style . display = "none" ;
121+ opt_out_settings . style . display = "none" ;
128122 }
129123}
130124
0 commit comments