The namespace of js-webcam-screenshot.
- Source:
Members
-
<static> DEFAULT_POST_FIELDNAME :string
-
The default name of the image field to be posted.
Type:
- string
- Default Value:
-
- "image"
- Source:
-
<static, readonly> RC :number
-
Possible code values passed to the
callback
of thego()
method.Type:
- number
- Source:
Properties:
Name Type Default Description OK
number 0 All good. USER_CANCELLED
number 1 User cancelled. UNSUPPORTED_BROWSER
number 2 Browser is not supported. CANT_ACCESS_WEBCAM
number 3 Error accessing the webcam. SAVE_CALLBACKERROR
number 4 Error thrown by the callback called just before posting data. SAVE_FAILED
number 5 Error while posting the image. -
<static, constant> VERSION :string
-
The current version of WebcamScreenshot.
Type:
- string
- Default Value:
-
- "0.1.0"
- Source:
Methods
-
<static> canvasToFormData(formData, fieldName, canvas, imageFormat)
-
Helper function to add the image represented in a
<canvas>
to aFormData
instance for posting.Parameters:
Name Type Argument Default Description formData
FormData The FormData
instance to add the image to.fieldName
string The name of the field that will contain the image data. canvas
HTMLCanvasElement A <canvas>
DOM element.imageFormat
string <optional>
'png' The format of the image (accepted values: 'jpg'
,'png'
).- Source:
-
<static> getIsSpported() → {boolean}
-
Returns
true
if the browser is supported,false
otherwise.- Source:
Returns:
- Type
- boolean
-
<static> go(options, callback)
-
Take a shot with the webcam.
Parameters:
Name Type Argument Description options
WebcamScreenshot.goOptions <optional>
Options. callback
WebcamScreenshot.goCallback <optional>
A function that will be called at the end. - Source:
Type Definitions
-
goBeforePostCallback(formData)
-
This callback is called just before POSTing the image.
Parameters:
Name Type Description formData
FormData The FormData
instance that's going to be posted. Useful to add other values to the POST (example:formData.append('myfield', 'myvalue');
).- Source:
-
goCallback(code, result)
-
Callback called after the
go()
method ends.Parameters:
Name Type Argument Description code
WebcamScreenshot.RC One of the WebcamScreenshot.RC
values.result
string | Object <optional>
This value may be: - If
code
is notWebcamScreenshot.RC.OK
→result
will contain error description ({string}). - If
code
isWebcamScreenshot.RC.OK
:- If the
postTo
option has been specified →result
will contain the response from the server. - If the
postTo
optionw wasn't set →result
will beundefined
.
- If the
- Source:
- If
-
goOptions
-
The options for
go()
methodType:
- Object
'bs2'
for Bootstrap 2'bs3'
for Bootstrap 3'jQueryUI'
for jQuery UI- Source:
Properties:
Name Type Argument Default Description width
number <optional>
300 The width of the image to be taken (in pixels). cancelText
string <optional>
'Cancel' The text (html is accepted) to show for the "Cancel" button. takeText
string <optional>
'Take it' The text (html is accepted) to show for the "Take it" button. parent
HTMLElement <optional>
window.document.body The DOM node to which we'll append our DOM nodes. canvas
HTMLCanvasElement | Array.<HTMLCanvasElement> | jQuery <optional>
null The <canvas> DOM node to which we'll render the taken shot (it can also be a jQuery object or an array of DOM nodes). postTo
string <optional>
If specified, we'll post the taken shot to this URL (as a form POST). postFieldname
string <optional>
If postTo, this will be the name of the field containing the image (defaults to WebcamScreenshot.DEFAULT_POST_FIELDNAME). postImageFormat
string <optional>
'png' The file format of the data to send (accepted values: 'jpg'
,'png'
).postReturnDataType
string <optional>
The type of data that you're expecting back from the server. For possible values see thee description of the dataType
options ofjQuery.ajax()
.onBeforePost
WebcamScreenshot.goBeforePostCallback <optional>
A function that will be called before posting the image. dialogFramework
string <optional>
The optional framework to use to show the dialog. Allowed values: dialogTitle
string <optional>
'Screenshot from webcam' The title of the dialog (used only if dialogFramework
is specified).