This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
/
index.vue
executable file
·338 lines (333 loc) · 10.1 KB
/
index.vue
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<template>
<div class="settings-experiments-view">
<p class="mb-0">
These are some features that aren't quite ready yet. You're welcome to try
them out! Feel free to send feedback to
<a href="mailto:REMOVED">REMOVED</a> or
through
<a
href="javascript:void(0)"
@click="$store.dispatch('START_SUPPORT_POPUP')"
>online chat</a
>.
</p>
<hr class="my-3" />
<b-modal
ref="invalidExperiment"
class="text-center"
hide-header
@shown="focusInvalidExperimentModalOkButton()"
>
<div style="font-size: 7rem;" class="p-0 text-center">🤔</div>
<div slot="modal-footer">
<b-button
class="float-right"
variant="secondary"
ref="invalidExperimentModalOkButton"
@click="hideInvalidExperimentModal()"
>{{ $t('common.ok') }}</b-button
>
</div>
</b-modal>
<b-modal ref="experimentConfirmation" hide-header>
<h3 class="modal-title text-center mb-3">
Do you want to add this experiment?
</h3>
<div class="card card-body mb-3 d-flex h-100">
<fa icon="flask" size="3x" class="mx-auto mb-3" />
<h3 class="h4 text-center mb-0">
{{ experimentToAdd.name }}
</h3>
<p class="mb-0 text-center mt-2 text-muted small">
<span v-if="experimentToAdd.description">
{{ experimentToAdd.description }}
</span>
<span v-else class="font-italic">No description</span>
</p>
</div>
<p class="text-center">
This feature is still in the oven and may not work right.
</p>
<hr />
<div class="text-danger font-weight-bold">
<b-form-checkbox
v-model="acknowledgements.experimentMayNotWorkOrBreakThings"
>
I understand that this experiment may not work perfectly and things
might break.
</b-form-checkbox>
<b-form-checkbox v-model="acknowledgements.couldGoAwayAtAnyTime">
I understand that this experiment could go away at any time.
</b-form-checkbox>
<b-form-checkbox
v-model="acknowledgements.iWillGiveFeedbackOnHowTheExperimentWorks"
>
I'll give feedback on how well this experiment works for me (<a
href="mailto:REMOVED"
target="_blank"
>REMOVED</a
>
or
<a
href="javascript:void(0)"
@click="$store.dispatch('START_SUPPORT_POPUP')"
>online chat</a
>).
</b-form-checkbox>
</div>
<div slot="modal-footer">
<b-button
:disabled="
!acknowledgements.experimentMayNotWorkOrBreakThings ||
!acknowledgements.couldGoAwayAtAnyTime ||
!acknowledgements.iWillGiveFeedbackOnHowTheExperimentWorks
"
class="float-right"
:variant="
!acknowledgements.experimentMayNotWorkOrBreakThings ||
!acknowledgements.couldGoAwayAtAnyTime ||
!acknowledgements.iWillGiveFeedbackOnHowTheExperimentWorks
? 'outline-dark'
: 'secondary'
"
@click="addExperiment({ withConfirmation: false })"
>{{ $t('settings.experiments.addExperiment') }}</b-button
>
<b-button
class="float-right"
variant="link"
@click="hideExperimentConfirmationModal()"
>{{ $t('common.cancel') }}</b-button
>
</div>
</b-modal>
<b-modal ref="experimentAlreadyAdded" hide-header>
<h5 class="modal-title">
{{
$t('settings.experiments.alreadyAdded', {
alreadyAddedExperimentName,
})
}}
</h5>
<div slot="modal-footer">
<b-button
class="float-right"
variant="secondary"
@click="hideExperimentAlreadyAddedModal()"
>{{ $t('common.ok') }}</b-button
>
</div>
</b-modal>
<div class="row">
<div
class="col-md-6 mb-3"
v-for="experiment in experimentsWithHiddenExperiments"
:key="experiment.id"
>
<div
class="card card-body mb-3 d-flex h-100"
:class="
experimentLoaded(experiment.id) ? 'bg-white shadow' : 'bg-light'
"
>
<h3 class="h5">
{{ experiment.name }}
</h3>
<p class="small mb-0">
<span v-if="experiment.description">{{
experiment.description
}}</span>
<span v-else class="font-italic">No description</span>
</p>
<hr class="mt-auto" />
<div class="d-flex mb-n2 mt-1 align-items-center">
<span
v-if="experimentLoaded(experiment.id)"
class="small text-muted"
><fa icon="check" fixed-width /> Added
</span>
<b-button
v-if="experimentLoaded(experiment.id)"
class="ml-auto stretched-link"
@click="
$store.commit('REMOVE_EXPERIMENT', {
experiment: experiment.id,
})
"
variant="outline-danger"
>
Remove
</b-button>
<b-button
v-else
class="ml-auto stretched-link"
@click="
experimentIdToAdd = experiment.id;
addExperiment({ withConfirmation: true });
"
>
Add
</b-button>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import {
BButton,
BModal,
BInputGroup,
BInputGroupAppend,
BListGroup,
BListGroupItem,
BFormInput,
BFormCheckbox,
} from 'bootstrap-vue';
export default {
components: {
BButton,
BInputGroup,
BInputGroupAppend,
BListGroup,
BListGroupItem,
BFormInput,
BFormCheckbox,
BModal,
},
middleware: ['settings-meta'],
meta: {
settingsPageTitleKey: 'settings.experiments.experiments',
},
data() {
return {
experiments: [
{
id: 'typingMode',
name: 'Manually type captions',
description: 'Adds a button to manually type captions.',
},
{
id: 'demo',
name: 'Demo mode',
description:
'Fills the captionining window automatically with dummy text and ignores any microphone input.',
},
{
id: 'speakBack',
name: 'Speak everything back',
description:
'After speech is converted to text, convert the text back to speech using speech synthesis.',
},
{
id: 'youtube',
name: 'YouTube integration',
description:
'Add an experimental YouTube live closed captions integration. After you add this experiment, go to Channels to set it up.',
},
],
experimentIdToAdd: '',
alreadyAddedExperimentName: '',
acknowledgements: {
experimentMayNotWorkOrBreakThings: false,
couldGoAwayAtAnyTime: false,
iWillGiveFeedbackOnHowTheExperimentWorks: false,
},
};
},
computed: {
loadedExperiments() {
return this.$store.state.settings.exp;
},
experimentToAdd() {
const experiment = this.experiments.find(
(e) => e.id === this.experimentIdToAdd
);
return experiment || { name: this.experimentIdToAdd }; // it's a hidden experiment
},
experimentsWithHiddenExperiments() {
return [
...this.experiments,
// With added experiments that aren't in our static list
// of experiments we present on load
...this.loadedExperiments
// Remove experiments that are already in our static list
.filter(
(loadedExperiment) =>
!this.experiments.map((e) => e.id).includes(loadedExperiment)
)
.map((loadedExperimentId) => ({
id: loadedExperimentId,
name: loadedExperimentId,
})),
];
},
},
methods: {
experimentLoaded(experimentId) {
return this.loadedExperiments.includes(experimentId);
},
hideInvalidExperimentModal: function() {
this.$refs.invalidExperiment.hide();
},
hideExperimentConfirmationModal: function() {
this.$refs.experimentConfirmation.hide();
Object.keys(this.acknowledgements).forEach(
(acknowledgementKey) =>
(this.acknowledgements[acknowledgementKey] = false)
);
},
hideExperimentAlreadyAddedModal: function() {
this.$refs.experimentAlreadyAdded.hide();
},
isValidExperiment: function() {
return [
'share',
'fab',
'saveTranscriptWithTimingsToDropbox',
'captionSpeedSetting',
...this.experiments.map((e) => e.id),
].includes(this.experimentIdToAdd);
},
addExperiment: function({ withConfirmation }) {
if (this.isValidExperiment()) {
if (withConfirmation) {
this.$refs.experimentConfirmation.show();
} else {
this.$store.commit('ADD_EXPERIMENT', {
experiment: this.experimentIdToAdd,
});
this.experimentIdToAdd = '';
this.$refs.experimentConfirmation.hide();
}
} else {
this.$refs.invalidExperiment.show();
}
Object.keys(this.acknowledgements).forEach(
(acknowledgementKey) =>
(this.acknowledgements[acknowledgementKey] = false)
);
},
focusInvalidExperimentModalOkButton: function() {
this.$refs.invalidExperimentModalOkButton.focus();
},
parseExperimentFromURL() {
if (this.$route.query.add) {
if (this.loadedExperiments.includes(this.$route.query.add)) {
this.alreadyAddedExperimentName = this.$route.query.add;
this.$refs.experimentAlreadyAdded.show();
} else {
this.experimentIdToAdd = this.$route.query.add;
this.addExperiment({ withConfirmation: true });
}
}
},
},
watch: {
'$store.state.settingsLoaded'() {
this.parseExperimentFromURL();
},
},
};
</script>