CB-12895 : updated src files to use eslint format

This commit is contained in:
Audrey So 2017-07-14 14:19:05 -07:00
parent 80342b0ddd
commit 16c4325fef
8 changed files with 219 additions and 225 deletions

View File

@ -1,5 +1,3 @@
/*jshint node: true, jasmine: true */
/* /*
* *
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one

View File

@ -1,4 +1,3 @@
/*jshint node: true */
/* global Q, resolveLocalFileSystemURL, Camera, cordova */ /* global Q, resolveLocalFileSystemURL, Camera, cordova */
/* /*
* *

View File

@ -1,5 +1,3 @@
/*jshint node: true, jasmine: true */
/* /*
* *
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one

View File

@ -59,7 +59,7 @@
}, },
"devDependencies": { "devDependencies": {
"dmd-plugin-cordova-plugin": "^0.1.0", "dmd-plugin-cordova-plugin": "^0.1.0",
"eslint": "^4.2.0", "eslint": "^4.3.0",
"eslint-config-semistandard": "^11.0.0", "eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1", "eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.3.0", "eslint-plugin-import": "^2.3.0",

View File

@ -22,17 +22,17 @@
/* globals qnx, FileError, PluginResult */ /* globals qnx, FileError, PluginResult */
var PictureSourceType = { var PictureSourceType = {
PHOTOLIBRARY: 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android) PHOTOLIBRARY: 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
CAMERA: 1, // Take picture from camera CAMERA: 1, // Take picture from camera
SAVEDPHOTOALBUM: 2 // Choose image from picture library (same as PHOTOLIBRARY for Android) SAVEDPHOTOALBUM: 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
}, };
DestinationType = { var DestinationType = {
DATA_URL: 0, // Return base64 encoded string DATA_URL: 0, // Return base64 encoded string
FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android) FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android)
NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS) NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS)
}, };
savePath = window.qnx.webplatform.getApplication().getEnv('HOME').replace('/data', '') + '/shared/camera/', var savePath = window.qnx.webplatform.getApplication().getEnv('HOME').replace('/data', '') + '/shared/camera/';
invokeAvailable = true; var invokeAvailable = true;
// check for camera card - it isn't currently availble in work perimeter // check for camera card - it isn't currently availble in work perimeter
window.qnx.webplatform.getApplication().invocation.queryTargets( window.qnx.webplatform.getApplication().invocation.queryTargets(
@ -54,7 +54,7 @@ function showCameraDialog (done, cancel, fail) {
wv.allowQnxObject = true; wv.allowQnxObject = true;
wv.allowRpc = true; wv.allowRpc = true;
wv.zOrder = 1; wv.zOrder = 1;
wv.setGeometry(0, 0, screen.width, screen.height); wv.setGeometry(0, 0, screen.width, screen.height); /* eslint no-undef : 0 */
wv.backgroundColor = 0x00000000; wv.backgroundColor = 0x00000000;
wv.active = true; wv.active = true;
wv.visible = true; wv.visible = true;
@ -71,7 +71,7 @@ function showCameraDialog (done, cancel, fail) {
} else { } else {
saveImage(args[1], done, fail); saveImage(args[1], done, fail);
} }
wv.un('JavaScriptCallback', arguments.callee); wv.un('JavaScriptCallback', arguments.callee); /* eslint no-caller : 0 */
wv.visible = false; wv.visible = false;
wv.destroy(); wv.destroy();
qnx.webplatform.getApplication().unlockRotation(); qnx.webplatform.getApplication().unlockRotation();
@ -87,19 +87,19 @@ function showCameraDialog (done, cancel, fail) {
// create unique name for saved file (same pattern as BB10 camera app) // create unique name for saved file (same pattern as BB10 camera app)
function imgName () { function imgName () {
var date = new Date(), var date = new Date();
pad = function (n) { return n < 10 ? '0' + n : n; }; var pad = function (n) { return n < 10 ? '0' + n : n; };
return 'IMG_' + date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + '_' + return 'IMG_' + date.getFullYear() + pad(date.getMonth() + 1) + pad(date.getDate()) + '_' +
pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png'; pad(date.getHours()) + pad(date.getMinutes()) + pad(date.getSeconds()) + '.png';
} }
// convert dataURI to Blob // convert dataURI to Blob
function dataURItoBlob (dataURI) { function dataURItoBlob (dataURI) {
var byteString = atob(dataURI.split(',')[1]), var byteString = atob(dataURI.split(',')[1]);
mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0], var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
arrayBuffer = new ArrayBuffer(byteString.length), var arrayBuffer = new ArrayBuffer(byteString.length);
ia = new Uint8Array(arrayBuffer), var ia = new Uint8Array(arrayBuffer);
i; var i;
for (i = 0; i < byteString.length; i++) { for (i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i); ia[i] = byteString.charCodeAt(i);
} }
@ -124,85 +124,85 @@ function saveImage (data, success, fail) {
} }
function encodeBase64 (filePath, callback) { function encodeBase64 (filePath, callback) {
var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox; // save original sandbox value
errorHandler = function (err) { var errorHandler = function (err) {
var msg = 'An error occured: '; var msg = 'An error occured: ';
switch (err.code) { switch (err.code) {
case FileError.NOT_FOUND_ERR: case FileError.NOT_FOUND_ERR:
msg += 'File or directory not found'; msg += 'File or directory not found';
break; break;
case FileError.NOT_READABLE_ERR: case FileError.NOT_READABLE_ERR:
msg += 'File or directory not readable'; msg += 'File or directory not readable';
break; break;
case FileError.PATH_EXISTS_ERR: case FileError.PATH_EXISTS_ERR:
msg += 'File or directory already exists'; msg += 'File or directory already exists';
break; break;
case FileError.TYPE_MISMATCH_ERR: case FileError.TYPE_MISMATCH_ERR:
msg += 'Invalid file type'; msg += 'Invalid file type';
break; break;
default: default:
msg += 'Unknown Error'; msg += 'Unknown Error';
break; break;
} }
// set it back to original value // set it back to original value
window.qnx.webplatform.getController().setFileSystemSandbox = sandbox; window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
callback(msg); callback(msg);
}, };
gotFile = function (fileEntry) { var gotFile = function (fileEntry) {
fileEntry.file(function (file) { fileEntry.file(function (file) {
var reader = new FileReader(); var reader = new FileReader();
reader.onloadend = function (e) { reader.onloadend = function (e) {
// set it back to original value // set it back to original value
window.qnx.webplatform.getController().setFileSystemSandbox = sandbox; window.qnx.webplatform.getController().setFileSystemSandbox = sandbox;
callback(this.result); callback(this.result);
}; };
reader.readAsDataURL(file); reader.readAsDataURL(file);
}, errorHandler); }, errorHandler);
}, };
onInitFs = function (fs) { var onInitFs = function (fs) {
window.qnx.webplatform.getController().setFileSystemSandbox = false; window.qnx.webplatform.getController().setFileSystemSandbox = false;
fs.root.getFile(filePath, {create: false}, gotFile, errorHandler); fs.root.getFile(filePath, {create: false}, gotFile, errorHandler);
}; };
window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max
} }
module.exports = { module.exports = {
takePicture: function (success, fail, args, env) { takePicture: function (success, fail, args, env) {
var destinationType = JSON.parse(decodeURIComponent(args[1])), var destinationType = JSON.parse(decodeURIComponent(args[1]));
sourceType = JSON.parse(decodeURIComponent(args[2])), var sourceType = JSON.parse(decodeURIComponent(args[2]));
result = new PluginResult(args, env), var result = new PluginResult(args, env);
done = function (data) { var done = function (data) {
if (destinationType === DestinationType.FILE_URI) { if (destinationType === DestinationType.FILE_URI) {
data = 'file://' + data; data = 'file://' + data;
result.callbackOk(data, false); result.callbackOk(data, false);
} else { } else {
encodeBase64(data, function (data) { encodeBase64(data, function (data) {
if (/^data:/.test(data)) { if (/^data:/.test(data)) {
data = data.slice(data.indexOf(',') + 1); data = data.slice(data.indexOf(',') + 1);
result.callbackOk(data, false); result.callbackOk(data, false);
} else { } else {
result.callbackError(data, false); result.callbackError(data, false);
} }
}); });
} }
}, };
cancel = function (reason) { var cancel = function (reason) {
result.callbackError(reason, false); result.callbackError(reason, false);
}, };
invoked = function (error) { var invoked = function (error) {
if (error) { if (error) {
result.callbackError(error, false); result.callbackError(error, false);
} }
}; };
switch (sourceType) { switch (sourceType) {
case PictureSourceType.CAMERA: case PictureSourceType.CAMERA:

View File

@ -33,7 +33,7 @@ function takePicture (success, error, opts) {
input.name = 'files[]'; input.name = 'files[]';
input.onchange = function (inputEvent) { input.onchange = function (inputEvent) {
var reader = new FileReader(); var reader = new FileReader(); /* eslint no-undef : 0 */
reader.onload = function (readerEvent) { reader.onload = function (readerEvent) {
input.parentNode.removeChild(input); input.parentNode.removeChild(input);
@ -54,8 +54,8 @@ function capture (success, errorCallback, opts) {
var targetWidth = opts[3]; var targetWidth = opts[3];
var targetHeight = opts[4]; var targetHeight = opts[4];
targetWidth = targetWidth == -1 ? 320 : targetWidth; targetWidth = targetWidth === -1 ? 320 : targetWidth;
targetHeight = targetHeight == -1 ? 240 : targetHeight; targetHeight = targetHeight === -1 ? 240 : targetHeight;
var video = document.createElement('video'); var video = document.createElement('video');
var button = document.createElement('button'); var button = document.createElement('button');

View File

@ -19,7 +19,6 @@
* *
*/ */
/* jshint unused:true, undef:true, browser:true */
/* global Windows:true, URL:true, module:true, require:true, WinJS:true */ /* global Windows:true, URL:true, module:true, require:true, WinJS:true */
var Camera = require('./Camera'); var Camera = require('./Camera');
@ -56,7 +55,7 @@ module.exports = {
takePicture: function (successCallback, errorCallback, args) { takePicture: function (successCallback, errorCallback, args) {
var sourceType = args[2]; var sourceType = args[2];
if (sourceType != Camera.PictureSourceType.CAMERA) { if (sourceType !== Camera.PictureSourceType.CAMERA) {
takePictureFromFile(successCallback, errorCallback, args); takePictureFromFile(successCallback, errorCallback, args);
} else { } else {
takePictureFromCamera(successCallback, errorCallback, args); takePictureFromCamera(successCallback, errorCallback, args);
@ -79,7 +78,7 @@ function resizeImage (successCallback, errorCallback, file, targetWidth, targetH
var tempPhotoFileName = ''; var tempPhotoFileName = '';
var targetContentType = ''; var targetContentType = '';
if (encodingType == Camera.EncodingType.PNG) { if (encodingType === Camera.EncodingType.PNG) {
tempPhotoFileName = 'camera_cordova_temp_return.png'; tempPhotoFileName = 'camera_cordova_temp_return.png';
targetContentType = 'image/png'; targetContentType = 'image/png';
} else { } else {
@ -95,7 +94,7 @@ function resizeImage (successCallback, errorCallback, file, targetWidth, targetH
.then(function (buffer) { .then(function (buffer) {
var strBase64 = encodeToBase64String(buffer); var strBase64 = encodeToBase64String(buffer);
var imageData = 'data:' + file.contentType + ';base64,' + strBase64; var imageData = 'data:' + file.contentType + ';base64,' + strBase64;
var image = new Image(); var image = new Image(); /* eslint no-undef : 0 */
image.src = imageData; image.src = imageData;
image.onload = function () { image.onload = function () {
var ratio = Math.min(targetWidth / this.width, targetHeight / this.height); var ratio = Math.min(targetWidth / this.width, targetHeight / this.height);
@ -127,8 +126,7 @@ function resizeImage (successCallback, errorCallback, file, targetWidth, targetH
}) })
.done(null, function (err) { .done(null, function (err) {
errorCallback(err); errorCallback(err);
} });
);
} }
// Because of asynchronous method, so let the successCallback be called in it. // Because of asynchronous method, so let the successCallback be called in it.
@ -137,7 +135,7 @@ function resizeImageBase64 (successCallback, errorCallback, file, targetWidth, t
var strBase64 = encodeToBase64String(buffer); var strBase64 = encodeToBase64String(buffer);
var imageData = 'data:' + file.contentType + ';base64,' + strBase64; var imageData = 'data:' + file.contentType + ';base64,' + strBase64;
var image = new Image(); var image = new Image(); /* eslint no-undef : 0 */
image.src = imageData; image.src = imageData;
image.onload = function () { image.onload = function () {
@ -173,11 +171,11 @@ function takePictureFromFile (successCallback, errorCallback, args) {
} }
function takePictureFromFileWP (successCallback, errorCallback, args) { function takePictureFromFileWP (successCallback, errorCallback, args) {
var mediaType = args[6], var mediaType = args[6];
destinationType = args[1], var destinationType = args[1];
targetWidth = args[3], var targetWidth = args[3];
targetHeight = args[4], var targetHeight = args[4];
encodingType = args[5]; var encodingType = args[5];
/* /*
Need to add and remove an event listener to catch activation state Need to add and remove an event listener to catch activation state
@ -192,13 +190,13 @@ function takePictureFromFileWP (successCallback, errorCallback, args) {
webUIApp.removeEventListener('activated', filePickerActivationHandler); webUIApp.removeEventListener('activated', filePickerActivationHandler);
return; return;
} }
if (destinationType == Camera.DestinationType.FILE_URI || destinationType == Camera.DestinationType.NATIVE_URI) { if (destinationType === Camera.DestinationType.FILE_URI || destinationType === Camera.DestinationType.NATIVE_URI) {
if (targetHeight > 0 && targetWidth > 0) { if (targetHeight > 0 && targetWidth > 0) {
resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType); resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType);
} else { } else {
var storageFolder = getAppData().localFolder; var storageFolder = getAppData().localFolder;
file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function (storageFile) { file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function (storageFile) {
if (destinationType == Camera.DestinationType.NATIVE_URI) { if (destinationType === Camera.DestinationType.NATIVE_URI) {
successCallback('ms-appdata:///local/' + storageFile.name); successCallback('ms-appdata:///local/' + storageFile.name);
} else { } else {
successCallback(URL.createObjectURL(storageFile)); successCallback(URL.createObjectURL(storageFile));
@ -222,10 +220,10 @@ function takePictureFromFileWP (successCallback, errorCallback, args) {
}; };
var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker(); var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
if (mediaType == Camera.MediaType.PICTURE) { if (mediaType === Camera.MediaType.PICTURE) {
fileOpenPicker.fileTypeFilter.replaceAll(['.png', '.jpg', '.jpeg']); fileOpenPicker.fileTypeFilter.replaceAll(['.png', '.jpg', '.jpeg']);
fileOpenPicker.suggestedStartLocation = pickerLocId.picturesLibrary; fileOpenPicker.suggestedStartLocation = pickerLocId.picturesLibrary;
} else if (mediaType == Camera.MediaType.VIDEO) { } else if (mediaType === Camera.MediaType.VIDEO) {
fileOpenPicker.fileTypeFilter.replaceAll(windowsPhoneVideoContainers); fileOpenPicker.fileTypeFilter.replaceAll(windowsPhoneVideoContainers);
fileOpenPicker.suggestedStartLocation = pickerLocId.videosLibrary; fileOpenPicker.suggestedStartLocation = pickerLocId.videosLibrary;
} else { } else {
@ -238,17 +236,17 @@ function takePictureFromFileWP (successCallback, errorCallback, args) {
} }
function takePictureFromFileWindows (successCallback, errorCallback, args) { function takePictureFromFileWindows (successCallback, errorCallback, args) {
var mediaType = args[6], var mediaType = args[6];
destinationType = args[1], var destinationType = args[1];
targetWidth = args[3], var targetWidth = args[3];
targetHeight = args[4], var targetHeight = args[4];
encodingType = args[5]; var encodingType = args[5];
var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker(); var fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
if (mediaType == Camera.MediaType.PICTURE) { if (mediaType === Camera.MediaType.PICTURE) {
fileOpenPicker.fileTypeFilter.replaceAll(['.png', '.jpg', '.jpeg']); fileOpenPicker.fileTypeFilter.replaceAll(['.png', '.jpg', '.jpeg']);
fileOpenPicker.suggestedStartLocation = pickerLocId.picturesLibrary; fileOpenPicker.suggestedStartLocation = pickerLocId.picturesLibrary;
} else if (mediaType == Camera.MediaType.VIDEO) { } else if (mediaType === Camera.MediaType.VIDEO) {
fileOpenPicker.fileTypeFilter.replaceAll(windowsVideoContainers); fileOpenPicker.fileTypeFilter.replaceAll(windowsVideoContainers);
fileOpenPicker.suggestedStartLocation = pickerLocId.videosLibrary; fileOpenPicker.suggestedStartLocation = pickerLocId.videosLibrary;
} else { } else {
@ -261,13 +259,13 @@ function takePictureFromFileWindows (successCallback, errorCallback, args) {
errorCallback("User didn't choose a file."); errorCallback("User didn't choose a file.");
return; return;
} }
if (destinationType == Camera.DestinationType.FILE_URI || destinationType == Camera.DestinationType.NATIVE_URI) { if (destinationType === Camera.DestinationType.FILE_URI || destinationType === Camera.DestinationType.NATIVE_URI) {
if (targetHeight > 0 && targetWidth > 0) { if (targetHeight > 0 && targetWidth > 0) {
resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType); resizeImage(successCallback, errorCallback, file, targetWidth, targetHeight, encodingType);
} else { } else {
var storageFolder = getAppData().localFolder; var storageFolder = getAppData().localFolder;
file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function (storageFile) { file.copyAsync(storageFolder, file.name, Windows.Storage.NameCollisionOption.replaceExisting).done(function (storageFile) {
if (destinationType == Camera.DestinationType.NATIVE_URI) { if (destinationType === Camera.DestinationType.NATIVE_URI) {
successCallback('ms-appdata:///local/' + storageFile.name); successCallback('ms-appdata:///local/' + storageFile.name);
} else { } else {
successCallback(URL.createObjectURL(storageFile)); successCallback(URL.createObjectURL(storageFile));
@ -303,19 +301,19 @@ function takePictureFromCamera (successCallback, errorCallback, args) {
function takePictureFromCameraWP (successCallback, errorCallback, args) { function takePictureFromCameraWP (successCallback, errorCallback, args) {
// We are running on WP8.1 which lacks CameraCaptureUI class // We are running on WP8.1 which lacks CameraCaptureUI class
// so we need to use MediaCapture class instead and implement custom UI for camera // so we need to use MediaCapture class instead and implement custom UI for camera
var destinationType = args[1], var destinationType = args[1];
targetWidth = args[3], var targetWidth = args[3];
targetHeight = args[4], var targetHeight = args[4];
encodingType = args[5], var encodingType = args[5];
saveToPhotoAlbum = args[9], var saveToPhotoAlbum = args[9];
cameraDirection = args[11], var cameraDirection = args[11];
capturePreview = null, var capturePreview = null;
cameraCaptureButton = null, var cameraCaptureButton = null;
cameraCancelButton = null, var cameraCancelButton = null;
capture = null, var capture = null;
captureSettings = null, var captureSettings = null;
CaptureNS = Windows.Media.Capture, var CaptureNS = Windows.Media.Capture;
sensor = null; var sensor = null;
function createCameraUI () { function createCameraUI () {
// create style for take and cancel buttons // create style for take and cancel buttons
@ -367,7 +365,7 @@ function takePictureFromCameraWP (successCallback, errorCallback, args) {
} }
devices.forEach(function (currDev) { devices.forEach(function (currDev) {
if (currDev.enclosureLocation.panel && currDev.enclosureLocation.panel == expectedPanel) { if (currDev.enclosureLocation.panel && currDev.enclosureLocation.panel === expectedPanel) {
captureSettings.videoDeviceId = currDev.id; captureSettings.videoDeviceId = currDev.id;
} }
}); });
@ -480,11 +478,11 @@ function takePictureFromCameraWP (successCallback, errorCallback, args) {
function captureAction () { function captureAction () {
var encodingProperties, var encodingProperties;
fileName, var fileName;
tempFolder = getAppData().temporaryFolder; var tempFolder = getAppData().temporaryFolder;
if (encodingType == Camera.EncodingType.PNG) { if (encodingType === Camera.EncodingType.PNG) {
fileName = 'photo.png'; fileName = 'photo.png';
encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createPng(); encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createPng();
} else { } else {
@ -656,22 +654,22 @@ function takePictureFromCameraWP (successCallback, errorCallback, args) {
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaprotation.aspx // https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.imaging.bitmaprotation.aspx
switch (orientation) { switch (orientation) {
// portrait // portrait
case Windows.Devices.Sensors.SimpleOrientation.notRotated: case Windows.Devices.Sensors.SimpleOrientation.notRotated:
return Windows.Media.Capture.VideoRotation.clockwise90Degrees; return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
// landscape // landscape
case Windows.Devices.Sensors.SimpleOrientation.rotated90DegreesCounterclockwise: case Windows.Devices.Sensors.SimpleOrientation.rotated90DegreesCounterclockwise:
return Windows.Media.Capture.VideoRotation.none; return Windows.Media.Capture.VideoRotation.none;
// portrait-flipped (not supported by WinPhone Apps) // portrait-flipped (not supported by WinPhone Apps)
case Windows.Devices.Sensors.SimpleOrientation.rotated180DegreesCounterclockwise: case Windows.Devices.Sensors.SimpleOrientation.rotated180DegreesCounterclockwise:
// Falling back to portrait default // Falling back to portrait default
return Windows.Media.Capture.VideoRotation.clockwise90Degrees; return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
// landscape-flipped // landscape-flipped
case Windows.Devices.Sensors.SimpleOrientation.rotated270DegreesCounterclockwise: case Windows.Devices.Sensors.SimpleOrientation.rotated270DegreesCounterclockwise:
return Windows.Media.Capture.VideoRotation.clockwise180Degrees; return Windows.Media.Capture.VideoRotation.clockwise180Degrees;
// faceup & facedown // faceup & facedown
default: default:
// Falling back to portrait default // Falling back to portrait default
return Windows.Media.Capture.VideoRotation.clockwise90Degrees; return Windows.Media.Capture.VideoRotation.clockwise90Degrees;
} }
} }
@ -693,18 +691,18 @@ function takePictureFromCameraWP (successCallback, errorCallback, args) {
} }
function takePictureFromCameraWindows (successCallback, errorCallback, args) { function takePictureFromCameraWindows (successCallback, errorCallback, args) {
var destinationType = args[1], var destinationType = args[1];
targetWidth = args[3], var targetWidth = args[3];
targetHeight = args[4], var targetHeight = args[4];
encodingType = args[5], var encodingType = args[5];
allowCrop = !!args[7], var allowCrop = !!args[7];
saveToPhotoAlbum = args[9], var saveToPhotoAlbum = args[9];
WMCapture = Windows.Media.Capture, var WMCapture = Windows.Media.Capture;
cameraCaptureUI = new WMCapture.CameraCaptureUI(); var cameraCaptureUI = new WMCapture.CameraCaptureUI();
cameraCaptureUI.photoSettings.allowCropping = allowCrop; cameraCaptureUI.photoSettings.allowCropping = allowCrop;
if (encodingType == Camera.EncodingType.PNG) { if (encodingType === Camera.EncodingType.PNG) {
cameraCaptureUI.photoSettings.format = WMCapture.CameraCaptureUIPhotoFormat.png; cameraCaptureUI.photoSettings.format = WMCapture.CameraCaptureUIPhotoFormat.png;
} else { } else {
cameraCaptureUI.photoSettings.format = WMCapture.CameraCaptureUIPhotoFormat.jpeg; cameraCaptureUI.photoSettings.format = WMCapture.CameraCaptureUIPhotoFormat.jpeg;
@ -715,14 +713,13 @@ function takePictureFromCameraWindows (successCallback, errorCallback, args) {
var UIMaxRes = WMCapture.CameraCaptureUIMaxPhotoResolution; var UIMaxRes = WMCapture.CameraCaptureUIMaxPhotoResolution;
var totalPixels = targetWidth * targetHeight; var totalPixels = targetWidth * targetHeight;
if (targetWidth == -1 && targetHeight == -1) { if (targetWidth === -1 && targetHeight === -1) {
maxRes = UIMaxRes.highestAvailable; maxRes = UIMaxRes.highestAvailable;
}
// Temp fix for CB-10539 // Temp fix for CB-10539
/* else if (totalPixels <= 320 * 240) { /* else if (totalPixels <= 320 * 240) {
maxRes = UIMaxRes.verySmallQvga; maxRes = UIMaxRes.verySmallQvga;
} */ } */
else if (totalPixels <= 640 * 480) { } else if (totalPixels <= 640 * 480) {
maxRes = UIMaxRes.smallVga; maxRes = UIMaxRes.smallVga;
} else if (totalPixels <= 1024 * 768) { } else if (totalPixels <= 1024 * 768) {
maxRes = UIMaxRes.mediumXga; maxRes = UIMaxRes.mediumXga;
@ -784,7 +781,7 @@ function takePictureFromCameraWindows (successCallback, errorCallback, args) {
function savePhoto (picture, options, successCallback, errorCallback) { function savePhoto (picture, options, successCallback, errorCallback) {
// success callback for capture operation // success callback for capture operation
var success = function (picture) { var success = function (picture) {
if (options.destinationType == Camera.DestinationType.FILE_URI || options.destinationType == Camera.DestinationType.NATIVE_URI) { if (options.destinationType === Camera.DestinationType.FILE_URI || options.destinationType === Camera.DestinationType.NATIVE_URI) {
if (options.targetHeight > 0 && options.targetWidth > 0) { if (options.targetHeight > 0 && options.targetWidth > 0) {
resizeImage(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight, options.encodingType); resizeImage(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight, options.encodingType);
} else { } else {

View File

@ -20,26 +20,26 @@
*/ */
/* globals Camera, resolveLocalFileSystemURL, FileEntry, CameraPopoverOptions, FileTransfer, FileUploadOptions, LocalFileSystem, MSApp */ /* globals Camera, resolveLocalFileSystemURL, FileEntry, CameraPopoverOptions, FileTransfer, FileUploadOptions, LocalFileSystem, MSApp */
/* jshint jasmine: true */ /* eslint-env jasmine */
exports.defineAutoTests = function () { exports.defineAutoTests = function () {
describe('Camera (navigator.camera)', function () { describe('Camera (navigator.camera)', function () {
it("should exist", function () { it('should exist', function () {
expect(navigator.camera).toBeDefined(); expect(navigator.camera).toBeDefined();
}); });
it("should contain a getPicture function", function () { it('should contain a getPicture function', function () {
expect(navigator.camera.getPicture).toBeDefined(); expect(navigator.camera.getPicture).toBeDefined();
expect(typeof navigator.camera.getPicture == 'function').toBe(true); expect(typeof navigator.camera.getPicture === 'function').toBe(true);
}); });
}); });
describe('Camera Constants (window.Camera + navigator.camera)', function () { describe('Camera Constants (window.Camera + navigator.camera)', function () {
it("camera.spec.1 window.Camera should exist", function () { it('camera.spec.1 window.Camera should exist', function () {
expect(window.Camera).toBeDefined(); expect(window.Camera).toBeDefined();
}); });
it("camera.spec.2 should contain three DestinationType constants", function () { it('camera.spec.2 should contain three DestinationType constants', function () {
expect(Camera.DestinationType.DATA_URL).toBe(0); expect(Camera.DestinationType.DATA_URL).toBe(0);
expect(Camera.DestinationType.FILE_URI).toBe(1); expect(Camera.DestinationType.FILE_URI).toBe(1);
expect(Camera.DestinationType.NATIVE_URI).toBe(2); expect(Camera.DestinationType.NATIVE_URI).toBe(2);
@ -48,14 +48,14 @@ exports.defineAutoTests = function () {
expect(navigator.camera.DestinationType.NATIVE_URI).toBe(2); expect(navigator.camera.DestinationType.NATIVE_URI).toBe(2);
}); });
it("camera.spec.3 should contain two EncodingType constants", function () { it('camera.spec.3 should contain two EncodingType constants', function () {
expect(Camera.EncodingType.JPEG).toBe(0); expect(Camera.EncodingType.JPEG).toBe(0);
expect(Camera.EncodingType.PNG).toBe(1); expect(Camera.EncodingType.PNG).toBe(1);
expect(navigator.camera.EncodingType.JPEG).toBe(0); expect(navigator.camera.EncodingType.JPEG).toBe(0);
expect(navigator.camera.EncodingType.PNG).toBe(1); expect(navigator.camera.EncodingType.PNG).toBe(1);
}); });
it("camera.spec.4 should contain three MediaType constants", function () { it('camera.spec.4 should contain three MediaType constants', function () {
expect(Camera.MediaType.PICTURE).toBe(0); expect(Camera.MediaType.PICTURE).toBe(0);
expect(Camera.MediaType.VIDEO).toBe(1); expect(Camera.MediaType.VIDEO).toBe(1);
expect(Camera.MediaType.ALLMEDIA).toBe(2); expect(Camera.MediaType.ALLMEDIA).toBe(2);
@ -64,7 +64,7 @@ exports.defineAutoTests = function () {
expect(navigator.camera.MediaType.ALLMEDIA).toBe(2); expect(navigator.camera.MediaType.ALLMEDIA).toBe(2);
}); });
it("camera.spec.5 should contain three PictureSourceType constants", function () { it('camera.spec.5 should contain three PictureSourceType constants', function () {
expect(Camera.PictureSourceType.PHOTOLIBRARY).toBe(0); expect(Camera.PictureSourceType.PHOTOLIBRARY).toBe(0);
expect(Camera.PictureSourceType.CAMERA).toBe(1); expect(Camera.PictureSourceType.CAMERA).toBe(1);
expect(Camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); expect(Camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2);
@ -75,7 +75,6 @@ exports.defineAutoTests = function () {
}); });
}; };
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
@ -86,7 +85,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var fileEntry = null; var fileEntry = null;
var pageStartTime = +new Date(); var pageStartTime = +new Date();
//default camera options // default camera options
var camQualityDefault = ['50', 50]; var camQualityDefault = ['50', 50];
var camDestinationTypeDefault = ['FILE_URI', 1]; var camDestinationTypeDefault = ['FILE_URI', 1];
var camPictureSourceTypeDefault = ['CAMERA', 1]; var camPictureSourceTypeDefault = ['CAMERA', 1];
@ -96,12 +95,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
var camCorrectOrientationDefault = ['correctOrientation', false]; var camCorrectOrientationDefault = ['correctOrientation', false];
var camSaveToPhotoAlbumDefault = ['saveToPhotoAlbum', true]; var camSaveToPhotoAlbumDefault = ['saveToPhotoAlbum', true];
function log(value) { function log (value) {
console.log(value); console.log(value);
document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n'; document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n';
} }
function clearStatus() { function clearStatus () {
document.getElementById('camera_status').innerHTML = ''; document.getElementById('camera_status').innerHTML = '';
document.getElementById('camera_image').src = 'about:blank'; document.getElementById('camera_image').src = 'about:blank';
var canvas = document.getElementById('canvas'); var canvas = document.getElementById('canvas');
@ -111,11 +110,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
fileEntry = null; fileEntry = null;
} }
function setPicture(url, callback) { function setPicture (url, callback) {
try { try {
window.atob(url); window.atob(url);
// if we got here it is a base64 string (DATA_URL) // if we got here it is a base64 string (DATA_URL)
url = "data:image/jpeg;base64," + url; url = 'data:image/jpeg;base64,' + url;
} catch (e) { } catch (e) {
// not DATA_URL // not DATA_URL
} }
@ -134,11 +133,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
}; };
} }
function onGetPictureError(e) { function onGetPictureError (e) {
log('Error getting picture: ' + (e.code || e)); log('Error getting picture: ' + (e.code || e));
} }
function getPictureWin(data) { function getPictureWin (data) {
setPicture(data); setPicture(data);
// TODO: Fix resolveLocalFileSystemURI to work with native-uri. // TODO: Fix resolveLocalFileSystemURI to work with native-uri.
if (pictureUrl.indexOf('file:') === 0 || pictureUrl.indexOf('content:') === 0 || pictureUrl.indexOf('ms-appdata:') === 0 || pictureUrl.indexOf('assets-library:') === 0) { if (pictureUrl.indexOf('file:') === 0 || pictureUrl.indexOf('content:') === 0 || pictureUrl.indexOf('ms-appdata:') === 0 || pictureUrl.indexOf('assets-library:') === 0) {
@ -155,7 +154,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
} }
} }
function getPicture() { function getPicture () {
clearStatus(); clearStatus();
var options = extractOptions(); var options = extractOptions();
log('Getting picture with options: ' + JSON.stringify(options)); log('Getting picture with options: ' + JSON.stringify(options));
@ -168,27 +167,27 @@ exports.defineManualTests = function (contentEl, createActionButton) {
}; };
} }
function uploadImage() { function uploadImage () {
var ft = new FileTransfer(), var ft = new FileTransfer();
options = new FileUploadOptions(); var options = new FileUploadOptions();
options.fileKey = "photo"; options.fileKey = 'photo';
options.fileName = 'test.jpg'; options.fileName = 'test.jpg';
options.mimeType = "image/jpeg"; options.mimeType = 'image/jpeg';
ft.onprogress = function (progressEvent) { ft.onprogress = function (progressEvent) {
console.log('progress: ' + progressEvent.loaded + ' of ' + progressEvent.total); console.log('progress: ' + progressEvent.loaded + ' of ' + progressEvent.total);
}; };
var server = "http://sheltered-retreat-43956.herokuapp.com"; var server = 'http://sheltered-retreat-43956.herokuapp.com';
ft.upload(pictureUrl, server + '/upload', win, fail, options); ft.upload(pictureUrl, server + '/upload', win, fail, options);
function win(information_back) { function win (information_back) {
log('upload complete'); log('upload complete');
} }
function fail(message) { function fail (message) {
log('upload failed: ' + JSON.stringify(message)); log('upload failed: ' + JSON.stringify(message));
} }
} }
function logCallback(apiName, success) { function logCallback (apiName, success) {
return function () { return function () {
log('Call to ' + apiName + (success ? ' success: ' : ' failed: ') + JSON.stringify([].slice.call(arguments))); log('Call to ' + apiName + (success ? ' success: ' : ' failed: ') + JSON.stringify([].slice.call(arguments)));
}; };
@ -198,20 +197,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
* Select image from library using a NATIVE_URI destination type * Select image from library using a NATIVE_URI destination type
* This calls FileEntry.getMetadata, FileEntry.setMetadata, FileEntry.getParent, FileEntry.file, and FileReader.readAsDataURL. * This calls FileEntry.getMetadata, FileEntry.setMetadata, FileEntry.getParent, FileEntry.file, and FileReader.readAsDataURL.
*/ */
function readFile() { function readFile () {
function onFileReadAsDataURL(evt) { function onFileReadAsDataURL (evt) {
var img = document.getElementById('camera_image'); var img = document.getElementById('camera_image');
img.style.visibility = "visible"; img.style.visibility = 'visible';
img.style.display = "block"; img.style.display = 'block';
img.src = evt.target.result; img.src = evt.target.result;
log("FileReader.readAsDataURL success"); log('FileReader.readAsDataURL success');
} }
function onFileReceived(file) { function onFileReceived (file) {
log('Got file: ' + JSON.stringify(file)); log('Got file: ' + JSON.stringify(file));
fileObj = file; fileObj = file;
/* eslint-disable no-undef */
var reader = new FileReader(); var reader = new FileReader();
/* eslint-enable no-undef */
reader.onload = function () { reader.onload = function () {
log('FileReader.readAsDataURL() - length = ' + reader.result.length); log('FileReader.readAsDataURL() - length = ' + reader.result.length);
}; };
@ -228,10 +228,10 @@ exports.defineManualTests = function (contentEl, createActionButton) {
} }
} }
function getFileInfo() { function getFileInfo () {
// Test FileEntry API here. // Test FileEntry API here.
fileEntry.getMetadata(logCallback('FileEntry.getMetadata', true), logCallback('FileEntry.getMetadata', false)); fileEntry.getMetadata(logCallback('FileEntry.getMetadata', true), logCallback('FileEntry.getMetadata', false));
fileEntry.setMetadata(logCallback('FileEntry.setMetadata', true), logCallback('FileEntry.setMetadata', false), { "com.apple.MobileBackup": 1 }); fileEntry.setMetadata(logCallback('FileEntry.setMetadata', true), logCallback('FileEntry.setMetadata', false), { 'com.apple.MobileBackup': 1 });
fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false)); fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false)); fileEntry.getParent(logCallback('FileEntry.getParent', true), logCallback('FileEntry.getParent', false));
} }
@ -240,7 +240,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
* Copy image from library using a NATIVE_URI destination type * Copy image from library using a NATIVE_URI destination type
* This calls FileEntry.copyTo and FileEntry.moveTo. * This calls FileEntry.copyTo and FileEntry.moveTo.
*/ */
function copyImage() { function copyImage () {
var onFileSystemReceived = function (fileSystem) { var onFileSystemReceived = function (fileSystem) {
var destDirEntry = fileSystem.root; var destDirEntry = fileSystem.root;
var origName = fileEntry.name; var origName = fileEntry.name;
@ -249,17 +249,17 @@ exports.defineManualTests = function (contentEl, createActionButton) {
fileEntry.copyTo(destDirEntry, 'copied_file.png', logCallback('FileEntry.copyTo', true), logCallback('FileEntry.copyTo', false)); fileEntry.copyTo(destDirEntry, 'copied_file.png', logCallback('FileEntry.copyTo', true), logCallback('FileEntry.copyTo', false));
fileEntry.moveTo(destDirEntry, 'moved_file.png', logCallback('FileEntry.moveTo', true), logCallback('FileEntry.moveTo', false)); fileEntry.moveTo(destDirEntry, 'moved_file.png', logCallback('FileEntry.moveTo', true), logCallback('FileEntry.moveTo', false));
//cleanup // cleanup
//rename moved file back to original name so other tests can reference image // rename moved file back to original name so other tests can reference image
resolveLocalFileSystemURL(destDirEntry.nativeURL+'moved_file.png', function(fileEntry) { resolveLocalFileSystemURL(destDirEntry.nativeURL + 'moved_file.png', function (fileEntry) {
fileEntry.moveTo(destDirEntry, origName, logCallback('FileEntry.moveTo', true), logCallback('FileEntry.moveTo', false)); fileEntry.moveTo(destDirEntry, origName, logCallback('FileEntry.moveTo', true), logCallback('FileEntry.moveTo', false));
console.log('Cleanup: successfully renamed file back to original name'); console.log('Cleanup: successfully renamed file back to original name');
}, function () { }, function () {
console.log('Cleanup: failed to rename file back to original name'); console.log('Cleanup: failed to rename file back to original name');
}); });
//remove copied file // remove copied file
resolveLocalFileSystemURL(destDirEntry.nativeURL+'copied_file.png', function(fileEntry) { resolveLocalFileSystemURL(destDirEntry.nativeURL + 'copied_file.png', function (fileEntry) {
fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false)); fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false));
console.log('Cleanup: successfully removed copied file'); console.log('Cleanup: successfully removed copied file');
}, function () { }, function () {
@ -274,11 +274,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
* Write image to library using a NATIVE_URI destination type * Write image to library using a NATIVE_URI destination type
* This calls FileEntry.createWriter, FileWriter.write, and FileWriter.truncate. * This calls FileEntry.createWriter, FileWriter.write, and FileWriter.truncate.
*/ */
function writeImage() { function writeImage () {
var onFileWriterReceived = function (fileWriter) { var onFileWriterReceived = function (fileWriter) {
fileWriter.onwrite = logCallback('FileWriter.write', true); fileWriter.onwrite = logCallback('FileWriter.write', true);
fileWriter.onerror = logCallback('FileWriter.write', false); fileWriter.onerror = logCallback('FileWriter.write', false);
fileWriter.write("some text!"); fileWriter.write('some text!');
}; };
var onFileTruncateWriterReceived = function (fileWriter) { var onFileTruncateWriterReceived = function (fileWriter) {
@ -291,7 +291,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
fileEntry.createWriter(onFileTruncateWriterReceived, null); fileEntry.createWriter(onFileTruncateWriterReceived, null);
} }
function displayImageUsingCanvas() { function displayImageUsingCanvas () {
var canvas = document.getElementById('canvas'); var canvas = document.getElementById('canvas');
var img = document.getElementById('camera_image'); var img = document.getElementById('camera_image');
var w = img.width; var w = img.width;
@ -308,11 +308,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
* Remove image from library using a NATIVE_URI destination type * Remove image from library using a NATIVE_URI destination type
* This calls FileEntry.remove. * This calls FileEntry.remove.
*/ */
function removeImage() { function removeImage () {
fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false)); fileEntry.remove(logCallback('FileEntry.remove', true), logCallback('FileEntry.remove', false));
} }
function testInputTag(inputEl) { function testInputTag (inputEl) {
clearStatus(); clearStatus();
// iOS 6 likes to dead-lock in the onchange context if you // iOS 6 likes to dead-lock in the onchange context if you
// do any alerts or try to remote-debug. // do any alerts or try to remote-debug.
@ -321,7 +321,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
}, 0); }, 0);
} }
function testNativeFile2(inputEl) { function testNativeFile2 (inputEl) {
/* eslint-disable no-undef */
if (!inputEl.value) { if (!inputEl.value) {
alert('No file selected.'); alert('No file selected.');
return; return;
@ -331,6 +332,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
alert('Got value but no file.'); alert('Got value but no file.');
return; return;
} }
/* eslint-enable no-undef */
var URLApi = window.URL || window.webkitURL; var URLApi = window.URL || window.webkitURL;
if (URLApi) { if (URLApi) {
var blobURL = URLApi.createObjectURL(fileObj); var blobURL = URLApi.createObjectURL(fileObj);
@ -346,26 +348,26 @@ exports.defineManualTests = function (contentEl, createActionButton) {
} }
} }
function extractOptions() { function extractOptions () {
var els = document.querySelectorAll('#image-options select'); var els = document.querySelectorAll('#image-options select');
var ret = {}; var ret = {};
/*jshint -W084 */ /* eslint-disable no-cond-assign */
for (var i = 0, el; el = els[i]; ++i) { for (var i = 0, el; el = els[i]; ++i) {
var value = el.value; var value = el.value;
if (value === '') continue; if (value === '') continue;
value = +value; value = +value;
if (el.isBool) { if (el.isBool) {
ret[el.getAttribute("name")] = !!value; ret[el.getAttribute('name')] = !!value;
} else { } else {
ret[el.getAttribute("name")] = value; ret[el.getAttribute('name')] = value;
} }
} }
/*jshint +W084 */ /* eslint-enable no-cond-assign */
return ret; return ret;
} }
function createOptionsEl(name, values, selectionDefault) { function createOptionsEl (name, values, selectionDefault) {
var openDiv = '<div style="display: inline-block">' + name + ': '; var openDiv = '<div style="display: inline-block">' + name + ': ';
var select = '<select name=' + name + ' id="' + name + '">'; var select = '<select name=' + name + ' id="' + name + '">';
@ -375,13 +377,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
} }
var options = ''; var options = '';
if (typeof values == 'boolean') { if (typeof values === 'boolean') {
values = { 'true': 1, 'false': 0 }; values = { 'true': 1, 'false': 0 };
} }
for (var k in values) { for (var k in values) {
var isSelected = ''; var isSelected = '';
if (selectionDefault) { if (selectionDefault) {
if (selectionDefault[0] == k) { if (selectionDefault[0] === k) {
isSelected = 'selected'; isSelected = 'selected';
} }
} }
@ -400,8 +402,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
'<b>Status:</b> <div id="camera_status"></div>' + '<b>Status:</b> <div id="camera_status"></div>' +
'img: <img width="100" id="camera_image">' + 'img: <img width="100" id="camera_image">' +
'canvas: <canvas id="canvas" width="1" height="1"></canvas>' + 'canvas: <canvas id="canvas" width="1" height="1"></canvas>' +
'</div>', '</div>';
options_div = '<h2>Cordova Camera API Options</h2>' + var options_div = '<h2>Cordova Camera API Options</h2>' +
'<div id="image-options">' + '<div id="image-options">' +
createOptionsEl('sourceType', Camera.PictureSourceType, camPictureSourceTypeDefault) + createOptionsEl('sourceType', Camera.PictureSourceType, camPictureSourceTypeDefault) +
createOptionsEl('destinationType', Camera.DestinationType, camDestinationTypeDefault) + createOptionsEl('destinationType', Camera.DestinationType, camDestinationTypeDefault) +
@ -414,9 +416,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
createOptionsEl('correctOrientation', true, camCorrectOrientationDefault) + createOptionsEl('correctOrientation', true, camCorrectOrientationDefault) +
createOptionsEl('saveToPhotoAlbum', true, camSaveToPhotoAlbumDefault) + createOptionsEl('saveToPhotoAlbum', true, camSaveToPhotoAlbumDefault) +
createOptionsEl('cameraDirection', Camera.Direction) + createOptionsEl('cameraDirection', Camera.Direction) +
'</div>', '</div>';
getpicture_div = '<div id="getpicture"></div>', var getpicture_div = '<div id="getpicture"></div>';
test_procedure = '<h4>Recommended Test Procedure</h4>' + var test_procedure = '<h4>Recommended Test Procedure</h4>' +
'Options not specified should be the default value' + 'Options not specified should be the default value' +
'<br>Status box should update with image and info whenever an image is taken or selected from library' + '<br>Status box should update with image and info whenever an image is taken or selected from library' +
'</p><div style="background:#B0C4DE;border:1px solid #FFA07A;margin:15px 6px 0px;min-width:295px;max-width:97%;padding:4px 0px 2px 10px;min-height:160px;max-height:200px;overflow:auto">' + '</p><div style="background:#B0C4DE;border:1px solid #FFA07A;margin:15px 6px 0px;min-width:295px;max-width:97%;padding:4px 0px 2px 10px;min-height:160px;max-height:200px;overflow:auto">' +
@ -429,14 +431,14 @@ exports.defineManualTests = function (contentEl, createActionButton) {
'</p><li>sourceType=PHOTOLIBRARY<br>mediaType=ALLMEDIA<br>allowEdit=true<br>Should be able to select pics and videos and edit picture if selected</li>' + '</p><li>sourceType=PHOTOLIBRARY<br>mediaType=ALLMEDIA<br>allowEdit=true<br>Should be able to select pics and videos and edit picture if selected</li>' +
'</p><li>sourceType=CAMERA<br>targetWidth & targetHeight=50<br>allowEdit=false<br>Do Get File Metadata test below and take note of size<br>Repeat test but with width and height=800. Size should be significantly larger.</li>' + '</p><li>sourceType=CAMERA<br>targetWidth & targetHeight=50<br>allowEdit=false<br>Do Get File Metadata test below and take note of size<br>Repeat test but with width and height=800. Size should be significantly larger.</li>' +
'</p><li>quality=0<br>targetWidth & targetHeight=default<br>allowEdit=false<br>Do Get File Metadata test below and take note of size<br>Repeat test but with quality=80. Size should be significantly larger.</li>' + '</p><li>quality=0<br>targetWidth & targetHeight=default<br>allowEdit=false<br>Do Get File Metadata test below and take note of size<br>Repeat test but with quality=80. Size should be significantly larger.</li>' +
'</ol></div>', '</ol></div>';
inputs_div = '<h2>Native File Inputs</h2>' + var inputs_div = '<h2>Native File Inputs</h2>' +
'For the following tests, status box should update with file selected' + 'For the following tests, status box should update with file selected' +
'</p><div>input type=file <input type="file" class="testInputTag"></div>' + '</p><div>input type=file <input type="file" class="testInputTag"></div>' +
'<div>capture=camera <input type="file" accept="image/*;capture=camera" class="testInputTag"></div>' + '<div>capture=camera <input type="file" accept="image/*;capture=camera" class="testInputTag"></div>' +
'<div>capture=camcorder <input type="file" accept="video/*;capture=camcorder" class="testInputTag"></div>' + '<div>capture=camcorder <input type="file" accept="video/*;capture=camcorder" class="testInputTag"></div>' +
'<div>capture=microphone <input type="file" accept="audio/*;capture=microphone" class="testInputTag"></div>', '<div>capture=microphone <input type="file" accept="audio/*;capture=microphone" class="testInputTag"></div>';
actions_div = '<h2>Actions</h2>' + var actions_div = '<h2>Actions</h2>' +
'For the following tests, ensure that an image is set in status box' + 'For the following tests, ensure that an image is set in status box' +
'</p><div id="metadata"></div>' + '</p><div id="metadata"></div>' +
'Expected result: Get metadata about file selected.<br>Status box will show, along with the metadata, "Call to FileEntry.getMetadata success, Call to FileEntry.setMetadata success, Call to FileEntry.getParent success"' + 'Expected result: Get metadata about file selected.<br>Status box will show, along with the metadata, "Call to FileEntry.getMetadata success, Call to FileEntry.setMetadata success, Call to FileEntry.getParent success"' +
@ -456,20 +458,20 @@ exports.defineManualTests = function (contentEl, createActionButton) {
// We need to wrap this code due to Windows security restrictions // We need to wrap this code due to Windows security restrictions
// see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details // see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) { if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
MSApp.execUnsafeLocalFunction(function() { MSApp.execUnsafeLocalFunction(function () {
contentEl.innerHTML = info_div + options_div + getpicture_div + test_procedure + inputs_div + actions_div; contentEl.innerHTML = info_div + options_div + getpicture_div + test_procedure + inputs_div + actions_div;
}); });
} else { } else {
contentEl.innerHTML = info_div + options_div + getpicture_div + test_procedure + inputs_div + actions_div; contentEl.innerHTML = info_div + options_div + getpicture_div + test_procedure + inputs_div + actions_div;
} }
var elements = document.getElementsByClassName("testInputTag"); var elements = document.getElementsByClassName('testInputTag');
var listener = function (e) { var listener = function (e) {
testInputTag(e.target); testInputTag(e.target);
}; };
for (var i = 0; i < elements.length; ++i) { for (var i = 0; i < elements.length; ++i) {
var item = elements[i]; var item = elements[i];
item.addEventListener("change", listener, false); item.addEventListener('change', listener, false);
} }
createActionButton('Get picture', function () { createActionButton('Get picture', function () {