Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
captureImage: function (successCallback, errorCallback, args) {
var fail = function (code) {
if (errorCallback) {
errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR));
}
};
var options = args[0];
var limit = options.limit || 1;
if (typeof limit !== 'number' || limit < 1) {
fail(CaptureError.CAPTURE_INVALID_ARGUMENT);
return;
}
// Counter for already taken images
var imagesTaken = 0;
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;
if (!navigator.getUserMedia) {
fail(CaptureError.CAPTURE_NOT_SUPPORTED);
return;
}
}, function () {
errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
}
);
}, function () {
errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
});
} else if (mediaTypeFlag === 'image') {