File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed
static/examples/cstg-prebid-example Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change 1818 function updateGuiElements ( ) {
1919 console . log ( 'Updating displayed values.' ) ;
2020 const uid2 = pbjs . getUserIds ( ) . uid2 ;
21+
22+ let isOptedOut = false ;
23+ const storedToken = localStorage . getItem ( '__uid2_advertising_token' ) ;
24+ if ( storedToken ) {
25+ try {
26+ const tokenData = JSON . parse ( storedToken ) ;
27+ isOptedOut = tokenData . latestToken === 'optout' ;
28+ } catch ( e ) {
29+ console . log ( 'Could not parse stored token' ) ;
30+ }
31+ }
32+
2133 $ ( '#targeted_advertising_ready' ) . text ( uid2 ? 'yes' : 'no' ) ;
22- $ ( '#advertising_token' ) . text ( uid2 ? String ( uid2 . id ) : '' ) ;
23- if ( ! uid2 ) {
24- $ ( '#login_form' ) . show ( ) ;
25- $ ( '#clear_storage_form' ) . hide ( ) ;
26- } else {
34+
35+ if ( isOptedOut ) {
36+ $ ( '#advertising_token' ) . text ( 'This email has opted out.' ) ;
2737 $ ( '#login_form' ) . hide ( ) ;
2838 $ ( '#clear_storage_form' ) . show ( ) ;
39+ } else {
40+ $ ( '#advertising_token' ) . text ( uid2 ? String ( uid2 . id ) : '' ) ;
41+ if ( ! uid2 ) {
42+ $ ( '#login_form' ) . show ( ) ;
43+ $ ( '#clear_storage_form' ) . hide ( ) ;
44+ } else {
45+ $ ( '#login_form' ) . hide ( ) ;
46+ $ ( '#clear_storage_form' ) . show ( ) ;
47+ }
2948 }
3049 }
3150
You can’t perform that action at this time.
0 commit comments