Skip to content
Permalink
Browse files
CB-10636 Add JSHint for plugins
  • Loading branch information
daserge committed Feb 26, 2016
1 parent aa69e1b commit d56ab5b08ac855f73025a657521c79dcb93ef617
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 48 deletions.
@@ -12,7 +12,7 @@ Thumbs.db
*.swp
*.user


node_modules



@@ -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,
"cordova": true
}
}
@@ -0,0 +1,4 @@
language: node_js
sudo: false
node_js:
- "4.2"
@@ -17,6 +17,8 @@
# under the License.
-->

[![Build Status](https://travis-ci.org/apache/cordova-plugin-geolocation.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-geolocation)

# cordova-plugin-geolocation

This plugin provides information about the device's location, such as
@@ -36,6 +36,13 @@
"cordova-windows",
"cordova-firefoxos"
],
"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"
}
}
@@ -14,6 +14,8 @@
* limitations under the License.
*/

/* global Windows, WinJS */

var PositionError = require('./PositionError');
var callbacks = {};
var locs = {};
@@ -128,11 +130,11 @@ module.exports = {
var clientId = args[0];
var highAccuracy = args[1];

onPositionChanged = function (e) {
var onPositionChanged = function (e) {
success(createResult(e.position), { keepCallback: true });
},
};

onStatusChanged = function (e) {
var onStatusChanged = function (e) {
switch (e.status) {
case Windows.Devices.Geolocation.PositionStatus.noData:
case Windows.Devices.Geolocation.PositionStatus.notAvailable:
@@ -183,7 +185,7 @@ module.exports = {
clearWatch: function (success, fail, args, env) {
var clientId = args[0];
var callback = callbacks[clientId];
var loc = locs[clientId]
var loc = locs[clientId];

if (callback && loc) {
loc.removeEventListener("positionchanged", callback.pos);
@@ -18,6 +18,10 @@
* under the License.
*
*/

/* jshint jasmine: true */
/* global WinJS, device */

exports.defineAutoTests = function () {
var fail = function (done, context, message) {
// prevents done() to be called several times
@@ -266,6 +270,40 @@ exports.defineAutoTests = function () {
exports.defineManualTests = function (contentEl, createActionButton) {
var watchLocationId = null;

/**
* Set location status
*/
function setLocationStatus(status) {
document.getElementById('location_status').innerHTML = status;
}
function setLocationDetails(p) {
var date = (new Date(p.timestamp));
document.getElementById('latitude').innerHTML = p.coords.latitude;
document.getElementById('longitude').innerHTML = p.coords.longitude;
document.getElementById('altitude').innerHTML = p.coords.altitude;
document.getElementById('accuracy').innerHTML = p.coords.accuracy;
document.getElementById('heading').innerHTML = p.coords.heading;
document.getElementById('speed').innerHTML = p.coords.speed;
document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy;
document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString();
}

/**
* Stop watching the location
*/
function stopLocation() {
var geo = navigator.geolocation;
if (!geo) {
alert('navigator.geolocation object is missing.');
return;
}
setLocationStatus("Stopped");
if (watchLocationId) {
geo.clearWatch(watchLocationId);
watchLocationId = null;
}
}

/**
* Start watching location
*/
@@ -292,22 +330,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
setLocationStatus("Running");
};

/**
* Stop watching the location
*/
var stopLocation = function () {
var geo = navigator.geolocation;
if (!geo) {
alert('navigator.geolocation object is missing.');
return;
}
setLocationStatus("Stopped");
if (watchLocationId) {
geo.clearWatch(watchLocationId);
watchLocationId = null;
}
};

/**
* Get current location
*/
@@ -340,24 +362,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {

};

/**
* Set location status
*/
var setLocationStatus = function (status) {
document.getElementById('location_status').innerHTML = status;
};
var setLocationDetails = function (p) {
var date = (new Date(p.timestamp));
document.getElementById('latitude').innerHTML = p.coords.latitude;
document.getElementById('longitude').innerHTML = p.coords.longitude;
document.getElementById('altitude').innerHTML = p.coords.altitude;
document.getElementById('accuracy').innerHTML = p.coords.accuracy;
document.getElementById('heading').innerHTML = p.coords.heading;
document.getElementById('speed').innerHTML = p.coords.speed;
document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy;
document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString();
};

/******************************************************************************/

var location_div = '<div id="info">' +
@@ -423,8 +427,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
note =
'<h3>Allow use of current location, if prompted</h3>';

contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed
+ altitude_accuracy + time + note + actions;
contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed +
altitude_accuracy + time + note + actions;

createActionButton('Get Location', function () {
getLocation();
@@ -19,13 +19,15 @@
*
*/


var exec = cordova.require('cordova/exec');
var utils = require('cordova/utils');
var PositionError = require('./PositionError');

module.exports = {
// Native watchPosition method is called async after permissions prompt.
// So we use additional map and own ids to return watch id synchronously.
var pluginToNativeWatchMap = {};

module.exports = {
getCurrentPosition: function(success, error, args) {
var win = function() {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
@@ -67,7 +69,3 @@ module.exports = {
exec(win, null, "Geolocation", "getPermission", []);
}
};

// Native watchPosition method is called async after permissions prompt.
// So we use additional map and own ids to return watch id synchronously.
var pluginToNativeWatchMap = {};

0 comments on commit d56ab5b

Please sign in to comment.