-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
229 lines (200 loc) · 7.09 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Transcend Consent Manager Playground</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- <link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css" /> -->
<style type="text/css">
body {
display: grid;
place-items: center;
height: 100vh;
}
#load-options ul,
#presets ul {
list-style: none;
padding-left: 0;
margin-top: 0;
}
#load-options label {
padding-left: 4px;
}
#policy-content img {
max-width: 100%;
height: auto;
}
img:not([src]):not([srcset])::after,
img[src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]::after
{
content: '[image blocked]';
color: crimson;
font-weight: bold;
}
:not(img):-moz-broken::after {
content: '[resource blocked]';
color: crimson;
font-weight: bold;
}
.innerHtmlTest {
color: red;
}
</style>
<script
data-cfasync="false"
data-ui="http://localhost:8080/build/ui.js"
data-messages="http://localhost:8080/build/translations"
data-css="http://localhost:8080/src/cm.css"
data-secondary-policy="http://transcend.io/test"
src="https://cdn.transcend.io/cm/443312ef-12f9-494d-85f5-969894260cc7/airgap.js"
onload="window.airgapScriptLoadEvent=event;"
data-regime="GDPR"
></script>
<!-- <script
data-cfasync="false"
data-languages="en,es-ES,fr-FR"
src="https://cdn.transcend.io/cm/443312ef-12f9-494d-85f5-969894260cc7/airgap.js"
></script> -->
</head>
<body style="height: 100%">
<h1>Transcend Consent Manager Playground!</h1>
<button id="cpra_button" style="display: none">
<img src="./privacy-choices-icon.svg" />
<span>Your Privacy Choices</span>
</button>
<script>
if (airgap && airgap.getRegimes().has('CPRA')) {
var cpraButton = document.getElementById('cpra_button');
cpraButton.onclick = function () {
transcend.showConsentManager({ viewState: 'AcceptOrRejectAll' });
};
cpraButton.style.display = 'block';
}
</script>
<h2>Do Not Sell/Share</h2>
<br />
<button id="do-not-sell">Do Not Sell My Personal Information</button>
<button id="opt-out-all">Opt Out of All Purposes</button>
<button id="do-not-sell-reset">Reset</button>
<hr />
<h2>View States</h2>
<p id="data"></p>
<h2>Policy Content</h2>
<div style="max-width: 600px">
<div id="policy-content" style="max-width: 100%"></div>
</div>
<br />
<script>
var handleDoNotSell = (event) => {
transcend.doNotSell(event);
};
var handleOptOutOfAll = (event) => {
transcend.optOutNotice(event);
};
var resetDoNotSell = (event) => {
airgap.setConsent(
event,
{ SaleOfInfo: true },
{ confirmed: false, prompted: false },
);
setupDoNotSellButton();
};
// Setup do not sell
var setupDoNotSellButton = () => {
// get button elements
let doNotSellDoc = document.getElementById('do-not-sell');
let optOutDoc = document.getElementById('opt-out-all');
let doNotSellDocReset = document.getElementById('do-not-sell-reset');
// handle opt out of all
optOutDoc.addEventListener('click', handleOptOutOfAll);
// reset state
doNotSellDocReset.addEventListener('click', resetDoNotSell);
// check if opted in or out of sale
let isOptedOut = !airgap.getConsent().purposes.SaleOfInfo;
// change text if opted out
if (isOptedOut) {
doNotSellDoc.innerHTML =
'We No Longer Sell Your Personal Information';
doNotSellDoc.removeEventListener('click', handleDoNotSell);
} else {
doNotSellDoc.innerHTML = 'Do Not Sell My Personal Information';
// Add on click event if user is opted in
doNotSellDoc.addEventListener('click', handleDoNotSell);
}
};
// Setup buttons for each view state
let doc = document.getElementById('data');
// callback on change of view state
var setViewState = (viewState) => {
transcend.showConsentManager(viewState);
setupDoNotSellButton();
};
// Add button for default view state
doc.innerHTML += `<button onClick="transcend.showConsentManager()">Default</button><br/><br/>`;
// callback on change of view state
var fetchBackendConsent = (userId) => {
console.log(`Mocking call to backend to fetch user ID ${userId}`);
return Promise.resolve({
SaleOfInfo: false,
});
};
/**
* Dynamically change out policy content based on language
*/
async function setPolicyContent(language) {
if (language) {
await transcend.setActiveLocale(language);
}
const [policy] = await transcend.getPolicies({
policyTitles: ['Label Privacy Policy'],
// variables: { labelName: 'Marshmalt Records' },
locale: language || transcend.getActiveLocale(),
});
document.getElementById('policy-content').innerHTML = policy.content;
}
// Prepare document on ready
transcend.ready(() => {
// Add buttons for view states
transcend.viewStates.forEach((viewState) => {
doc.innerHTML += `<button onClick="setViewState({ viewState: '${viewState}' })">${viewState}</button><br/><br/>`;
});
// re-render the button on consent change
airgap.addEventListener('consent-change', (...args) => {
setupDoNotSellButton();
});
// this script will blur the screen while a consent banner is showing
/*transcend.addEventListener(
'view-state-change',
({ detail: { viewState, previousViewState } }) => {
let closedViewStates = ['Hidden', 'Closed', 'Collapsed'];
let cm = document.getElementById('transcend-consent-manager');
if (closedViewStates.includes(viewState)) {
cm.style.inset = '';
cm.style.pointerEvents = '';
cm.style.backgroundColor = '';
} else {
cm.style.inset = '0';
cm.style.pointerEvents = 'all';
cm.style.backgroundColor = 'rgba(0,0,0,0.5)';
cm.dataset.shown = 'shown';
}
},
);*/
// setup the do not sell button
setupDoNotSellButton();
transcend
.setUiVariables({
labelName: 'Marshmalt Records',
})
.then(() => {
setPolicyContent();
});
// resolve consent from backend
// uncomment to test backend consent mocked integration
// fetchBackendConsent(1234).then((consent) =>
// airgap.setConsent(window.airgapScriptLoadEvent, consent),
// );
});
</script>
</body>
</html>