@4site/engrid-scripts 0.20.2 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/optin-ladder.d.ts +1 -0
- package/dist/optin-ladder.js +28 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/optin-ladder.d.ts
CHANGED
package/dist/optin-ladder.js
CHANGED
|
@@ -27,12 +27,12 @@ export class OptInLadder {
|
|
|
27
27
|
}
|
|
28
28
|
this._form.onSubmit.subscribe(() => {
|
|
29
29
|
// Save the checkbox values to sessionStorage
|
|
30
|
-
this.saveOptInsToSessionStorage();
|
|
30
|
+
this.saveOptInsToSessionStorage("parent");
|
|
31
31
|
});
|
|
32
32
|
this.logger.log("Running as Parent");
|
|
33
33
|
if (ENGrid.getPageNumber() === 1) {
|
|
34
|
-
// Delete
|
|
35
|
-
|
|
34
|
+
// Delete items from sessionStorage
|
|
35
|
+
this.clearSessionStorage();
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
runAsChildRegular() {
|
|
@@ -123,7 +123,7 @@ export class OptInLadder {
|
|
|
123
123
|
this.saveStepToSessionStorage(currentStep, totalSteps);
|
|
124
124
|
// On form submit, save the checkbox values to sessionStorage
|
|
125
125
|
this._form.onSubmit.subscribe(() => {
|
|
126
|
-
this.saveOptInsToSessionStorage();
|
|
126
|
+
this.saveOptInsToSessionStorage("child");
|
|
127
127
|
// Save the current step to sessionStorage
|
|
128
128
|
currentStep++;
|
|
129
129
|
this.saveStepToSessionStorage(currentStep, totalSteps);
|
|
@@ -134,19 +134,25 @@ export class OptInLadder {
|
|
|
134
134
|
this.logger.log("Not Embedded on a Thank You Page");
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
+
const hasOptInLadderStop = sessionStorage.getItem("engrid.optin-ladder-stop");
|
|
138
|
+
if (hasOptInLadderStop) {
|
|
139
|
+
this.logger.log("OptInLadder has been stopped");
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
137
142
|
const sessionStorageOptInLadder = JSON.parse(sessionStorage.getItem("engrid.optin-ladder") || "{}");
|
|
138
143
|
const currentStep = sessionStorageOptInLadder.step || 0;
|
|
139
144
|
const totalSteps = sessionStorageOptInLadder.totalSteps || 0;
|
|
140
|
-
if (currentStep
|
|
141
|
-
this.logger.log(`Current step ${currentStep} is less
|
|
145
|
+
if (currentStep <= totalSteps) {
|
|
146
|
+
this.logger.log(`Current step ${currentStep} is less or equal to total steps ${totalSteps}`);
|
|
147
|
+
this.hidePage();
|
|
142
148
|
// Redirect to the first page
|
|
143
149
|
window.location.href = this.getFirstPageUrl();
|
|
144
150
|
return;
|
|
145
151
|
}
|
|
146
152
|
else {
|
|
147
|
-
this.logger.log(`Current step ${currentStep} is
|
|
153
|
+
this.logger.log(`Current step ${currentStep} is greater than total steps ${totalSteps}`);
|
|
148
154
|
// Remove the session storage
|
|
149
|
-
|
|
155
|
+
this.clearSessionStorage();
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
158
|
inIframe() {
|
|
@@ -169,7 +175,7 @@ export class OptInLadder {
|
|
|
169
175
|
path.push("1");
|
|
170
176
|
return url.origin + path.join("/") + "?chain";
|
|
171
177
|
}
|
|
172
|
-
saveOptInsToSessionStorage() {
|
|
178
|
+
saveOptInsToSessionStorage(type = "parent") {
|
|
173
179
|
// Grab all the checkboxes with the name starting with "supporter.questions"
|
|
174
180
|
const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]');
|
|
175
181
|
if (checkboxes.length === 0) {
|
|
@@ -177,15 +183,23 @@ export class OptInLadder {
|
|
|
177
183
|
return;
|
|
178
184
|
}
|
|
179
185
|
const sessionStorageCheckboxValues = JSON.parse(sessionStorage.getItem("engrid.supporter.questions") || "{}");
|
|
186
|
+
let hasDeny = false;
|
|
180
187
|
// Loop through all the checkboxes and store the value in sessionStorage
|
|
181
188
|
checkboxes.forEach((checkbox) => {
|
|
182
189
|
if (checkbox.checked) {
|
|
183
190
|
const index = checkbox.name.split(".")[2];
|
|
184
191
|
sessionStorageCheckboxValues[index] = "Y";
|
|
185
192
|
}
|
|
193
|
+
else {
|
|
194
|
+
hasDeny = true;
|
|
195
|
+
}
|
|
186
196
|
});
|
|
187
197
|
sessionStorage.setItem("engrid.supporter.questions", JSON.stringify(sessionStorageCheckboxValues));
|
|
188
198
|
this.logger.log(`Saved checkbox values to sessionStorage: ${JSON.stringify(sessionStorageCheckboxValues)}`);
|
|
199
|
+
if (type === "child" && hasDeny) {
|
|
200
|
+
// Add a deny value to the sessionStorage to stop the ladder
|
|
201
|
+
sessionStorage.setItem("engrid.optin-ladder-stop", "Y");
|
|
202
|
+
}
|
|
189
203
|
}
|
|
190
204
|
isEmbeddedThankYouPage() {
|
|
191
205
|
return ENGrid.getBodyData("embedded") === "thank-you-page-donation";
|
|
@@ -196,4 +210,9 @@ export class OptInLadder {
|
|
|
196
210
|
engridPage.classList.add("hide");
|
|
197
211
|
}
|
|
198
212
|
}
|
|
213
|
+
clearSessionStorage() {
|
|
214
|
+
sessionStorage.removeItem("engrid.supporter.questions");
|
|
215
|
+
sessionStorage.removeItem("engrid.optin-ladder");
|
|
216
|
+
sessionStorage.removeItem("engrid.optin-ladder-stop");
|
|
217
|
+
}
|
|
199
218
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.20.
|
|
1
|
+
export declare const AppVersion = "0.20.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.20.
|
|
1
|
+
export const AppVersion = "0.20.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.3",
|
|
4
4
|
"description": "Scripts for the ENGRID Project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"strongly-typed-events": "^2.0.9"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/4site-interactive-studios/engrid#readme",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "42f9f5e6571c882757478c2a5fefd22ea7df799f",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|