videomail-client 5.2.1 → 5.3.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/README.md +1 -1
- package/TODO.md +4 -3
- package/package.json +3 -3
- package/prototype/index.html +3 -3
- package/prototype/js/videomail-client.js +152 -73
- package/prototype/js/videomail-client.min.js +4 -4
- package/prototype/js/videomail-client.min.js.map +1 -1
- package/prototype/with_cc_and_bcc.html +115 -0
- package/src/js/events.js +1 -0
- package/src/js/options.js +2 -0
- package/src/js/wrappers/container.js +51 -42
- package/src/js/wrappers/form.js +67 -0
- package/src/js/wrappers/visuals/recorder.js +5 -3
- package/prototype/with_time_control.html +0 -39
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>videomail-client examples</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
+
|
|
7
|
+
<style type="text/css">
|
|
8
|
+
input[type='email'],
|
|
9
|
+
input[type='text'],
|
|
10
|
+
fieldset,
|
|
11
|
+
textarea,
|
|
12
|
+
.buttons,
|
|
13
|
+
#startOver {
|
|
14
|
+
margin: 1em 0;
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<h1>With CC and BCC</h1>
|
|
21
|
+
<p>Another form example with optional CC and BCC input fields for email addresses.</p>
|
|
22
|
+
|
|
23
|
+
<!-- Once you set the method to POST, then two request will be made internally. -->
|
|
24
|
+
<!-- The first one to the videomail server and the second one to the specified action -->
|
|
25
|
+
<form action="/contact" method="post" id="videomailFormWithCcAndBcc">
|
|
26
|
+
<input
|
|
27
|
+
name="from"
|
|
28
|
+
size="64"
|
|
29
|
+
type="email"
|
|
30
|
+
placeholder="Enter your email address"
|
|
31
|
+
required
|
|
32
|
+
/>
|
|
33
|
+
<input
|
|
34
|
+
multiple
|
|
35
|
+
name="to"
|
|
36
|
+
size="64"
|
|
37
|
+
type="email"
|
|
38
|
+
placeholder="Enter recipient TO email addresss(es)"
|
|
39
|
+
/>
|
|
40
|
+
<input
|
|
41
|
+
multiple
|
|
42
|
+
name="cc"
|
|
43
|
+
size="64"
|
|
44
|
+
type="email"
|
|
45
|
+
placeholder="Enter recipient CC email address(es)"
|
|
46
|
+
/>
|
|
47
|
+
<input
|
|
48
|
+
multiple
|
|
49
|
+
name="bcc"
|
|
50
|
+
size="64"
|
|
51
|
+
type="email"
|
|
52
|
+
placeholder="Enter recipient BCC email address(es)"
|
|
53
|
+
/>
|
|
54
|
+
<input
|
|
55
|
+
name="subject"
|
|
56
|
+
size="64"
|
|
57
|
+
type="text"
|
|
58
|
+
placeholder="Enter a subject"
|
|
59
|
+
required
|
|
60
|
+
/>
|
|
61
|
+
<div id="videomail"></div>
|
|
62
|
+
<textarea
|
|
63
|
+
id="body"
|
|
64
|
+
name="body"
|
|
65
|
+
placeholder="Enter your message"
|
|
66
|
+
cols="40"
|
|
67
|
+
rows="4"
|
|
68
|
+
required
|
|
69
|
+
></textarea>
|
|
70
|
+
</form>
|
|
71
|
+
|
|
72
|
+
<!-- Placed outside the form by intention to ensure code works with that scenario as well -->
|
|
73
|
+
<input type="button" value="Submit" disabled />
|
|
74
|
+
|
|
75
|
+
<div id="viewVideo" style="display: none">
|
|
76
|
+
<h2 class="subject"></h2>
|
|
77
|
+
<h3 class="status"></h3>
|
|
78
|
+
<p class="body"></p>
|
|
79
|
+
<video class="replay"></video>
|
|
80
|
+
<button id="startOver">Start over</button>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<script src="/js/videomail-client.js"></script>
|
|
84
|
+
<script>
|
|
85
|
+
var videomailClient = new VideomailClient({
|
|
86
|
+
verbose: true,
|
|
87
|
+
video: { limitSeconds: 120, width: 320, countdown: false },
|
|
88
|
+
selectors: {
|
|
89
|
+
submitButtonSelector: 'body input[value="Submit"]',
|
|
90
|
+
formId: 'videomailFormWithCcAndBcc'
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
var startOverButton = document.getElementById('startOver')
|
|
95
|
+
|
|
96
|
+
var onSubmitted = function (videomail, response) {
|
|
97
|
+
var statusHeader = document.querySelector('h3.status')
|
|
98
|
+
|
|
99
|
+
// status has been generated on server side, see gulp task 'connect'
|
|
100
|
+
statusHeader.innerHTML = response.status
|
|
101
|
+
|
|
102
|
+
this.replay(videomail, 'viewVideo')
|
|
103
|
+
|
|
104
|
+
startOverButton.onclick = this.startOver
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
videomailClient.on(
|
|
108
|
+
videomailClient.events.SUBMITTED,
|
|
109
|
+
onSubmitted.bind(videomailClient)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
videomailClient.show()
|
|
113
|
+
</script>
|
|
114
|
+
</body>
|
|
115
|
+
</html>
|
package/src/js/events.js
CHANGED
|
@@ -11,6 +11,7 @@ export default keymirror({
|
|
|
11
11
|
COUNTDOWN: null, // countdown for recording has started
|
|
12
12
|
RECORDING: null, // webcam is recording
|
|
13
13
|
STOPPING: null, // recording is being stopped (= preview)
|
|
14
|
+
STOPPED: null, // recording has stopped
|
|
14
15
|
PROGRESS: null, // start sending
|
|
15
16
|
BEGIN_AUDIO_ENCODING: null, // encoding video
|
|
16
17
|
BEGIN_VIDEO_ENCODING: null, // encoding video
|
package/src/js/options.js
CHANGED
|
@@ -135,6 +135,8 @@ export default {
|
|
|
135
135
|
defaults: {
|
|
136
136
|
from: null, // define default FROM email address
|
|
137
137
|
to: null, // define default TO email address
|
|
138
|
+
cc: null, // define default CC email address
|
|
139
|
+
bcc: null, // define default BCC email address
|
|
138
140
|
subject: null, // define default subject line
|
|
139
141
|
body: null // define default body content
|
|
140
142
|
},
|
|
@@ -222,49 +222,8 @@ const Container = function (options) {
|
|
|
222
222
|
hidden(containerElement, true)
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
// fixes https://github.com/binarykitchen/videomail-client/issues/71
|
|
226
|
-
function trimEmail(email) {
|
|
227
|
-
return email.replace(/(^[,\s]+)|([,\s]+$)/g, '')
|
|
228
|
-
}
|
|
229
|
-
|
|
230
225
|
function submitVideomail(formData, method, cb) {
|
|
231
|
-
const
|
|
232
|
-
subject: options.selectors.subjectInputName,
|
|
233
|
-
from: options.selectors.fromInputName,
|
|
234
|
-
to: options.selectors.toInputName,
|
|
235
|
-
cc: options.selectors.ccInputName,
|
|
236
|
-
bcc: options.selectors.bccInputName,
|
|
237
|
-
body: options.selectors.bodyInputName,
|
|
238
|
-
key: options.selectors.keyInputName,
|
|
239
|
-
parentKey: options.selectors.parentKeyInputName,
|
|
240
|
-
sendCopy: options.selectors.sendCopyInputName
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const videomailFormData = {}
|
|
244
|
-
|
|
245
|
-
Object.keys(FORM_FIELDS).forEach(function (key) {
|
|
246
|
-
const formFieldValue = FORM_FIELDS[key]
|
|
247
|
-
|
|
248
|
-
if (formFieldValue in formData) {
|
|
249
|
-
videomailFormData[key] = formData[formFieldValue]
|
|
250
|
-
}
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
if (videomailFormData.from) {
|
|
254
|
-
videomailFormData.from = trimEmail(videomailFormData.from)
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (videomailFormData.to) {
|
|
258
|
-
videomailFormData.to = trimEmail(videomailFormData.to)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (videomailFormData.cc) {
|
|
262
|
-
videomailFormData.cc = trimEmail(videomailFormData.cc)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (videomailFormData.bcc) {
|
|
266
|
-
videomailFormData.bcc = trimEmail(videomailFormData.bcc)
|
|
267
|
-
}
|
|
226
|
+
const videomailFormData = form.transformFormData(formData)
|
|
268
227
|
|
|
269
228
|
// when method is undefined, treat it as a post
|
|
270
229
|
if (isPost(method) || !method) {
|
|
@@ -613,6 +572,56 @@ const Container = function (options) {
|
|
|
613
572
|
whyInvalid = 'Form input(s() are invalid'
|
|
614
573
|
}
|
|
615
574
|
}
|
|
575
|
+
|
|
576
|
+
// TODO CONTINUE FROM HERE, MAKE VALIDATION CLEVER WHEN AUTOMATIC SO THAT IT REQUIRES AT
|
|
577
|
+
// LEAST ONE RECIPIENT AMONG TO/CC/BCC
|
|
578
|
+
if (valid) {
|
|
579
|
+
// If CC and/or BCC exist, validate one more time to ensure at least
|
|
580
|
+
// one recipient is given
|
|
581
|
+
const recipients = form.getRecipients()
|
|
582
|
+
|
|
583
|
+
const toIsConfigured = 'to' in recipients
|
|
584
|
+
const ccIsConfigured = 'cc' in recipients
|
|
585
|
+
const bccIsConfigured = 'bcc' in recipients
|
|
586
|
+
|
|
587
|
+
const hasTo = recipients.to?.length > 0
|
|
588
|
+
const hasCc = recipients.cc?.length > 0
|
|
589
|
+
const hasBcc = recipients.bcc?.length > 0
|
|
590
|
+
|
|
591
|
+
if (toIsConfigured) {
|
|
592
|
+
if (!hasTo) {
|
|
593
|
+
if (ccIsConfigured && bccIsConfigured) {
|
|
594
|
+
if (!hasCc && !hasBcc) {
|
|
595
|
+
valid = false
|
|
596
|
+
}
|
|
597
|
+
} else if (ccIsConfigured) {
|
|
598
|
+
if (!hasCc) {
|
|
599
|
+
valid = false
|
|
600
|
+
}
|
|
601
|
+
} else if (bccIsConfigured) {
|
|
602
|
+
if (!hasBcc) {
|
|
603
|
+
valid = false
|
|
604
|
+
}
|
|
605
|
+
} else {
|
|
606
|
+
whyInvalid = 'Please configure the form to have at least one recipient.'
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
} else if (ccIsConfigured) {
|
|
610
|
+
if (!hasCc) {
|
|
611
|
+
if (bccIsConfigured) {
|
|
612
|
+
if (!hasBcc) {
|
|
613
|
+
valid = false
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (!valid) {
|
|
620
|
+
whyInvalid = 'Please enter at least one recipient.'
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
console.log({ recipients })
|
|
624
|
+
}
|
|
616
625
|
} else {
|
|
617
626
|
valid = visualsValid
|
|
618
627
|
}
|
package/src/js/wrappers/form.js
CHANGED
|
@@ -7,6 +7,11 @@ import Events from '../events'
|
|
|
7
7
|
import EventEmitter from '../util/eventEmitter'
|
|
8
8
|
import VideomailError from '../util/videomailError'
|
|
9
9
|
|
|
10
|
+
// fixes https://github.com/binarykitchen/videomail-client/issues/71
|
|
11
|
+
function trimEmail(email) {
|
|
12
|
+
return email.replace(/(^[,\s]+)|([,\s]+$)/g, '')
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
const Form = function (container, formElement, options) {
|
|
11
16
|
EventEmitter.call(this, options, 'Form')
|
|
12
17
|
|
|
@@ -18,6 +23,68 @@ const Form = function (container, formElement, options) {
|
|
|
18
23
|
return getFormData(formElement, { includeDisabled: true })
|
|
19
24
|
}
|
|
20
25
|
|
|
26
|
+
this.transformFormData = function (formData) {
|
|
27
|
+
const FORM_FIELDS = {
|
|
28
|
+
subject: options.selectors.subjectInputName,
|
|
29
|
+
from: options.selectors.fromInputName,
|
|
30
|
+
to: options.selectors.toInputName,
|
|
31
|
+
cc: options.selectors.ccInputName,
|
|
32
|
+
bcc: options.selectors.bccInputName,
|
|
33
|
+
body: options.selectors.bodyInputName,
|
|
34
|
+
key: options.selectors.keyInputName,
|
|
35
|
+
parentKey: options.selectors.parentKeyInputName,
|
|
36
|
+
sendCopy: options.selectors.sendCopyInputName
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const transformedFormData = {}
|
|
40
|
+
|
|
41
|
+
Object.keys(FORM_FIELDS).forEach(function (key) {
|
|
42
|
+
const formFieldValue = FORM_FIELDS[key]
|
|
43
|
+
|
|
44
|
+
if (formFieldValue in formData) {
|
|
45
|
+
transformedFormData[key] = formData[formFieldValue]
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
if (transformedFormData.from) {
|
|
50
|
+
transformedFormData.from = trimEmail(transformedFormData.from)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (transformedFormData.to) {
|
|
54
|
+
transformedFormData.to = trimEmail(transformedFormData.to)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (transformedFormData.cc) {
|
|
58
|
+
transformedFormData.cc = trimEmail(transformedFormData.cc)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (transformedFormData.bcc) {
|
|
62
|
+
transformedFormData.bcc = trimEmail(transformedFormData.bcc)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return transformedFormData
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.getRecipients = function () {
|
|
69
|
+
const videomailFormData = this.transformFormData(getData())
|
|
70
|
+
|
|
71
|
+
const recipients = {}
|
|
72
|
+
|
|
73
|
+
if ('to' in videomailFormData) {
|
|
74
|
+
recipients.to = videomailFormData.to
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if ('cc' in videomailFormData) {
|
|
78
|
+
recipients.cc = videomailFormData.cc
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if ('bcc' in videomailFormData) {
|
|
82
|
+
recipients.bcc = videomailFormData.bcc
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return recipients
|
|
86
|
+
}
|
|
87
|
+
|
|
21
88
|
this.loadVideomail = function (videomail) {
|
|
22
89
|
const limit = formElement.elements.length
|
|
23
90
|
|
|
@@ -756,8 +756,8 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
|
|
|
756
756
|
args: args
|
|
757
757
|
}
|
|
758
758
|
|
|
759
|
-
// todo commented out because for some reasons server does
|
|
760
|
-
// array of many log lines. to examine later.
|
|
759
|
+
// todo commented out because for some reasons server does
|
|
760
|
+
// not accept such a long array of many log lines. to examine later.
|
|
761
761
|
//
|
|
762
762
|
// add some useful debug info to examine weird stuff like this one
|
|
763
763
|
// UnprocessableError: Unable to encode a video with FPS near zero.
|
|
@@ -858,7 +858,9 @@ const Recorder = function (visuals, replay, defaultOptions = {}) {
|
|
|
858
858
|
recordingStats.sampleRate = userMedia.getAudioSampleRate()
|
|
859
859
|
}
|
|
860
860
|
|
|
861
|
-
writeCommand('stop', recordingStats)
|
|
861
|
+
writeCommand('stop', recordingStats, function () {
|
|
862
|
+
self.emit(Events.STOPPED, { recordingStats })
|
|
863
|
+
})
|
|
862
864
|
|
|
863
865
|
// beware, resetting will set framesCount to zero, so leave this here
|
|
864
866
|
self.reset()
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>videomail-client examples</title>
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<h1>BETA! Include time control to ensure video frames are in perfect order</h1>
|
|
9
|
-
<div id="videomail"></div>
|
|
10
|
-
<script src="/js/videomail-client.js"></script>
|
|
11
|
-
<script>
|
|
12
|
-
var videomailClient = new VideomailClient({
|
|
13
|
-
verbose: true,
|
|
14
|
-
enableAutoPause: false,
|
|
15
|
-
disableSubmit: true,
|
|
16
|
-
audio: {
|
|
17
|
-
enabled: true,
|
|
18
|
-
switch: true
|
|
19
|
-
},
|
|
20
|
-
image: {
|
|
21
|
-
quality: 0.5
|
|
22
|
-
},
|
|
23
|
-
video: {
|
|
24
|
-
limitSeconds: 120,
|
|
25
|
-
countdown: false,
|
|
26
|
-
width: 640,
|
|
27
|
-
timeControl: true
|
|
28
|
-
},
|
|
29
|
-
text: {
|
|
30
|
-
buttons: {
|
|
31
|
-
preview: 'Stop'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
videomailClient.show()
|
|
37
|
-
</script>
|
|
38
|
-
</body>
|
|
39
|
-
</html>
|