7
7
we treat your data with the utmost care and are transparent about how we handle it.
8
8
You can add accept the treatment of your data by clicking on the Accept button, reject it or learn more about it.
9
9
</ p >
10
- < button onclick ="acceptAllData() " type ="button " class ="btn btn-outline- success "> Accept</ button >
11
- < button onclick ="acceptLocalStorage(false) " type ="button " class ="btn btn-outline- danger "> Reject</ button >
12
- < button type ="button " class ="btn btn-outline-secondary " data-toggle ="modal " data-target ="#labelstoreModal "> Learn more</ button >
10
+ < button onclick ="acceptAllData() " type ="button " class ="btn btn-success "> Accept</ button >
11
+ < button onclick ="acceptLocalStorage(false) " type ="button " class ="btn btn-danger "> Reject</ button >
12
+ < button type ="button " class ="btn btn-info " data-toggle ="modal " data-target ="#labelstoreModal "> Learn more</ button >
13
13
</ div >
14
14
</ div >
15
15
< div class ="modal fade " id ="labelstoreModal " tabindex ="-1 " role ="dialog ">
16
16
< div class ="modal-dialog " role ="document ">
17
17
< div class ="modal-content ">
18
18
< form id ="labelstore-form ">
19
19
< div class ="modal-header ">
20
- < h4 class ="modal-title " id =" myModalLabel " > Modal title</ h4 >
21
- < button id =" close-storage-modal " type ="button " class ="close " data-dismiss ="modal " aria-label ="Close "> < span aria-hidden ="true "> ×</ span > </ button >
20
+ < h4 class ="modal-title "> Modal title</ h4 >
21
+ < button type ="button " class ="close " data-dismiss ="modal " aria-label ="Close "> < span aria-hidden ="true "> ×</ span > </ button >
22
22
</ div >
23
23
< div class ="modal-body text-center ">
24
24
To improve your experience on our site, we would like to store certain data in your
@@ -33,12 +33,65 @@ <h4 class="modal-title" id="myModalLabel">Modal title</h4>
33
33
</ div >
34
34
</ div >
35
35
< div class ="modal-footer ">
36
- < button type ="submit " class ="btn btn-outline-secondary "> Accept Selected</ button >
37
- < button onclick ="acceptAllData() " data-dismiss ="modal " type ="button " class ="btn btn-outline- success "> Accept All</ button >
38
- < button onclick ="acceptLocalStorage(false) " data-dismiss ="modal " type ="button " class ="btn btn-outline- danger "> Reject All</ button >
36
+ < button type ="submit " class ="btn btn-info "> Accept Selected</ button >
37
+ < button onclick ="acceptAllData() " data-dismiss ="modal " type ="button " class ="btn btn-success "> Accept All</ button >
38
+ < button onclick ="acceptLocalStorage(false) " data-dismiss ="modal " type ="button " class ="btn btn-danger "> Reject All</ button >
39
39
</ div >
40
40
</ form >
41
41
</ div >
42
42
</ div >
43
43
</ div >
44
- < script type ="text/javascript " src ="scripts/localStorage.js "> </ script >
44
+ < script type ="text/javascript " src ="scripts/localStorage.js ">
45
+ const acceptFromSelection = ( e ) => {
46
+ e . preventDefault ( )
47
+
48
+ acceptData (
49
+ Object . entries (
50
+ Object . fromEntries ( new FormData ( e . target ) ) // retireve the form data
51
+ ) . filter ( ( [ _ , value ] ) => value === "on" ) . map ( ( [ key , _ ] ) => key ) // only keep ticked checkboxes
52
+ )
53
+
54
+ $ ( "#labelstoreModal" ) . modal ( 'hide' )
55
+ return false
56
+ }
57
+
58
+ /// popup setup
59
+ const popup = document . getElementById ( "localStorage-ask" )
60
+ document . getElementById ( "labelstore-form" ) ?. addEventListener ( "submit" , acceptFromSelection )
61
+
62
+ // v question unanswered
63
+ if ( isLocalStorageAvailable ( ) && sessionStorage . getItem ( "acceptLocalStorage" ) === null ) {
64
+ if ( popup ) popup . style . visibility = "visible" ;
65
+
66
+ const consentList = document . getElementById ( 'consent-inputs' )
67
+
68
+ Object . entries ( LocalStorageDataConsent ) . forEach ( ( [ key , value ] ) => {
69
+ consentList . appendChild (
70
+ document . createElement ( "hr" )
71
+ )
72
+ const input = document . createElement ( "input" ) ;
73
+ Object . entries ( {
74
+ class : "form-check-input" ,
75
+ type : "checkbox" ,
76
+ role : "switch" ,
77
+ style : "margin: 5px;" ,
78
+ id : key ,
79
+ name : key ,
80
+ checked : "true" ,
81
+ } ) . forEach ( ( [ key , value ] ) => input . setAttribute ( key , value ) )
82
+
83
+ consentList . appendChild ( input )
84
+
85
+ const label = document . createElement ( "label" )
86
+ Object . entries ( {
87
+ class : "form-check-label" ,
88
+ for : key ,
89
+ } ) . forEach ( ( [ key , value ] ) => input . setAttribute ( key , value ) )
90
+
91
+ label . textContent = value
92
+ consentList . appendChild ( label )
93
+ } )
94
+ } else {
95
+ if ( popup ) popup . style . display = "none" ;
96
+ }
97
+ </ script >
0 commit comments