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
callbackof thego()method.Type:
- number
- Source:
Properties:
Name Type Default Description OKnumber 0 All good. USER_CANCELLEDnumber 1 User cancelled. UNSUPPORTED_BROWSERnumber 2 Browser is not supported. CANT_ACCESS_WEBCAMnumber 3 Error accessing the webcam. SAVE_CALLBACKERRORnumber 4 Error thrown by the callback called just before posting data. SAVE_FAILEDnumber 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 aFormDatainstance for posting.Parameters:
Name Type Argument Default Description formDataFormData The FormDatainstance to add the image to.fieldNamestring The name of the field that will contain the image data. canvasHTMLCanvasElement A <canvas>DOM element.imageFormatstring <optional>
'png' The format of the image (accepted values: 'jpg','png').- Source:
-
<static> getIsSpported() → {boolean}
-
Returns
trueif the browser is supported,falseotherwise.- Source:
Returns:
- Type
- boolean
-
<static> go(options, callback)
-
Take a shot with the webcam.
Parameters:
Name Type Argument Description optionsWebcamScreenshot.goOptions <optional>
Options. callbackWebcamScreenshot.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 formDataFormData The FormDatainstance 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 codeWebcamScreenshot.RC One of the WebcamScreenshot.RCvalues.resultstring | Object <optional>
This value may be: - If
codeis notWebcamScreenshot.RC.OK→resultwill contain error description ({string}). - If
codeisWebcamScreenshot.RC.OK:- If the
postTooption has been specified →resultwill contain the response from the server. - If the
postTooptionw wasn't set →resultwill 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 widthnumber <optional>
300 The width of the image to be taken (in pixels). cancelTextstring <optional>
'Cancel' The text (html is accepted) to show for the "Cancel" button. takeTextstring <optional>
'Take it' The text (html is accepted) to show for the "Take it" button. parentHTMLElement <optional>
window.document.body The DOM node to which we'll append our DOM nodes. canvasHTMLCanvasElement | 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). postTostring <optional>
If specified, we'll post the taken shot to this URL (as a form POST). postFieldnamestring <optional>
If postTo, this will be the name of the field containing the image (defaults to WebcamScreenshot.DEFAULT_POST_FIELDNAME). postImageFormatstring <optional>
'png' The file format of the data to send (accepted values: 'jpg','png').postReturnDataTypestring <optional>
The type of data that you're expecting back from the server. For possible values see thee description of the dataTypeoptions ofjQuery.ajax().onBeforePostWebcamScreenshot.goBeforePostCallback <optional>
A function that will be called before posting the image. dialogFrameworkstring <optional>
The optional framework to use to show the dialog. Allowed values: dialogTitlestring <optional>
'Screenshot from webcam' The title of the dialog (used only if dialogFrameworkis specified).