incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [34/50] git commit: Linting the JS code
Date Tue, 03 Jan 2012 18:57:10 GMT
Linting the JS code


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/5406d6c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/5406d6c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/5406d6c9

Branch: refs/heads/master
Commit: 5406d6c98f517ae15b20f8d4d4ff05fa498eb627
Parents: 29c7e12
Author: macdonst <simon.macdonald@gmail.com>
Authored: Tue Nov 8 06:54:15 2011 +0800
Committer: macdonst <simon.macdonald@gmail.com>
Committed: Thu Nov 17 04:38:11 2011 +0800

----------------------------------------------------------------------
 framework/assets/js/battery.js       |   31 ++++++++++++++---------------
 framework/assets/js/camera.js        |    6 ++--
 framework/assets/js/capture.js       |    3 --
 framework/assets/js/compass.js       |    4 +-
 framework/assets/js/file.js          |   22 +++++++++++++-------
 framework/assets/js/filetransfer.js  |    2 +-
 framework/assets/js/media.js         |    2 +-
 framework/assets/js/network.js       |    6 ++--
 framework/assets/js/phonegap.js.base |    4 +-
 framework/assets/js/storage.js       |    2 +-
 framework/build.xml                  |    4 +-
 11 files changed, 44 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/battery.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/battery.js b/framework/assets/js/battery.js
index 6048e40..2723c49 100755
--- a/framework/assets/js/battery.js
+++ b/framework/assets/js/battery.js
@@ -49,35 +49,33 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
         
         // Register the event listener in the proper array
         if (eventType === "batterystatus") {
-            var pos = me._batteryListener.indexOf(handler);
-            if (pos === -1) {
-            	me._batteryListener.push(handler);
+            if (me._batteryListener.indexOf(handler) === -1) {
+                me._batteryListener.push(handler);
             }
         } else if (eventType === "batterylow") {
-            var pos = me._lowListener.indexOf(handler);
-            if (pos === -1) {
-            	me._lowListener.push(handler);
+            if (me._lowListener.indexOf(handler) === -1) {
+                me._lowListener.push(handler);
             }
         } else if (eventType === "batterycritical") {
-            var pos = me._criticalListener.indexOf(handler);
-            if (pos === -1) {
-            	me._criticalListener.push(handler);
+            if (me._criticalListener.indexOf(handler) === -1) {
+                me._criticalListener.push(handler);
             }
         }
     } else {
+        var pos = -1;
         // Remove the event listener from the proper array
         if (eventType === "batterystatus") {
-            var pos = me._batteryListener.indexOf(handler);
+            pos = me._batteryListener.indexOf(handler);
             if (pos > -1) {
                 me._batteryListener.splice(pos, 1);        
             }
         } else if (eventType === "batterylow") {
-            var pos = me._lowListener.indexOf(handler);
+            pos = me._lowListener.indexOf(handler);
             if (pos > -1) {
                 me._lowListener.splice(pos, 1);        
             }
         } else if (eventType === "batterycritical") {
-            var pos = me._criticalListener.indexOf(handler);
+            pos = me._criticalListener.indexOf(handler);
             if (pos > -1) {
                 me._criticalListener.splice(pos, 1);        
             }
@@ -98,13 +96,14 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
 Battery.prototype._status = function(info) {
 	if (info) {
 		var me = this;
-		if (me._level != info.level || me._isPlugged != info.isPlugged) {
+        var level = info.level;
+		if (me._level !== level || me._isPlugged !== info.isPlugged) {
 			// Fire batterystatus event
 			PhoneGap.fireWindowEvent("batterystatus", info);
 
 			// Fire low battery event
-			if (info.level == 20 || info.level == 5) {
-				if (info.level == 20) {
+			if (level === 20 || level === 5) {
+				if (level === 20) {
 					PhoneGap.fireWindowEvent("batterylow", info);
 				}
 				else {
@@ -112,7 +111,7 @@ Battery.prototype._status = function(info) {
 				}
 			}
 		}
-		me._level = info.level;
+		me._level = level;
 		me._isPlugged = info.isPlugged;	
 	}
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/camera.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/camera.js b/framework/assets/js/camera.js
index 7278487..17af89d 100755
--- a/framework/assets/js/camera.js
+++ b/framework/assets/js/camera.js
@@ -124,7 +124,7 @@ Camera.prototype.getPicture = function(successCallback, errorCallback,
options)
         options.quality = 80;
     }
     if (options.maxResolution === null || typeof options.maxResolution === "undefined") {
-    	options.maxResolution = 0;
+        options.maxResolution = 0;
     }
     if (options.destinationType === null || typeof options.destinationType === "undefined")
{
         options.destinationType = Camera.DestinationType.DATA_URL;
@@ -141,7 +141,7 @@ Camera.prototype.getPicture = function(successCallback, errorCallback,
options)
     if (options.targetWidth === null || typeof options.targetWidth === "undefined") {
         options.targetWidth = -1;
     } 
-    else if (typeof options.targetWidth == "string") {
+    else if (typeof options.targetWidth === "string") {
         var width = new Number(options.targetWidth);
         if (isNaN(width) === false) {
             options.targetWidth = width.valueOf();
@@ -150,7 +150,7 @@ Camera.prototype.getPicture = function(successCallback, errorCallback,
options)
     if (options.targetHeight === null || typeof options.targetHeight === "undefined") {
         options.targetHeight = -1;
     } 
-    else if (typeof options.targetHeight == "string") {
+    else if (typeof options.targetHeight === "string") {
         var height = new Number(options.targetHeight);
         if (isNaN(height) === false) {
             options.targetHeight = height.valueOf();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/capture.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/capture.js b/framework/assets/js/capture.js
index a5ad35c..28ad367 100644
--- a/framework/assets/js/capture.js
+++ b/framework/assets/js/capture.js
@@ -192,9 +192,6 @@ var CaptureAudioOptions = function(){
 };
 
 PhoneGap.addConstructor(function(){
-	if (typeof navigator.device === "undefined") {
-		navigator.device = window.device = new Device();
-	}
 	if (typeof navigator.device.capture === "undefined") {
 		navigator.device.capture = window.device.capture = new Capture();
 	}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/compass.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/compass.js b/framework/assets/js/compass.js
index 06093a9..6465516 100755
--- a/framework/assets/js/compass.js
+++ b/framework/assets/js/compass.js
@@ -20,7 +20,7 @@
 if (!PhoneGap.hasResource("compass")) {
 PhoneGap.addResource("compass");
 
-CompassError = function(){
+var CompassError = function(){
     this.code = null;
 };
 
@@ -28,7 +28,7 @@ CompassError = function(){
 CompassError.COMPASS_INTERNAL_ERR = 0;
 CompassError.COMPASS_NOT_SUPPORTED = 20;
 
-CompassHeading = function() {
+var CompassHeading = function() {
     this.magneticHeading = null;
     this.trueHeading = null;
     this.headingAccuracy = null;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/file.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/file.js b/framework/assets/js/file.js
index c65f769..256aa0c 100755
--- a/framework/assets/js/file.js
+++ b/framework/assets/js/file.js
@@ -385,7 +385,7 @@ FileWriter.prototype.abort = function() {
     this.readyState = FileWriter.DONE;
 
     // If write end callback
-    if (typeof this.onwriteend == "function") {
+    if (typeof this.onwriteend === "function") {
         this.onwriteend({"type":"writeend", "target":this});
     }
 };
@@ -843,14 +843,14 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback)
{
         var writer = new FileWriter(filePointer);
     
         if (writer.fileName === null || writer.fileName === "") {
-            if (typeof errorCallback == "function") {
+            if (typeof errorCallback === "function") {
                 errorCallback({
                     "code": FileError.INVALID_STATE_ERR
                 });
             }
         }
     
-        if (typeof successCallback == "function") {
+        if (typeof successCallback === "function") {
             successCallback(writer);
         }       
     }, errorCallback);
@@ -885,7 +885,7 @@ LocalFileSystem.APPLICATION = 3;
  */
 LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallback, errorCallback)
{
     if (type < 0 || type > 3) {
-        if (typeof errorCallback == "function") {
+        if (typeof errorCallback === "function") {
             errorCallback({
                 "code": FileError.SYNTAX_ERR
             });
@@ -993,8 +993,14 @@ LocalFileSystem.prototype._castDate = function(pluginResult) {
 PhoneGap.addConstructor(function() {
     var pgLocalFileSystem = new LocalFileSystem();
     // Needed for cast methods
-    if(typeof window.localFileSystem == "undefined") window.localFileSystem  = pgLocalFileSystem;
-    if(typeof window.requestFileSystem == "undefined") window.requestFileSystem  = pgLocalFileSystem.requestFileSystem;
-    if(typeof window.resolveLocalFileSystemURI == "undefined") window.resolveLocalFileSystemURI
= pgLocalFileSystem.resolveLocalFileSystemURI;
+    if (typeof window.localFileSystem === "undefined") {
+        window.localFileSystem = pgLocalFileSystem;
+    }
+    if (typeof window.requestFileSystem === "undefined") {
+        window.requestFileSystem = pgLocalFileSystem.requestFileSystem;
+    }
+    if (typeof window.resolveLocalFileSystemURI === "undefined") {
+        window.resolveLocalFileSystemURI = pgLocalFileSystem.resolveLocalFileSystemURI;
+    }
 });
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/filetransfer.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/filetransfer.js b/framework/assets/js/filetransfer.js
index a3d794c..690cfcd 100644
--- a/framework/assets/js/filetransfer.js
+++ b/framework/assets/js/filetransfer.js
@@ -69,7 +69,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback,
erro
         fileKey = options.fileKey;
         fileName = options.fileName;
         mimeType = options.mimeType;
-        if (options.chunkedMode != null || typeof options.chunkedMode != "undefined") {
+        if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
             chunkedMode = options.chunkedMode;
         }
         if (options.params) {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/media.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/media.js b/framework/assets/js/media.js
index 5a1d9cc..1f86af7 100755
--- a/framework/assets/js/media.js
+++ b/framework/assets/js/media.js
@@ -226,7 +226,7 @@ PhoneGap.Media.onStatus = function(id, msg, value) {
             media.errorCallback({"code":value});
         }
     }
-    else if (msg == Media.MEDIA_POSITION) {
+    else if (msg === Media.MEDIA_POSITION) {
         media._position = value;
     }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/network.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/network.js b/framework/assets/js/network.js
index e3939f8..007355e 100755
--- a/framework/assets/js/network.js
+++ b/framework/assets/js/network.js
@@ -35,7 +35,7 @@ var Connection = function() {
     this.getInfo(
         function(type) {
             // Need to send events if we are on or offline
-            if (type == "none") {
+            if (type === "none") {
                 // set a timer if still offline at the end of timer send the offline event
                 me._timer = setTimeout(function(){
                     me.type = type;
@@ -44,7 +44,7 @@ var Connection = function() {
                     }, me.timeout);
             } else {
                 // If there is a current offline event pending clear it
-                if (me._timer != null) {
+                if (me._timer !== null) {
                     clearTimeout(me._timer);
                     me._timer = null;
                 }
@@ -91,7 +91,7 @@ Connection.prototype.getInfo = function(successCallback, errorCallback)
{
 
 PhoneGap.addConstructor(function() {
     if (typeof navigator.network === "undefined") {
-        navigator.network = new Object();
+        navigator.network = {};
     }
     if (typeof navigator.network.connection === "undefined") {
         navigator.network.connection = new Connection();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/phonegap.js.base
----------------------------------------------------------------------
diff --git a/framework/assets/js/phonegap.js.base b/framework/assets/js/phonegap.js.base
index 01a61a5..2d7c383 100755
--- a/framework/assets/js/phonegap.js.base
+++ b/framework/assets/js/phonegap.js.base
@@ -386,7 +386,7 @@ PhoneGap.m_window_addEventListener = window.addEventListener;
  */
 PhoneGap.addWindowEventHandler = function(event, callback) {
     PhoneGap.windowEventHandler[event] = callback;
-}
+};
 
 /**
  * Add a custom document event handler.
@@ -396,7 +396,7 @@ PhoneGap.addWindowEventHandler = function(event, callback) {
  */
 PhoneGap.addDocumentEventHandler = function(event, callback) {
     PhoneGap.documentEventHandler[event] = callback;
-}
+};
 
 /**
  * Intercept adding document event listeners and handle our own

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/assets/js/storage.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/storage.js b/framework/assets/js/storage.js
index a9e80cf..cb741a9 100755
--- a/framework/assets/js/storage.js
+++ b/framework/assets/js/storage.js
@@ -428,7 +428,7 @@ PhoneGap.addConstructor(function() {
             else {
                 return db;
             }
-        }
+        };
     }
     
     if (typeof window.localStorage === "undefined") {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5406d6c9/framework/build.xml
----------------------------------------------------------------------
diff --git a/framework/build.xml b/framework/build.xml
index 45d842a..94b0bfd 100644
--- a/framework/build.xml
+++ b/framework/build.xml
@@ -130,8 +130,8 @@
         
       <!-- Create uncompressed JS file -->
       <concat destfile="assets/www/phonegap-${version}.js">
-        <fileset dir="assets/js" includes="phonegap.js.base" />
-        <fileset dir="assets/js" includes="*.js" />
+        <filelist dir="assets/js" files="phonegap.js.base,device.js"/>
+        <fileset dir="assets/js" includes="*.js" excludes="phonegap.js.base,device.js"/>
       </concat>
 
       <!-- update project files to reference phonegap-x.x.x.min.js -->


Mime
View raw message