Skip to content
Permalink
Browse files
CB-10636 Add JSHint for plugins
Added Travis badge
Added node_modules to gitignore
Disabled quotmark as it is deprecated
Fixed jshint issues
  • Loading branch information
daserge committed Feb 18, 2016
1 parent 52f0b41 commit 7d35ac850642d2f2113e13a601b86875896e74ea
Showing 12 changed files with 50 additions and 20 deletions.
@@ -12,7 +12,7 @@ Thumbs.db
*.swp
*.user


node_modules



@@ -0,0 +1,15 @@
{
"browser": true
, "bitwise": true
, "undef": true
, "trailing": true
, "quotmark": false
, "indent": 4
, "unused": "vars"
, "latedef": "nofunc"
, "globals": {
"module": false,
"exports": false,
"require": false
}
}
@@ -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-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device)

# cordova-plugin-device

This plugin defines a global `device` object, which describes the device's hardware and software.
@@ -42,6 +42,13 @@
"cordova-browser",
"cordova-osx"
],
"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"
}
}
@@ -19,6 +19,8 @@
*
*/

/* global PluginResult */

function getModelName () {
var modelName = window.qnx.webplatform.device.modelName;
//Pre 10.2 (meaning Z10 or Q10)
@@ -19,7 +19,6 @@
*
*/
var browser = require('cordova/platform');
var cordova = require('cordova');

function getPlatform() {
return "browser";
@@ -36,6 +35,7 @@ function getVersion() {
function getBrowserInfo(getModel) {
var userAgent = navigator.userAgent;
var returnVal = '';
var offset;

if ((offset = userAgent.indexOf('Chrome')) !== -1) {
returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
@@ -20,8 +20,6 @@
*/
//example UA String for Firefox OS
//Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0
var firefoxos = require('cordova/platform');
var cordova = require('cordova');

//UA parsing not recommended but currently this is the only way to get the Firefox OS version
//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
@@ -20,7 +20,6 @@
*/

var tizen = require('cordova/platform');
var cordova = require('cordova');

module.exports = {
getDeviceInfo: function(success, error) {
@@ -19,8 +19,7 @@
*
*/

var cordova = require('cordova');
var exec = require('cordova/exec');
/* global Cordova */

module.exports = {
getInfo:function(win,fail,args) {
@@ -19,9 +19,11 @@
*
*/

/* global Windows, createUUID */

var ROOT_CONTAINER = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}";
var DEVICE_CLASS_KEY = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10";
var DEVICE_CLASS_KEY_NO_SEMICOLON = '{A45C254E-DF1C-4EFD-8020-67D146A850E0}10';
var DEVICE_CLASS_KEY_NO_SEMICOLON = "{A45C254E-DF1C-4EFD-8020-67D146A850E0}10";
var ROOT_CONTAINER_QUERY = "System.Devices.ContainerId:=\"" + ROOT_CONTAINER + "\"";
var HAL_DEVICE_CLASS = "4d36e966-e325-11ce-bfc1-08002be10318";
var DEVICE_DRIVER_VERSION_KEY = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3";
@@ -19,6 +19,8 @@
*
*/

/* jshint jasmine: true */

exports.defineAutoTests = function() {
describe('Device Information (window.device)', function () {
it("should exist", function() {
@@ -27,31 +29,31 @@ exports.defineAutoTests = function() {

it("should contain a platform specification that is a string", function() {
expect(window.device.platform).toBeDefined();
expect((new String(window.device.platform)).length > 0).toBe(true);
expect((String(window.device.platform)).length > 0).toBe(true);
});

it("should contain a version specification that is a string", function() {
expect(window.device.version).toBeDefined();
expect((new String(window.device.version)).length > 0).toBe(true);
expect((String(window.device.version)).length > 0).toBe(true);
});

it("should contain a UUID specification that is a string or a number", function() {
expect(window.device.uuid).toBeDefined();
if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') {
expect((new String(window.device.uuid)).length > 0).toBe(true);
expect((String(window.device.uuid)).length > 0).toBe(true);
} else {
expect(window.device.uuid > 0).toBe(true);
}
});

it("should contain a cordova specification that is a string", function() {
expect(window.device.cordova).toBeDefined();
expect((new String(window.device.cordova)).length > 0).toBe(true);
expect((String(window.device.cordova)).length > 0).toBe(true);
});

it("should depend on the presence of cordova.version string", function() {
expect(window.cordova.version).toBeDefined();
expect((new String(window.cordova.version)).length > 0).toBe(true);
expect((String(window.cordova.version)).length > 0).toBe(true);
});

it("should contain device.cordova equal to cordova.version", function() {
@@ -60,12 +62,12 @@ exports.defineAutoTests = function() {

it("should contain a model specification that is a string", function() {
expect(window.device.model).toBeDefined();
expect((new String(window.device.model)).length > 0).toBe(true);
expect((String(window.device.model)).length > 0).toBe(true);
});

it("should contain a manufacturer property that is a string", function() {
expect(window.device.manufacturer).toBeDefined();
expect((new String(window.device.manufacturer)).length > 0).toBe(true);
expect((String(window.device.manufacturer)).length > 0).toBe(true);
});

it("should contain an isVirtual property that is a boolean", function() {
@@ -75,28 +77,28 @@ exports.defineAutoTests = function() {

it("should contain a serial number specification that is a string", function() {
expect(window.device.serial).toBeDefined();
expect((new String(window.device.serial)).length > 0).toBe(true);
expect((String(window.device.serial)).length > 0).toBe(true);

});

});
};

exports.defineManualTests = function(contentEl, createActionButton) {
var logMessage = function (message, color) {
var logMessage = function (message, color) {
var log = document.getElementById('info');
var logLine = document.createElement('div');
if (color) {
logLine.style.color = color;
}
logLine.innerHTML = message;
log.appendChild(logLine);
}
};

var clearLog = function () {
var log = document.getElementById('info');
log.innerHTML = '';
}
};

var device_tests = '<h3>Press Dump Device button to get device information</h3>' +
'<div id="dump_device"></div>' +

0 comments on commit 7d35ac8

Please sign in to comment.