cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject cordova-plugin-dialogs git commit: CB-10636 Add JSHint for plugins
Date Mon, 29 Feb 2016 07:37:47 GMT
Repository: cordova-plugin-dialogs
Updated Branches:
  refs/heads/master cb81ad682 -> c173b511a


CB-10636 Add JSHint for plugins


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/c173b511
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/c173b511
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/c173b511

Branch: refs/heads/master
Commit: c173b511a3ef1ea906915883db309b1fbda70e2d
Parents: cb81ad6
Author: daserge <v-seshak@microsoft.com>
Authored: Fri Feb 26 19:53:20 2016 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Fri Feb 26 20:08:32 2016 +0300

----------------------------------------------------------------------
 .gitignore                       |  2 +-
 .jshintrc                        | 17 +++++++++++++++++
 .travis.yml                      |  4 ++++
 README.md                        |  2 ++
 package.json                     |  9 ++++++++-
 src/blackberry10/index.js        |  2 ++
 src/firefoxos/notification.js    |  6 +++---
 src/windows/NotificationProxy.js | 30 ++++++++++++++++++------------
 tests/tests.js                   | 21 +++++++++++++++------
 www/blackberry10/beep.js         | 32 ++++++++++++++++++--------------
 www/browser/notification.js      | 30 +++++++++++++++---------------
 11 files changed, 103 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/.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-dialogs/blob/c173b511/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..479adeb
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,17 @@
+{
+    "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,
+        "Notification": true
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/.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-dialogs/blob/c173b511/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 02eb1b2..1965044 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,8 @@
 #         under the License.
 -->
 
+[![Build Status](https://travis-ci.org/apache/cordova-plugin-dialogs.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-dialogs)
+
 # cordova-plugin-dialogs
 
 This plugin provides access to some native dialog UI elements

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index ed54d16..9b5b884 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,13 @@
     "cordova-windows8",
     "cordova-windows"
   ],
+  "scripts": {
+    "test": "npm run jshint",
+    "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint
src && node node_modules/jshint/bin/jshint tests"
+  },
   "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-dialogs/blob/c173b511/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
index 3660f66..4969a77 100644
--- a/src/blackberry10/index.js
+++ b/src/blackberry10/index.js
@@ -14,6 +14,8 @@
 * limitations under the License.
 */
 
+/* global qnx, PluginResult */
+
 function showDialog(args, dialogType, result) {
     //Unpack and map the args
     var msg = JSON.parse(decodeURIComponent(args[0])),

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/src/firefoxos/notification.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/notification.js b/src/firefoxos/notification.js
index 18bce8b..aea562d 100644
--- a/src/firefoxos/notification.js
+++ b/src/firefoxos/notification.js
@@ -84,12 +84,12 @@ function modal(message, callback, title, buttonLabels, domObjects) {
             result = {
                 input1: '',
                 buttonIndex: 0
-            }
+            };
         }
         mainWindow.setTimeout(function() {
             callback(result);
         }, 10);
-    };
+    }
     modalWindow.addEventListener('unload', onUnload, false);
 
     // call callback and destroy modal
@@ -110,7 +110,7 @@ function modal(message, callback, title, buttonLabels, domObjects) {
           }
           response = response || labelIndex;
           callback(response);
-        }
+        };
     }
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/src/windows/NotificationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/NotificationProxy.js b/src/windows/NotificationProxy.js
index a8c5987..c9c9233 100644
--- a/src/windows/NotificationProxy.js
+++ b/src/windows/NotificationProxy.js
@@ -19,7 +19,7 @@
  *
 */
 
-/*global Windows:true */
+/*global Windows:true, WinJS, toStaticHTML */
 
 var cordova = require('cordova');
 
@@ -27,7 +27,7 @@ var isAlertShowing = false;
 var alertStack = [];
 
 // CB-8928: When toStaticHTML is undefined, prompt fails to run
-function _cleanHtml(html) { return html; }
+var _cleanHtml = function(html) { return html; };
 if (typeof toStaticHTML !== 'undefined') {
     _cleanHtml = toStaticHTML;
 }
@@ -36,7 +36,7 @@ if (typeof toStaticHTML !== 'undefined') {
 // simple html-based implementation until it is available
 function createPromptDialog(title, message, buttons, defaultText, callback) {
 
-    var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone;;
+    var isPhone = cordova.platformId == "windows" && WinJS.Utilities.isPhone;
 
     var dlgWrap = document.createElement("div");
     dlgWrap.style.position = "absolute";
@@ -64,9 +64,9 @@ function createPromptDialog(title, message, buttons, defaultText, callback)
{
     }
 
     // dialog layout template
-    dlg.innerHTML = _cleanHtml("<span id='lbl-title' style='font-size: 24pt'></span><br/>"
// title
-        + "<span id='lbl-message'></span><br/>" // message
-        + "<input id='prompt-input' style='width: 100%'/><br/>"); // input fields
+    dlg.innerHTML = _cleanHtml("<span id='lbl-title' style='font-size: 24pt'></span><br/>"
+ // title
+        "<span id='lbl-message'></span><br/>" + // message
+        "<input id='prompt-input' style='width: 100%'/><br/>"); // input fields
 
     dlg.querySelector('#lbl-title').appendChild(document.createTextNode(title));
     dlg.querySelector('#lbl-message').appendChild(document.createTextNode(message));
@@ -74,13 +74,13 @@ function createPromptDialog(title, message, buttons, defaultText, callback)
{
 
     function makeButtonCallback(idx) {
         return function () {
-            var value = promptInput = dlg.querySelector('#prompt-input').value;
+            var value = dlg.querySelector('#prompt-input').value;
             dlgWrap.parentNode.removeChild(dlgWrap);
 
             if (callback) {
                 callback({ input1: value, buttonIndex: idx });
             }
-        }
+        };
     }
 
     function addButton(idx, label) {
@@ -90,7 +90,7 @@ function createPromptDialog(title, message, buttons, defaultText, callback)
{
         button.style.fontSize = "12pt";
         button.tabIndex = idx;
         button.onclick = makeButtonCallback(idx + 1);
-        if (idx == 0) {
+        if (idx === 0) {
             button.style.color = "white";
             button.style.backgroundColor = "#464646";
         } else {
@@ -135,7 +135,9 @@ module.exports = {
         md.commands.append(new Windows.UI.Popups.UICommand(_buttonLabel));
         md.showAsync().then(function() {
             isAlertShowing = false;
-            win && win();
+            if (win) {
+                win();
+            }
 
             if (alertStack.length) {
                 setTimeout(alertStack.shift(), 0);
@@ -205,7 +207,9 @@ module.exports = {
             md.showAsync().then(function(res) {
                 isAlertShowing = false;
                 var result = res ? buttons.indexOf(res.label) + 1 : 0;
-                win && win(result);
+                if (win) {
+                    win(result);
+                }
                 if (alertStack.length) {
                     setTimeout(alertStack.shift(), 0);
                 }
@@ -237,7 +241,9 @@ module.exports = {
             } else {
                 snd.removeEventListener("ended", onEvent);
                 snd = null;
-                winX && winX(); // notification.js just sends null, but this is future
friendly
+                if (winX) {
+                    winX(); // notification.js just sends null, but this is future friendly
+                }
             }
             count--;
         };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 16e9cd9..a4cf382 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -19,6 +19,9 @@
  *
 */
 
+/* jshint jasmine: true */
+/* global cordova */
+
 exports.defineAutoTests = function () {
     describe('Notification (navigator.notification)', function () {
         it("should exist", function () {
@@ -57,12 +60,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
         var logLine = document.createElement('div');
         logLine.innerHTML = message;
         log.appendChild(logLine);
-    }
+    };
 
     var clearLog = function () {
         var log = document.getElementById('info');
         log.innerHTML = '';
-    }
+    };
 
     var beep = function () {
         console.log("beep()");
@@ -118,7 +121,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
                 if (r && r.buttonIndex === 0) {
                     var msg = "Dismissed dialog";
                     if (r.input1) {
-                        msg += " with input: " + r.input1
+                        msg += " with input: " + r.input1;
                     }
                     logMessage(msg);
                     console.log(msg);
@@ -181,14 +184,20 @@ exports.defineManualTests = function (contentEl, createActionButton)
{
     }, 'prompt');
 
     createActionButton('Built-in Alert Dialog', function () {
-        typeof alert === 'function' && alert('You pressed alert');
+        if (typeof alert === 'function') {
+            alert('You pressed alert');
+        }
     }, 'built_in_alert');
 
     createActionButton('Built-in Confirm Dialog', function () {
-        typeof confirm === 'function' && confirm('You selected confirm');
+        if (typeof confirm === 'function') {
+            confirm('You selected confirm');
+        }
     }, 'built_in_confirm');
 
     createActionButton('Built-in Prompt Dialog', function () {
-        typeof prompt === 'function' && prompt('This is a prompt', 'Default value');
+        if (typeof prompt === 'function') {
+            prompt('This is a prompt', 'Default value');
+        }
     }, 'built_in_prompt');
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/www/blackberry10/beep.js
----------------------------------------------------------------------
diff --git a/www/blackberry10/beep.js b/www/blackberry10/beep.js
index 401049e..da2e75d 100644
--- a/www/blackberry10/beep.js
+++ b/www/blackberry10/beep.js
@@ -21,20 +21,24 @@
 
 module.exports = function (quantity) {
     var count = 0,
-        beepObj,
-        play = function () { 
-            //create new object every time due to strage playback behaviour
-            beepObj = new Audio('local:///chrome/plugin/cordova-plugin-dialogs/notification-beep.wav');
-            beepObj.addEventListener("ended", callback);
-            beepObj.play();
-        },
-        callback = function () {
-            if (--count > 0) {
-                play();
-            } else {
-                delete beepObj;
-            }
-        };
+    beepObj;
+
+    function callback() {
+        if (--count > 0) {
+            play();
+        } else {
+            beepObj.removeEventListener("ended", callback);
+            beepObj = null;
+        }
+    }
+
+    function play() { 
+        //create new object every time due to strage playback behaviour
+        beepObj = new Audio('local:///chrome/plugin/cordova-plugin-dialogs/notification-beep.wav');
+        beepObj.addEventListener("ended", callback);
+        beepObj.play();
+    }
+
     count += quantity || 1;
     if (count > 0) {
         play();

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/c173b511/www/browser/notification.js
----------------------------------------------------------------------
diff --git a/www/browser/notification.js b/www/browser/notification.js
index e875309..1fdfafd 100644
--- a/www/browser/notification.js
+++ b/www/browser/notification.js
@@ -65,6 +65,21 @@ module.exports.prompt = window.navigator.notification.prompt = function(message,
 };
 
 
+var audioContext = (function() {
+    // Determine if the Audio API is supported by this browser
+    var AudioApi = window.AudioContext;
+    if (!AudioApi) {
+        AudioApi = window.webkitAudioContext;
+    }
+
+    if (AudioApi) {
+        // The Audio API is supported, so create a singleton instance of the AudioContext
+        return new AudioApi();
+    }
+
+    return undefined;
+}());
+
 module.exports.beep = window.navigator.notification.beep = function(times) {
     if (times > 0) {
         var BEEP_DURATION = 700;
@@ -98,18 +113,3 @@ module.exports.beep = window.navigator.notification.beep = function(times)
{
         }
     }
 };
-
-var audioContext = (function() {
-    // Determine if the Audio API is supported by this browser
-    var AudioApi = window.AudioContext;
-    if (!AudioApi) {
-        AudioApi = window.webkitAudioContext;
-    }
-
-    if (AudioApi) {
-        // The Audio API is supported, so create a singleton instance of the AudioContext
-        return new AudioApi();
-    }
-
-    return undefined;
-}());


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


Mime
View raw message