You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by da...@apache.org on 2016/03/02 09:57:58 UTC

cordova-plugin-media-capture git commit: CB-10636 Add JSHint for plugins

Repository: cordova-plugin-media-capture
Updated Branches:
  refs/heads/master 476067f33 -> 73928dc2d


CB-10636 Add JSHint for plugins

Added cordova-plugin-media dependency for manual tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/73928dc2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/73928dc2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/73928dc2

Branch: refs/heads/master
Commit: 73928dc2de37cc12df05dec340246518ce696e78
Parents: 476067f
Author: daserge <v-...@microsoft.com>
Authored: Mon Feb 29 19:14:01 2016 +0300
Committer: daserge <v-...@microsoft.com>
Committed: Tue Mar 1 09:54:49 2016 +0300

----------------------------------------------------------------------
 .gitignore                  |  2 +-
 .jshintrc                   | 18 ++++++++++++++++++
 .travis.yml                 |  4 ++++
 README.md                   |  2 ++
 package.json                |  9 ++++++++-
 src/blackberry10/index.js   | 10 +++++-----
 src/browser/CaptureProxy.js | 23 ++++++++++++++++-------
 src/windows/CaptureProxy.js | 37 ++++++++++++++++++-------------------
 tests/plugin.xml            |  2 ++
 tests/tests.js              |  5 ++++-
 10 files changed, 78 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 52b558e..6964ea0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ Thumbs.db
 *.swp
 *.user
 
-
+node_modules
 
 
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..9582eb7
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,18 @@
+{
+    "browser": true
+  , "devel": true
+  , "bitwise": true
+  , "undef": true
+  , "trailing": true
+  , "quotmark": false
+  , "indent": 4
+  , "unused": "vars"
+  , "latedef": "nofunc"
+  , "globals": {
+        "module": false,
+        "exports": false,
+        "require": false,
+        "cordova": true,
+        "File": true
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b9af4c5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+sudo: false
+node_js:
+  - "4.2"

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 717814f..6774f95 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,8 @@
 #         under the License.
 -->
 
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-media-capture.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-media-capture)
+
 # cordova-plugin-media-capture
 
 This plugin provides access to the device's audio, image, and video capture capabilities.

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 654abe8..47ffb9e 100644
--- a/package.json
+++ b/package.json
@@ -35,9 +35,16 @@
     "cordova-windows8",
     "cordova-windows"
   ],
+  "scripts": {
+    "test": "npm run jshint",
+    "jshint": "jshint www && jshint src && jshint tests"
+  },
   "peerDependencies": {
     "cordova-plugin-file": "^3.0.0"
   },
   "author": "Apache Software Foundation",
-  "license": "Apache-2.0"
+  "license": "Apache-2.0",
+  "devDependencies": {
+    "jshint": "^2.6.0"
+  }
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index ea78137..7ceb838 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -19,16 +19,16 @@
  *
 */
 
+/* global PluginResult */
+
 //cordova-js/lib/common/plugin/CaptureError.js
 var INTERNAL_ERROR_CODE = 0,
     APPLICATION_BUSY_ERROR_CODE = 1,
     INVALID_ARGUMENT_ERROR_CODE = 2,
-    NO_MEDIA_FILES_ERROR_CODE = 3,
-    NOT_SUPPORTED_ERROR_CODE = 20;
+    NO_MEDIA_FILES_ERROR_CODE = 3;
 
 function capture(action, options, result, webview) {
-    var noop = function () {},
-        limit = options.limit || 1,
+    var limit = options.limit || 1,
         fail = function (error) {
             result.callbackError({code: INTERNAL_ERROR_CODE});
         },
@@ -52,7 +52,7 @@ function capture(action, options, result, webview) {
             } else {
                 result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
             }
-        }
+        },
         onCancelled = function () {
             result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
         },

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/src/browser/CaptureProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/CaptureProxy.js b/src/browser/CaptureProxy.js
index 1682994..6c7cf4b 100644
--- a/src/browser/CaptureProxy.js
+++ b/src/browser/CaptureProxy.js
@@ -92,6 +92,7 @@ function CameraUI() {
  * @param  {Function} errorCB   Error callback
  */
 CameraUI.prototype.startPreview = function(count, successCB, errorCB) {
+    var that = this;
 
     this.preview.onclick = function (e) {
         // proceed with capture here
@@ -113,7 +114,6 @@ CameraUI.prototype.startPreview = function(count, successCB, errorCB) {
         errorCB(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES));
     };
 
-    var that = this;
     navigator.getUserMedia({video: true}, function (previewStream) {
         // Save video stream to be able to stop it later 
         that._previewStream = previewStream;
@@ -133,24 +133,31 @@ CameraUI.prototype.destroyPreview = function () {
     this.preview.src = null;
     this._previewStream.stop();
     this._previewStream = null;
-    this.container && document.body.removeChild(this.container);
+    if (this.container) {
+        document.body.removeChild(this.container);
+    }
 };
 
 
 module.exports = {
-
     captureAudio:function(successCallback, errorCallback) {
-        errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED));
+        if (errorCallback) {
+            errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED));
+        }
     },
 
     captureVideo:function (successCallback, errorCallback) {
-        errorCallback && errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED));
+        if (errorCallback) {
+            errorCallback(new CaptureError(CaptureError.CAPTURE_NOT_SUPPORTED));
+        }
     },
 
     captureImage:function (successCallback, errorCallback, args) {
 
         var fail = function (code) {
-            errorCallback && errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR));
+            if (errorCallback) {
+                errorCallback(new CaptureError(code || CaptureError.CAPTURE_INTERNAL_ERR));
+            }
         };
 
         var options = args[0];
@@ -217,7 +224,9 @@ module.exports = {
         var img = document.createElement('img');
         img.src = args[0];
         img.onload = function () {
-            successCallback && successCallback(new MediaFileData(null, 0, img.height, img.width, 0));
+            if (successCallback) {
+                successCallback(new MediaFileData(null, 0, img.height, img.width, 0));
+            }
         };
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/src/windows/CaptureProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/CaptureProxy.js b/src/windows/CaptureProxy.js
index 3f943f7..3b9689e 100644
--- a/src/windows/CaptureProxy.js
+++ b/src/windows/CaptureProxy.js
@@ -19,12 +19,11 @@
  *
 */
 
-/*global Windows:true */
+/* global Windows:true */
 
 var MediaFile = require('cordova-plugin-media-capture.MediaFile');
 var CaptureError = require('cordova-plugin-media-capture.CaptureError');
 var CaptureAudioOptions = require('cordova-plugin-media-capture.CaptureAudioOptions');
-var CaptureImageOptions = require('cordova-plugin-media-capture.CaptureImageOptions');
 var CaptureVideoOptions = require('cordova-plugin-media-capture.CaptureVideoOptions');
 var MediaFileData = require('cordova-plugin-media-capture.MediaFileData');
 
@@ -150,7 +149,9 @@ function MediaCaptureProxy() {
     function destroyCameraPreview() {
         capturePreview.pause();
         capturePreview.src = null;
-        previewContainer && document.body.removeChild(previewContainer);
+        if (previewContainer) {
+            document.body.removeChild(previewContainer);
+        }
         if (capture) {
             capture.stopRecordAsync();
             capture = null;
@@ -340,20 +341,19 @@ module.exports = {
     },
 
     captureImage:function (successCallback, errorCallback, args) {
-        var options = args[0];
-
         var CaptureNS = Windows.Media.Capture;
+
+        function fail(code, data) {
+            var err = new CaptureError(code);
+            err.message = data;
+            errorCallback(err);
+        }
+
         // Check if necessary API available
         if (!CaptureNS.CameraCaptureUI) {
             // We are running on WP8.1 which lacks CameraCaptureUI class
             // so we need to use MediaCapture class instead and implement custom UI for camera
 
-            function fail(code, data) {
-                var err = new CaptureError(code);
-                err.message = data;
-                errorCallback(err);
-            }
-
             var proxy = new MediaCaptureProxy();
 
             proxy.capturePhoto(function (photoFile) {
@@ -369,7 +369,6 @@ module.exports = {
             });
 
         } else {
-            var imageOptions = new CaptureImageOptions();
             var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI();
             cameraCaptureUI.photoSettings.allowCropping = true;
             cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.highestAvailable;
@@ -398,19 +397,19 @@ module.exports = {
 
     captureVideo:function (successCallback, errorCallback, args) {
         var options = args[0];
-
         var CaptureNS = Windows.Media.Capture;
+
+        function fail(code, data) {
+            var err = new CaptureError(code);
+            err.message = data;
+            errorCallback(err);
+        }
+
         // Check if necessary API available
         if (!CaptureNS.CameraCaptureUI) {
             // We are running on WP8.1 which lacks CameraCaptureUI class
             // so we need to use MediaCapture class instead and implement custom UI for camera
 
-            function fail(code, data) {
-                var err = new CaptureError(code);
-                err.message = data;
-                errorCallback(err);
-            }
-
             var proxy = new MediaCaptureProxy();
 
             proxy.captureVideo(function (videoFile) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/tests/plugin.xml
----------------------------------------------------------------------
diff --git a/tests/plugin.xml b/tests/plugin.xml
index 5c0ba77..d45600b 100644
--- a/tests/plugin.xml
+++ b/tests/plugin.xml
@@ -26,6 +26,8 @@
     <name>Cordova Media Capture Plugin Tests</name>
     <license>Apache 2.0</license>
 
+    <dependency id="cordova-plugin-media" />
+
     <js-module src="tests.js" name="tests">
     </js-module>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/73928dc2/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 28c3dd2..7336b8a 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,6 +19,10 @@
  *
 */
 
+/* jshint jasmine: true */
+/* global CaptureAudioOptions, CaptureImageOptions, CaptureVideoOptions, CaptureError */
+/* global Media, MediaFile, MediaFileData, resolveLocalFileSystemURL */
+
 exports.defineAutoTests = function () {
     describe('Capture (navigator.device.capture)', function () {
         it("capture.spec.1 should exist", function () {
@@ -118,7 +122,6 @@ exports.defineAutoTests = function () {
 /******************************************************************************/
 
 exports.defineManualTests = function (contentEl, createActionButton) {
-    var platformId = cordova.require('cordova/platform').id;
     var pageStartTime = +new Date();
 
     function log(value) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org