@lookit/templates 2.1.0 → 3.1.0
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/index.browser.js +21 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +251 -33
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/consentVideoTemplate.ts +3 -0
- package/src/establishingConnectionTemplate.ts +16 -0
- package/src/index.spec.ts +99 -0
- package/src/index.ts +4 -1
- package/src/utils.ts +7 -0
package/src/index.spec.ts
CHANGED
|
@@ -74,6 +74,89 @@ test("consent garden template", () => {
|
|
|
74
74
|
expect(chsTemplate.consentVideo(trial)).toContain("Project GARDEN");
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
test("consent video with consent-recording-only template", () => {
|
|
78
|
+
const trial = getTrial({ template: "consent-recording-only" });
|
|
79
|
+
const name = "some name";
|
|
80
|
+
window.chs = {
|
|
81
|
+
study: {
|
|
82
|
+
attributes: {
|
|
83
|
+
name,
|
|
84
|
+
duration: "duration",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
} as typeof window.chs;
|
|
88
|
+
|
|
89
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
90
|
+
'<div id="consent-video-trial">',
|
|
91
|
+
);
|
|
92
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
93
|
+
`You and your child will be recorded by your computer's webcam and microphone only while providing verbal consent.`,
|
|
94
|
+
);
|
|
95
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
96
|
+
`This webcam recording and other data collected on the CHS/Lookit website are sent securely to the Lookit platform.`,
|
|
97
|
+
);
|
|
98
|
+
expect(chsTemplate.consentVideo(trial)).not.toContain(
|
|
99
|
+
`You will also have the option to withdraw your recordings. If you do, only your consent recording will be kept and all other recordings will be deleted.`,
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("consent video with consent-recording-only template and only consent on CHS", () => {
|
|
104
|
+
const trial = getTrial({
|
|
105
|
+
template: "consent-recording-only",
|
|
106
|
+
only_consent_on_chs: true,
|
|
107
|
+
});
|
|
108
|
+
const name = "some name";
|
|
109
|
+
window.chs = {
|
|
110
|
+
study: {
|
|
111
|
+
attributes: {
|
|
112
|
+
name,
|
|
113
|
+
duration: "duration",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
} as typeof window.chs;
|
|
117
|
+
|
|
118
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
119
|
+
'<div id="consent-video-trial">',
|
|
120
|
+
);
|
|
121
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
122
|
+
`You and your child will be recorded by your computer's webcam and microphone only while providing verbal consent.`,
|
|
123
|
+
);
|
|
124
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
125
|
+
`This webcam recording is sent securely to the Lookit platform.`,
|
|
126
|
+
);
|
|
127
|
+
expect(chsTemplate.consentVideo(trial)).not.toContain(
|
|
128
|
+
`You will also have the option to withdraw your recordings. If you do, only your consent recording will be kept and all other recordings will be deleted.`,
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("video consent param only_consent_on_chs is ignored when the template is not consent-recording-only", () => {
|
|
133
|
+
const trial = getTrial({
|
|
134
|
+
only_consent_on_chs: true,
|
|
135
|
+
});
|
|
136
|
+
const name = "some name";
|
|
137
|
+
window.chs = {
|
|
138
|
+
study: {
|
|
139
|
+
attributes: {
|
|
140
|
+
name,
|
|
141
|
+
duration: "duration",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
} as typeof window.chs;
|
|
145
|
+
|
|
146
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
147
|
+
'<div id="consent-video-trial">',
|
|
148
|
+
);
|
|
149
|
+
expect(chsTemplate.consentVideo(trial)).not.toContain(
|
|
150
|
+
`You and your child will be recorded by your computer's webcam and microphone only while providing verbal consent.`,
|
|
151
|
+
);
|
|
152
|
+
expect(chsTemplate.consentVideo(trial)).not.toContain(
|
|
153
|
+
`This webcam recording is sent securely to the Lookit platform.`,
|
|
154
|
+
);
|
|
155
|
+
expect(chsTemplate.consentVideo(trial)).toContain(
|
|
156
|
+
`You will also have the option to withdraw your recordings. If you do, only your consent recording will be kept and all other recordings will be deleted.`,
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
77
160
|
test("video config template", () => {
|
|
78
161
|
const trial = getTrial();
|
|
79
162
|
|
|
@@ -127,3 +210,19 @@ test("exit survey template in French", () => {
|
|
|
127
210
|
"Nous vous demandons à nouveau en cas d'erreur lors de l'enregistrement ou de sélection par erreur d'un enfant différent au début de l'étude.",
|
|
128
211
|
);
|
|
129
212
|
});
|
|
213
|
+
|
|
214
|
+
test("estabilshing connection template", () => {
|
|
215
|
+
const trial = getTrial();
|
|
216
|
+
|
|
217
|
+
expect(chsTemplate.establishingConnection(trial)).toContain(
|
|
218
|
+
"<div>establishing video connection, please wait...</div>",
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("establishing connection template in French", () => {
|
|
223
|
+
const trial = getTrial({ locale: "fr" });
|
|
224
|
+
|
|
225
|
+
expect(chsTemplate.establishingConnection(trial)).toContain(
|
|
226
|
+
"<div>en attente de connection video, veuillez attendre...</div>",
|
|
227
|
+
);
|
|
228
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { consentVideo } from "./consentVideoTemplate";
|
|
2
|
+
import { establishingConnection } from "./establishingConnectionTemplate";
|
|
2
3
|
import { exitSurvey } from "./exitSurveyTemplate";
|
|
3
4
|
import { uploadingVideo } from "./uploadingVideoTemplate";
|
|
4
|
-
import { translateString } from "./utils";
|
|
5
|
+
import { loadingAnimation, translateString } from "./utils";
|
|
5
6
|
import { videoConfig } from "./videoConfigTemplate";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
@@ -10,4 +11,6 @@ export default {
|
|
|
10
11
|
uploadingVideo,
|
|
11
12
|
exitSurvey,
|
|
12
13
|
translateString,
|
|
14
|
+
establishingConnection,
|
|
15
|
+
loadingAnimation,
|
|
13
16
|
};
|
package/src/utils.ts
CHANGED
|
@@ -3,6 +3,7 @@ import i18next from "i18next";
|
|
|
3
3
|
import ICU from "i18next-icu";
|
|
4
4
|
import Yaml from "js-yaml";
|
|
5
5
|
import { PluginInfo, TrialType } from "jspsych";
|
|
6
|
+
import loaderPartial from "../hbs/partials/loader.hbs";
|
|
6
7
|
import en_us from "../i18n/en-us.yaml";
|
|
7
8
|
import eu from "../i18n/eu.yaml";
|
|
8
9
|
import fr from "../i18n/fr.yaml";
|
|
@@ -93,6 +94,9 @@ Handlebars.registerHelper("t", (context, { hash }) => {
|
|
|
93
94
|
return hash.htmlSafe ? new Handlebars.SafeString(txt) : txt;
|
|
94
95
|
});
|
|
95
96
|
|
|
97
|
+
// Register Handlebars partials
|
|
98
|
+
Handlebars.registerPartial("loader", loaderPartial);
|
|
99
|
+
|
|
96
100
|
/**
|
|
97
101
|
* Public method for directly translating a string, without a corresponding
|
|
98
102
|
* template.
|
|
@@ -104,3 +108,6 @@ Handlebars.registerHelper("t", (context, { hash }) => {
|
|
|
104
108
|
export const translateString = (messageIdStr: string) => {
|
|
105
109
|
return i18next.t(messageIdStr);
|
|
106
110
|
};
|
|
111
|
+
|
|
112
|
+
// This just renders the animation from the loader partial template. No parameters, so just export it here.
|
|
113
|
+
export const loadingAnimation = Handlebars.compile(loaderPartial);
|