Skip to content

Commit

Permalink
dep(dev)!: bump @cordova/[email protected] (#846)
Browse files Browse the repository at this point in the history
* dep(dev)!: bump @cordova/[email protected]
* chore: apply automatic lint fix
  • Loading branch information
erisu authored Aug 17, 2023
1 parent c2eb21d commit 61a6e9b
Show file tree
Hide file tree
Showing 9 changed files with 2,038 additions and 2,010 deletions.
3,608 changes: 1,818 additions & 1,790 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
}
},
"devDependencies": {
"@cordova/eslint-config": "^3.0.0"
"@cordova/eslint-config": "^5.0.0"
}
}
28 changes: 14 additions & 14 deletions src/browser/CameraProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
*
*/

var HIGHEST_POSSIBLE_Z_INDEX = 2147483647;
const HIGHEST_POSSIBLE_Z_INDEX = 2147483647;

function takePicture (success, error, opts) {
if (opts && opts[2] === 1) {
capture(success, error, opts);
} else {
var input = document.createElement('input');
const input = document.createElement('input');
input.style.position = 'relative';
input.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX;
input.className = 'cordova-camera-select';
input.type = 'file';
input.name = 'files[]';

input.onchange = function (inputEvent) {
var reader = new FileReader(); /* eslint no-undef : 0 */
const reader = new FileReader(); /* eslint no-undef : 0 */
reader.onload = function (readerEvent) {
input.parentNode.removeChild(input);

var imageData = readerEvent.target.result;
const imageData = readerEvent.target.result;

return success(imageData.substr(imageData.indexOf(',') + 1));
};
Expand All @@ -50,16 +50,16 @@ function takePicture (success, error, opts) {
}

function capture (success, errorCallback, opts) {
var localMediaStream;
var targetWidth = opts[3];
var targetHeight = opts[4];
let localMediaStream;
let targetWidth = opts[3];
let targetHeight = opts[4];

targetWidth = targetWidth === -1 ? 320 : targetWidth;
targetHeight = targetHeight === -1 ? 240 : targetHeight;

var video = document.createElement('video');
var button = document.createElement('button');
var parent = document.createElement('div');
const video = document.createElement('video');
const button = document.createElement('button');
const parent = document.createElement('div');
parent.style.position = 'relative';
parent.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX;
parent.className = 'cordova-camera-capture';
Expand All @@ -72,13 +72,13 @@ function capture (success, errorCallback, opts) {

button.onclick = function () {
// create a canvas and capture a frame from video stream
var canvas = document.createElement('canvas');
const canvas = document.createElement('canvas');
canvas.width = targetWidth;
canvas.height = targetHeight;
canvas.getContext('2d').drawImage(video, 0, 0, targetWidth, targetHeight);

// convert image stored in canvas to base64 encoded image
var imageData = canvas.toDataURL('image/png');
let imageData = canvas.toDataURL('image/png');
imageData = imageData.replace('data:image/png;base64,', '');

// stop video stream, remove video and button.
Expand All @@ -100,7 +100,7 @@ function capture (success, errorCallback, opts) {
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;

var successCallback = function (stream) {
const successCallback = function (stream) {
localMediaStream = stream;
if ('srcObject' in video) {
video.srcObject = localMediaStream;
Expand All @@ -123,7 +123,7 @@ function capture (success, errorCallback, opts) {
}

module.exports = {
takePicture: takePicture,
takePicture,
cleanup: function () {}
};

Expand Down
Loading

0 comments on commit 61a6e9b

Please sign in to comment.