Skip to content

Commit

Permalink
dep: bump @cordova/eslint-config@^5.0.0 w/ lint fix & package-lock re…
Browse files Browse the repository at this point in the history
…build (apache#276)
  • Loading branch information
erisu authored Jul 25, 2023
1 parent 0f07bef commit 3ce9948
Show file tree
Hide file tree
Showing 15 changed files with 1,565 additions and 2,188 deletions.
3,495 changes: 1,436 additions & 2,059 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 @@ -49,6 +49,6 @@
}
},
"devDependencies": {
"@cordova/eslint-config": "^3.0.0"
"@cordova/eslint-config": "^5.0.0"
}
}
40 changes: 20 additions & 20 deletions src/browser/CaptureProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*
*/

var MediaFile = require('cordova-plugin-media-capture.MediaFile');
var MediaFileData = require('cordova-plugin-media-capture.MediaFileData');
var CaptureError = require('cordova-plugin-media-capture.CaptureError');
const MediaFile = require('cordova-plugin-media-capture.MediaFile');
const MediaFileData = require('cordova-plugin-media-capture.MediaFileData');
const CaptureError = require('cordova-plugin-media-capture.CaptureError');

/**
* Helper function that converts data URI to Blob
Expand All @@ -31,15 +31,15 @@ var CaptureError = require('cordova-plugin-media-capture.CaptureError');
function dataURItoBlob (dataURI) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs
var byteString = atob(dataURI.split(',')[1]); // eslint-disable-line no-undef
const byteString = atob(dataURI.split(',')[1]); // eslint-disable-line no-undef

// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];

// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
const ab = new ArrayBuffer(byteString.length);
const ia = new Uint8Array(ab);
for (let i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}

Expand All @@ -53,7 +53,7 @@ function dataURItoBlob (dataURI) {
*/
function CameraUI () {
// Root element for preview
var container = document.createElement('div');
const container = document.createElement('div');
container.style.cssText =
'left: 0px; top: 0px; width: 100%; height: 100%; position: fixed; z-index:9999;' +
'padding: 40px; background-color: rgba(0,0,0,0.75);' +
Expand All @@ -71,7 +71,7 @@ function CameraUI () {
document.body.appendChild(container);

// Create fullscreen preview
var preview = document.getElementById('capturePreview');
const preview = document.getElementById('capturePreview');
preview.autoplay = true;
// We'll show preview only when video element content
// is fully loaded to avoid glitches
Expand All @@ -90,7 +90,7 @@ function CameraUI () {
* @param {Function} errorCB Error callback
*/
CameraUI.prototype.startPreview = function (count, successCB, errorCB) {
var that = this;
const that = this;

this.preview.onclick = function (e) {
// proceed with capture here
Expand All @@ -100,7 +100,7 @@ CameraUI.prototype.startPreview = function (count, successCB, errorCB) {
e.stopPropagation();
// Create canvas element, put video frame on it
// and save its contant as Data URL
var canvas = document.createElement('canvas');
const canvas = document.createElement('canvas');
canvas.width = this.videoWidth;
canvas.height = this.videoHeight;
canvas.getContext('2d').drawImage(that.preview, 0, 0);
Expand Down Expand Up @@ -154,22 +154,22 @@ module.exports = {
},

captureImage: function (successCallback, errorCallback, args) {
var fail = function (code) {
const fail = function (code) {
if (errorCallback) {
errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR));
}
};

var options = args[0];
const options = args[0];

var limit = options.limit || 1;
const limit = options.limit || 1;
if (typeof limit !== 'number' || limit < 1) {
fail(CaptureError.CAPTURE_INVALID_ARGUMENT);
return;
}

// Counter for already taken images
var imagesTaken = 0;
let imagesTaken = 0;

navigator.getUserMedia =
navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
Expand All @@ -179,7 +179,7 @@ module.exports = {
return;
}

var ui = new CameraUI();
const ui = new CameraUI();
ui.startPreview(
limit,
function (data) {
Expand All @@ -189,15 +189,15 @@ module.exports = {
}

// Array of resultant MediaFiles
var mediaFiles = [];
const mediaFiles = [];

// save data to file here
window.requestFileSystem(
window.TEMPORARY,
data.length * limit,
function (fileSystem) {
// If we need to capture multiple files, then append counter to filename
var fileName = limit <= 1 ? 'image.jpg' : 'image' + imagesTaken + '.jpg';
const fileName = limit <= 1 ? 'image.jpg' : 'image' + imagesTaken + '.jpg';
fileSystem.root.getFile(
fileName,
{ create: true },
Expand Down Expand Up @@ -234,7 +234,7 @@ module.exports = {
},

getFormatData: function (successCallback, errorCallback, args) {
var img = document.createElement('img');
const img = document.createElement('img');
img.src = args[0];
img.onload = function () {
if (successCallback) {
Expand Down
Loading

0 comments on commit 3ce9948

Please sign in to comment.