mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Linting the JS code
This commit is contained in:
parent
29c7e12505
commit
5406d6c98f
@ -49,35 +49,33 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
|
|||||||
|
|
||||||
// Register the event listener in the proper array
|
// Register the event listener in the proper array
|
||||||
if (eventType === "batterystatus") {
|
if (eventType === "batterystatus") {
|
||||||
var pos = me._batteryListener.indexOf(handler);
|
if (me._batteryListener.indexOf(handler) === -1) {
|
||||||
if (pos === -1) {
|
me._batteryListener.push(handler);
|
||||||
me._batteryListener.push(handler);
|
|
||||||
}
|
}
|
||||||
} else if (eventType === "batterylow") {
|
} else if (eventType === "batterylow") {
|
||||||
var pos = me._lowListener.indexOf(handler);
|
if (me._lowListener.indexOf(handler) === -1) {
|
||||||
if (pos === -1) {
|
me._lowListener.push(handler);
|
||||||
me._lowListener.push(handler);
|
|
||||||
}
|
}
|
||||||
} else if (eventType === "batterycritical") {
|
} else if (eventType === "batterycritical") {
|
||||||
var pos = me._criticalListener.indexOf(handler);
|
if (me._criticalListener.indexOf(handler) === -1) {
|
||||||
if (pos === -1) {
|
me._criticalListener.push(handler);
|
||||||
me._criticalListener.push(handler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var pos = -1;
|
||||||
// Remove the event listener from the proper array
|
// Remove the event listener from the proper array
|
||||||
if (eventType === "batterystatus") {
|
if (eventType === "batterystatus") {
|
||||||
var pos = me._batteryListener.indexOf(handler);
|
pos = me._batteryListener.indexOf(handler);
|
||||||
if (pos > -1) {
|
if (pos > -1) {
|
||||||
me._batteryListener.splice(pos, 1);
|
me._batteryListener.splice(pos, 1);
|
||||||
}
|
}
|
||||||
} else if (eventType === "batterylow") {
|
} else if (eventType === "batterylow") {
|
||||||
var pos = me._lowListener.indexOf(handler);
|
pos = me._lowListener.indexOf(handler);
|
||||||
if (pos > -1) {
|
if (pos > -1) {
|
||||||
me._lowListener.splice(pos, 1);
|
me._lowListener.splice(pos, 1);
|
||||||
}
|
}
|
||||||
} else if (eventType === "batterycritical") {
|
} else if (eventType === "batterycritical") {
|
||||||
var pos = me._criticalListener.indexOf(handler);
|
pos = me._criticalListener.indexOf(handler);
|
||||||
if (pos > -1) {
|
if (pos > -1) {
|
||||||
me._criticalListener.splice(pos, 1);
|
me._criticalListener.splice(pos, 1);
|
||||||
}
|
}
|
||||||
@ -98,13 +96,14 @@ Battery.prototype.eventHandler = function(eventType, handler, add) {
|
|||||||
Battery.prototype._status = function(info) {
|
Battery.prototype._status = function(info) {
|
||||||
if (info) {
|
if (info) {
|
||||||
var me = this;
|
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
|
// Fire batterystatus event
|
||||||
PhoneGap.fireWindowEvent("batterystatus", info);
|
PhoneGap.fireWindowEvent("batterystatus", info);
|
||||||
|
|
||||||
// Fire low battery event
|
// Fire low battery event
|
||||||
if (info.level == 20 || info.level == 5) {
|
if (level === 20 || level === 5) {
|
||||||
if (info.level == 20) {
|
if (level === 20) {
|
||||||
PhoneGap.fireWindowEvent("batterylow", info);
|
PhoneGap.fireWindowEvent("batterylow", info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -112,7 +111,7 @@ Battery.prototype._status = function(info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me._level = info.level;
|
me._level = level;
|
||||||
me._isPlugged = info.isPlugged;
|
me._isPlugged = info.isPlugged;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -124,7 +124,7 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
|
|||||||
options.quality = 80;
|
options.quality = 80;
|
||||||
}
|
}
|
||||||
if (options.maxResolution === null || typeof options.maxResolution === "undefined") {
|
if (options.maxResolution === null || typeof options.maxResolution === "undefined") {
|
||||||
options.maxResolution = 0;
|
options.maxResolution = 0;
|
||||||
}
|
}
|
||||||
if (options.destinationType === null || typeof options.destinationType === "undefined") {
|
if (options.destinationType === null || typeof options.destinationType === "undefined") {
|
||||||
options.destinationType = Camera.DestinationType.DATA_URL;
|
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") {
|
if (options.targetWidth === null || typeof options.targetWidth === "undefined") {
|
||||||
options.targetWidth = -1;
|
options.targetWidth = -1;
|
||||||
}
|
}
|
||||||
else if (typeof options.targetWidth == "string") {
|
else if (typeof options.targetWidth === "string") {
|
||||||
var width = new Number(options.targetWidth);
|
var width = new Number(options.targetWidth);
|
||||||
if (isNaN(width) === false) {
|
if (isNaN(width) === false) {
|
||||||
options.targetWidth = width.valueOf();
|
options.targetWidth = width.valueOf();
|
||||||
@ -150,7 +150,7 @@ Camera.prototype.getPicture = function(successCallback, errorCallback, options)
|
|||||||
if (options.targetHeight === null || typeof options.targetHeight === "undefined") {
|
if (options.targetHeight === null || typeof options.targetHeight === "undefined") {
|
||||||
options.targetHeight = -1;
|
options.targetHeight = -1;
|
||||||
}
|
}
|
||||||
else if (typeof options.targetHeight == "string") {
|
else if (typeof options.targetHeight === "string") {
|
||||||
var height = new Number(options.targetHeight);
|
var height = new Number(options.targetHeight);
|
||||||
if (isNaN(height) === false) {
|
if (isNaN(height) === false) {
|
||||||
options.targetHeight = height.valueOf();
|
options.targetHeight = height.valueOf();
|
||||||
|
@ -192,9 +192,6 @@ var CaptureAudioOptions = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
PhoneGap.addConstructor(function(){
|
PhoneGap.addConstructor(function(){
|
||||||
if (typeof navigator.device === "undefined") {
|
|
||||||
navigator.device = window.device = new Device();
|
|
||||||
}
|
|
||||||
if (typeof navigator.device.capture === "undefined") {
|
if (typeof navigator.device.capture === "undefined") {
|
||||||
navigator.device.capture = window.device.capture = new Capture();
|
navigator.device.capture = window.device.capture = new Capture();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
if (!PhoneGap.hasResource("compass")) {
|
if (!PhoneGap.hasResource("compass")) {
|
||||||
PhoneGap.addResource("compass");
|
PhoneGap.addResource("compass");
|
||||||
|
|
||||||
CompassError = function(){
|
var CompassError = function(){
|
||||||
this.code = null;
|
this.code = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ CompassError = function(){
|
|||||||
CompassError.COMPASS_INTERNAL_ERR = 0;
|
CompassError.COMPASS_INTERNAL_ERR = 0;
|
||||||
CompassError.COMPASS_NOT_SUPPORTED = 20;
|
CompassError.COMPASS_NOT_SUPPORTED = 20;
|
||||||
|
|
||||||
CompassHeading = function() {
|
var CompassHeading = function() {
|
||||||
this.magneticHeading = null;
|
this.magneticHeading = null;
|
||||||
this.trueHeading = null;
|
this.trueHeading = null;
|
||||||
this.headingAccuracy = null;
|
this.headingAccuracy = null;
|
||||||
|
@ -385,7 +385,7 @@ FileWriter.prototype.abort = function() {
|
|||||||
this.readyState = FileWriter.DONE;
|
this.readyState = FileWriter.DONE;
|
||||||
|
|
||||||
// If write end callback
|
// If write end callback
|
||||||
if (typeof this.onwriteend == "function") {
|
if (typeof this.onwriteend === "function") {
|
||||||
this.onwriteend({"type":"writeend", "target":this});
|
this.onwriteend({"type":"writeend", "target":this});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -843,14 +843,14 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
|
|||||||
var writer = new FileWriter(filePointer);
|
var writer = new FileWriter(filePointer);
|
||||||
|
|
||||||
if (writer.fileName === null || writer.fileName === "") {
|
if (writer.fileName === null || writer.fileName === "") {
|
||||||
if (typeof errorCallback == "function") {
|
if (typeof errorCallback === "function") {
|
||||||
errorCallback({
|
errorCallback({
|
||||||
"code": FileError.INVALID_STATE_ERR
|
"code": FileError.INVALID_STATE_ERR
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof successCallback == "function") {
|
if (typeof successCallback === "function") {
|
||||||
successCallback(writer);
|
successCallback(writer);
|
||||||
}
|
}
|
||||||
}, errorCallback);
|
}, errorCallback);
|
||||||
@ -885,7 +885,7 @@ LocalFileSystem.APPLICATION = 3;
|
|||||||
*/
|
*/
|
||||||
LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallback, errorCallback) {
|
LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallback, errorCallback) {
|
||||||
if (type < 0 || type > 3) {
|
if (type < 0 || type > 3) {
|
||||||
if (typeof errorCallback == "function") {
|
if (typeof errorCallback === "function") {
|
||||||
errorCallback({
|
errorCallback({
|
||||||
"code": FileError.SYNTAX_ERR
|
"code": FileError.SYNTAX_ERR
|
||||||
});
|
});
|
||||||
@ -993,8 +993,14 @@ LocalFileSystem.prototype._castDate = function(pluginResult) {
|
|||||||
PhoneGap.addConstructor(function() {
|
PhoneGap.addConstructor(function() {
|
||||||
var pgLocalFileSystem = new LocalFileSystem();
|
var pgLocalFileSystem = new LocalFileSystem();
|
||||||
// Needed for cast methods
|
// Needed for cast methods
|
||||||
if(typeof window.localFileSystem == "undefined") window.localFileSystem = pgLocalFileSystem;
|
if (typeof window.localFileSystem === "undefined") {
|
||||||
if(typeof window.requestFileSystem == "undefined") window.requestFileSystem = pgLocalFileSystem.requestFileSystem;
|
window.localFileSystem = pgLocalFileSystem;
|
||||||
if(typeof window.resolveLocalFileSystemURI == "undefined") window.resolveLocalFileSystemURI = pgLocalFileSystem.resolveLocalFileSystemURI;
|
}
|
||||||
|
if (typeof window.requestFileSystem === "undefined") {
|
||||||
|
window.requestFileSystem = pgLocalFileSystem.requestFileSystem;
|
||||||
|
}
|
||||||
|
if (typeof window.resolveLocalFileSystemURI === "undefined") {
|
||||||
|
window.resolveLocalFileSystemURI = pgLocalFileSystem.resolveLocalFileSystemURI;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -69,7 +69,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
|
|||||||
fileKey = options.fileKey;
|
fileKey = options.fileKey;
|
||||||
fileName = options.fileName;
|
fileName = options.fileName;
|
||||||
mimeType = options.mimeType;
|
mimeType = options.mimeType;
|
||||||
if (options.chunkedMode != null || typeof options.chunkedMode != "undefined") {
|
if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
|
||||||
chunkedMode = options.chunkedMode;
|
chunkedMode = options.chunkedMode;
|
||||||
}
|
}
|
||||||
if (options.params) {
|
if (options.params) {
|
||||||
|
@ -226,7 +226,7 @@ PhoneGap.Media.onStatus = function(id, msg, value) {
|
|||||||
media.errorCallback({"code":value});
|
media.errorCallback({"code":value});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (msg == Media.MEDIA_POSITION) {
|
else if (msg === Media.MEDIA_POSITION) {
|
||||||
media._position = value;
|
media._position = value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ var Connection = function() {
|
|||||||
this.getInfo(
|
this.getInfo(
|
||||||
function(type) {
|
function(type) {
|
||||||
// Need to send events if we are on or offline
|
// 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
|
// set a timer if still offline at the end of timer send the offline event
|
||||||
me._timer = setTimeout(function(){
|
me._timer = setTimeout(function(){
|
||||||
me.type = type;
|
me.type = type;
|
||||||
@ -44,7 +44,7 @@ var Connection = function() {
|
|||||||
}, me.timeout);
|
}, me.timeout);
|
||||||
} else {
|
} else {
|
||||||
// If there is a current offline event pending clear it
|
// If there is a current offline event pending clear it
|
||||||
if (me._timer != null) {
|
if (me._timer !== null) {
|
||||||
clearTimeout(me._timer);
|
clearTimeout(me._timer);
|
||||||
me._timer = null;
|
me._timer = null;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ Connection.prototype.getInfo = function(successCallback, errorCallback) {
|
|||||||
|
|
||||||
PhoneGap.addConstructor(function() {
|
PhoneGap.addConstructor(function() {
|
||||||
if (typeof navigator.network === "undefined") {
|
if (typeof navigator.network === "undefined") {
|
||||||
navigator.network = new Object();
|
navigator.network = {};
|
||||||
}
|
}
|
||||||
if (typeof navigator.network.connection === "undefined") {
|
if (typeof navigator.network.connection === "undefined") {
|
||||||
navigator.network.connection = new Connection();
|
navigator.network.connection = new Connection();
|
||||||
|
@ -386,7 +386,7 @@ PhoneGap.m_window_addEventListener = window.addEventListener;
|
|||||||
*/
|
*/
|
||||||
PhoneGap.addWindowEventHandler = function(event, callback) {
|
PhoneGap.addWindowEventHandler = function(event, callback) {
|
||||||
PhoneGap.windowEventHandler[event] = callback;
|
PhoneGap.windowEventHandler[event] = callback;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a custom document event handler.
|
* Add a custom document event handler.
|
||||||
@ -396,7 +396,7 @@ PhoneGap.addWindowEventHandler = function(event, callback) {
|
|||||||
*/
|
*/
|
||||||
PhoneGap.addDocumentEventHandler = function(event, callback) {
|
PhoneGap.addDocumentEventHandler = function(event, callback) {
|
||||||
PhoneGap.documentEventHandler[event] = callback;
|
PhoneGap.documentEventHandler[event] = callback;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intercept adding document event listeners and handle our own
|
* Intercept adding document event listeners and handle our own
|
||||||
|
@ -428,7 +428,7 @@ PhoneGap.addConstructor(function() {
|
|||||||
else {
|
else {
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window.localStorage === "undefined") {
|
if (typeof window.localStorage === "undefined") {
|
||||||
|
@ -130,8 +130,8 @@
|
|||||||
|
|
||||||
<!-- Create uncompressed JS file -->
|
<!-- Create uncompressed JS file -->
|
||||||
<concat destfile="assets/www/phonegap-${version}.js">
|
<concat destfile="assets/www/phonegap-${version}.js">
|
||||||
<fileset dir="assets/js" includes="phonegap.js.base" />
|
<filelist dir="assets/js" files="phonegap.js.base,device.js"/>
|
||||||
<fileset dir="assets/js" includes="*.js" />
|
<fileset dir="assets/js" includes="*.js" excludes="phonegap.js.base,device.js"/>
|
||||||
</concat>
|
</concat>
|
||||||
|
|
||||||
<!-- update project files to reference phonegap-x.x.x.min.js -->
|
<!-- update project files to reference phonegap-x.x.x.min.js -->
|
||||||
|
Loading…
Reference in New Issue
Block a user