-
Notifications
You must be signed in to change notification settings - Fork 11
/
common.js
111 lines (99 loc) · 5.44 KB
/
common.js
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
import { moduleParams } from "./questionnaire.js";
export const translate = (key, replacements = []) => {
let translation = moduleParams.i18n[key];
replacements.forEach((value, index) => {
translation = translation.replace(new RegExp(`\\{${index}\\}`, 'g'), value);
});
return translation;
}
export const responseRequestedModal = () => {
return `
<div class="modal" id="softModal" tabindex="-1" role="dialog" aria-labelledby="softModalTitle" aria-modal="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="softModalTitle" tabindex="-1">${translate('responseRequestedLabel')}</h5>
<button type="button" class="close" data-dismiss="modal" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div id="modalBody" class="modal-body" aria-describedby="modalBodyText">
<p id="modalBodyText"></p>
</div>
<div id="softModalFooter" class="modal-footer">
<button type="button" id=modalContinueButton class="btn btn-light" data-dismiss="modal" data-bs-dismiss="modal">${translate('continueWithoutAnsweringButton')}</button>
<button type="button" id=modalCloseButton class="btn btn-light" data-dismiss="modal" data-bs-dismiss="modal">${translate('answerQuestionButton')}</button>
</div>
</div>
</div>
</div>
`;
}
export const responseRequiredModal = () => {
return `
<div class="modal" id="hardModal" tabindex="-1" role="dialog" aria-labelledby="hardModalLabel" aria-modal="true" aria-describedby="hardModalBodyText">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="hardModalLabel">${translate('responseRequiredLabel')}</h5>
<button type="button" class="close" data-dismiss="modal" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p id="hardModalBodyText"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal" data-bs-dismiss="modal">${translate('answerQuestionButton')}</button>
</div>
</div>
</div>
</div>
`;
}
export const responseErrorModal = () => {
return `
<div class="modal" id="softModalResponse" tabindex="-1" role="dialog" aria-labelledby="softModalResponseTitle" aria-modal="true" aria-describedby="softModalResponseBody">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="softModalResponseTitle">${translate('responseErrorLabel')}</h5>
<button type="button" class="close" data-dismiss="modal" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div id="modalResponseBody" class="modal-body">
<p>${translate('responseErrorBody')}</p>
</div>
<div id="softModalResponseFooter" class="modal-footer">
<button type="button" id=modalResponseContinueButton class="btn btn-success" data-dismiss="modal" data-bs-dismiss="modal">${translate('correctButton')}</button>
<button type="button" id=modalResponseCloseButton class="btn btn-danger" data-dismiss="modal" data-bs-dismiss="modal">${translate('incorrectButton')}</button>
</div>
</div>
</div>
</div>
`;
}
export const submitModal = () => {
return `
<div class="modal" id="submitModal" tabindex="-1" role="dialog" aria-labelledby="submitModalLabel" aria-modal="true" aria-describedby="submitModalBodyText">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="submitModalLabel">${translate('submitLabel')}</h5>
<button type="button" class="close" data-dismiss="modal" data-bs-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p id="submitModalBodyText">${translate('submitBody')}</p>
</div>
<div class="modal-footer">
<button type="button" id="submitModalButton" class="btn btn-success" data-dismiss="modal" data-bs-dismiss="modal">${translate('submitButton')}</button>
<button type="button" id="cancelModal" class="btn btn-danger" data-dismiss="modal" data-bs-dismiss="modal">${translate('cancelButton')}</button>
</div>
</div>
</div>
</div>
`;
}