cordova-plugin-vibration
Advanced tools
Comparing version
{ | ||
"name": "cordova-plugin-vibration", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "Cordova Vibration Plugin", | ||
@@ -24,2 +24,5 @@ "types": "./types/index.d.ts", | ||
}, | ||
"bugs": { | ||
"url": "https://issues.apache.org/jira/browse/CB" | ||
}, | ||
"keywords": [ | ||
@@ -40,4 +43,4 @@ "cordova", | ||
"scripts": { | ||
"test": "npm run jshint", | ||
"jshint": "jshint www && jshint src && jshint tests" | ||
"test": "npm run eslint", | ||
"eslint": "eslint www && eslint src && eslint tests" | ||
}, | ||
@@ -54,4 +57,10 @@ "author": "Apache Software Foundation", | ||
"devDependencies": { | ||
"jshint": "^2.6.0" | ||
"eslint": "^4.0.0", | ||
"eslint-config-semistandard": "^11.0.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-node": "^5.0.0", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1" | ||
} | ||
} |
@@ -24,5 +24,5 @@ --- | ||
|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI| | ||
|:-:|:-:|:-:|:-:|:-:|:-:|:-:| | ||
|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-vibration/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-vibration/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-vibration/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-vibration/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-vibration/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-vibration/)|[](https://travis-ci.org/apache/cordova-plugin-vibration)| | ||
|AppVeyor|Travis CI| | ||
|:-:|:-:| | ||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-vibration)|[](https://travis-ci.org/apache/cordova-plugin-vibration)| | ||
@@ -29,0 +29,0 @@ # cordova-plugin-vibration |
@@ -23,2 +23,6 @@ <!-- | ||
### 2.1.6 (Nov 06, 2017) | ||
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) added `eslint` and removed `jshint` | ||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`. | ||
### 2.1.5 (Apr 27, 2017) | ||
@@ -25,0 +29,0 @@ * [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badge to `README` |
@@ -28,5 +28,5 @@ /* | ||
vibrate: function (success, fail, args, env) { | ||
var result = new PluginResult(args, env), | ||
duration = args[0], | ||
response = vibration.getInstance().vibrate(duration); | ||
var result = new PluginResult(args, env); | ||
var duration = args[0]; | ||
var response = vibration.getInstance().vibrate(duration); | ||
result.ok(response, false); | ||
@@ -36,35 +36,35 @@ } | ||
/////////////////////////////////////////////////////////////////// | ||
/// //////////////////////////////////////////////////////////////// | ||
// JavaScript wrapper for JNEXT plugin | ||
/////////////////////////////////////////////////////////////////// | ||
/// //////////////////////////////////////////////////////////////// | ||
JNEXT.Vibration = function () { | ||
var self = this, | ||
hasInstance = false; | ||
var self = this; | ||
var hasInstance = false; | ||
self.vibrate = function (duration) { | ||
//This is how Javascript calls into native | ||
return JNEXT.invoke(self.m_id, "vibrate " + duration); | ||
// This is how Javascript calls into native | ||
return JNEXT.invoke(self.m_id, 'vibrate ' + duration); | ||
}; | ||
self.init = function () { | ||
//Checks that the jnext library is present and loads it | ||
if (!JNEXT.require("libVibration")) { | ||
// Checks that the jnext library is present and loads it | ||
if (!JNEXT.require('libVibration')) { | ||
return false; | ||
} | ||
//Creates the native object that this interface will call | ||
self.m_id = JNEXT.createObject("libVibration.Vibration"); | ||
// Creates the native object that this interface will call | ||
self.m_id = JNEXT.createObject('libVibration.Vibration'); | ||
if (self.m_id === "") { | ||
if (self.m_id === '') { | ||
return false; | ||
} | ||
//Registers for the JNEXT event loop | ||
// Registers for the JNEXT event loop | ||
JNEXT.registerEvents(self); | ||
}; | ||
self.m_id = ""; | ||
self.m_id = ''; | ||
//Used by JNEXT library to get the ID | ||
// Used by JNEXT library to get the ID | ||
self.getId = function () { | ||
@@ -74,3 +74,3 @@ return self.m_id; | ||
//Not truly required but useful for instance management | ||
// Not truly required but useful for instance management | ||
self.getInstance = function () { | ||
@@ -77,0 +77,0 @@ if (!hasInstance) { |
@@ -23,3 +23,3 @@ /* | ||
module.exports = { | ||
vibrate: function(success, fail, milliseconds) { | ||
vibrate: function (success, fail, milliseconds) { | ||
console.log('Vibration is not supported'); | ||
@@ -26,0 +26,0 @@ return false; |
@@ -24,7 +24,7 @@ /* | ||
vibrate: function(success, fail, milliseconds) { | ||
vibrate: function (success, fail, milliseconds) { | ||
if (navigator.notification.vibrate) { | ||
navigator.vibrate(milliseconds); | ||
} else { | ||
console.log ("cordova/plugin/firefoxos/vibration, vibrate API does not exist"); | ||
console.log('cordova/plugin/firefoxos/vibration, vibrate API does not exist'); | ||
} | ||
@@ -34,2 +34,2 @@ } | ||
require("cordova/exec/proxy").add("Vibration", module.exports); | ||
require('cordova/exec/proxy').add('Vibration', module.exports); |
@@ -23,3 +23,3 @@ /* | ||
module.exports = { | ||
vibrate: function(milliseconds) { | ||
vibrate: function (milliseconds) { | ||
if (navigator.vibrate) { | ||
@@ -31,2 +31,2 @@ navigator.vibrate(milliseconds); | ||
require("cordova/tizen/commandProxy").add("Vibration", module.exports); | ||
require('cordova/tizen/commandProxy').add('Vibration', module.exports); |
@@ -24,4 +24,4 @@ /* | ||
function checkReqs(actionName, fail) { | ||
if (!(Windows.Phone && Windows.Phone.Devices && Windows.Phone.Devices.Notification && Windows.Phone.Devices.Notification.VibrationDevice) && WinJS.Utilities.isPhone !== true) { | ||
function checkReqs (actionName, fail) { | ||
if (!(Windows.Phone && Windows.Phone.Devices && Windows.Phone.Devices.Notification && Windows.Phone.Devices.Notification.VibrationDevice) && WinJS.Utilities.isPhone !== true) { | ||
fail(actionName + ' is unsupported by this platform.'); | ||
@@ -34,3 +34,3 @@ return false; | ||
function tryDoAction(actionName, success, fail, args, action) { | ||
function tryDoAction (actionName, success, fail, args, action) { | ||
try { | ||
@@ -48,3 +48,3 @@ if (checkReqs(actionName, fail) !== true) { | ||
/** | ||
/** | ||
* @typedef patternParsingResult | ||
@@ -62,4 +62,5 @@ * @type {Object} | ||
*/ | ||
function tryParsePatternValues(pattern) { | ||
var passed = true, failedItem; | ||
function tryParsePatternValues (pattern) { | ||
var passed = true; | ||
var failedItem; | ||
@@ -83,3 +84,3 @@ pattern = pattern.map(function (item) { | ||
/** | ||
/** | ||
* @typedef checkPatternReqsResult | ||
@@ -95,6 +96,7 @@ * @type {Object} | ||
*/ | ||
function checkPatternReqs(args, fail) { | ||
function checkPatternReqs (args, fail) { | ||
var patternParsingResult = tryParsePatternValues(args[0]); | ||
var repeat = args[1]; | ||
var passed = true, errMsg = ''; | ||
var passed = true; | ||
var errMsg = ''; | ||
@@ -132,3 +134,3 @@ if (!patternParsingResult.passed) { | ||
*/ | ||
function vibratePattern(patternArr, shouldRepeat, fail, patternCycle) { | ||
function vibratePattern (patternArr, shouldRepeat, fail, patternCycle) { | ||
return patternArr.reduce(function (previousValue, currentValue, index) { | ||
@@ -173,3 +175,3 @@ if (index % 2 === 0) { | ||
module.exports = { | ||
vibrate: function(success, fail, args) { | ||
vibrate: function (success, fail, args) { | ||
try { | ||
@@ -182,7 +184,6 @@ var duration = parseInt(args[0]); | ||
success(); | ||
} | ||
catch (e) { | ||
} catch (e) { | ||
fail(e); | ||
} | ||
}, | ||
}, | ||
vibrateWithPattern: function (success, fail, args) { | ||
@@ -208,3 +209,3 @@ // Cancel current vibrations first | ||
}, | ||
cancelVibration: function(success, fail, args) { | ||
cancelVibration: function (success, fail, args) { | ||
try { | ||
@@ -218,4 +219,3 @@ if (patternChainPromise) { | ||
} | ||
} | ||
catch (e) { | ||
} catch (e) { | ||
if (fail) { | ||
@@ -227,15 +227,15 @@ fail(e); | ||
}; | ||
} else if (typeof Vibration !== 'undefined' && Vibration.Vibration) { | ||
} else if (typeof Vibration !== 'undefined' && Vibration.Vibration) { | ||
// Windows Phone 8.1 code paths | ||
module.exports = { | ||
vibrate: function (success, fail, args) { | ||
tryDoAction("vibrate", success, fail, args, Vibration.Vibration.vibrate); | ||
tryDoAction('vibrate', success, fail, args, Vibration.Vibration.vibrate); | ||
}, | ||
vibrateWithPattern: function (success, fail, args) { | ||
tryDoAction("vibrate", success, fail, [DEFAULT_DURATION], Vibration.Vibration.vibrate); | ||
tryDoAction('vibrate', success, fail, [DEFAULT_DURATION], Vibration.Vibration.vibrate); | ||
}, | ||
cancelVibration: function (success, fail, args) { | ||
tryDoAction("cancelVibration", success, fail, args, Vibration.Vibration.cancelVibration); | ||
tryDoAction('cancelVibration', success, fail, args, Vibration.Vibration.cancelVibration); | ||
} | ||
@@ -265,2 +265,2 @@ }; | ||
require("cordova/exec/proxy").add("Vibration", module.exports); | ||
require('cordova/exec/proxy').add('Vibration', module.exports); |
@@ -22,3 +22,3 @@ /* | ||
/* jshint jasmine: true */ | ||
/* eslint-env jasmine */ | ||
@@ -28,9 +28,8 @@ exports.defineAutoTests = function () { | ||
describe('Vibration (navigator.notification.vibrate)', function () { | ||
it("navigator.notification should exist with vibrate function", function () { | ||
it('navigator.notification should exist with vibrate function', function () { | ||
expect(navigator.notification).toBeDefined(); | ||
expect(typeof navigator.notification.vibrate).toBeDefined(); | ||
expect(typeof navigator.notification.vibrate).toBe("function"); | ||
expect(typeof navigator.notification.vibrate).toBe('function'); | ||
if (cordova.platformId == "browser") | ||
expect(navigator.notification.vibrate(0)).toBe(false); | ||
if (cordova.platformId === 'browser') { expect(navigator.notification.vibrate(0)).toBe(false); } // eslint-disable-line no-undef | ||
}); | ||
@@ -56,95 +55,95 @@ }); | ||
//------------------------------------------------------------------------- | ||
// ------------------------------------------------------------------------- | ||
// Vibrations | ||
//------------------------------------------------------------------------- | ||
// ------------------------------------------------------------------------- | ||
//old vibrate call | ||
var vibrateOld = function(){ | ||
// old vibrate call | ||
var vibrateOld = function () { | ||
clearLog(); | ||
navigator.notification.vibrate(2500); | ||
logMessage("navigator.notification.vibrate(2500)", "green"); | ||
logMessage('navigator.notification.vibrate(2500)', 'green'); | ||
}; | ||
//old vibrate with pattern call | ||
var vibrateWithPatternOld = function(){ | ||
// old vibrate with pattern call | ||
var vibrateWithPatternOld = function () { | ||
clearLog(); | ||
navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000]); | ||
logMessage("navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000])", "green"); | ||
logMessage('navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000])', 'green'); | ||
}; | ||
//old vibrate with pattern with repeat call | ||
var vibrateWithPatternOldWithRepeat = function(){ | ||
// old vibrate with pattern with repeat call | ||
var vibrateWithPatternOldWithRepeat = function () { | ||
clearLog(); | ||
navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000], 2); | ||
logMessage("navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000], 2)", "green"); | ||
logMessage('navigator.notification.vibrateWithPattern([1000, 3000, 2000, 5000], 2)', 'green'); | ||
}; | ||
//old cancel vibrate call | ||
var cancelOld = function(){ | ||
// old cancel vibrate call | ||
var cancelOld = function () { | ||
clearLog(); | ||
navigator.notification.cancelVibration(); | ||
logMessage("navigator.notification.cancelVibration()", "green"); | ||
logMessage('navigator.notification.cancelVibration()', 'green'); | ||
}; | ||
//new standard vibrate call that aligns to w3c spec with param long | ||
var vibrateWithInt = function() { | ||
// new standard vibrate call that aligns to w3c spec with param long | ||
var vibrateWithInt = function () { | ||
clearLog(); | ||
navigator.vibrate(3000); | ||
logMessage("navigator.vibrate(3000)", "green"); | ||
logMessage('navigator.vibrate(3000)', 'green'); | ||
}; | ||
//new standard vibrate call that aligns to w3c spec with param array | ||
var vibrateWithArray = function() { | ||
// new standard vibrate call that aligns to w3c spec with param array | ||
var vibrateWithArray = function () { | ||
clearLog(); | ||
navigator.vibrate([3000]); | ||
logMessage("navigator.vibrate([3000])", "green"); | ||
logMessage('navigator.vibrate([3000])', 'green'); | ||
}; | ||
//vibrate with a pattern using w3c spec | ||
var vibrateWithPattern = function() { | ||
// vibrate with a pattern using w3c spec | ||
var vibrateWithPattern = function () { | ||
clearLog(); | ||
navigator.vibrate([1000, 2000, 3000, 2000, 5000]); | ||
logMessage("navigator.vibrate([1000, 2000, 3000, 2000, 5000])", "green"); | ||
logMessage('navigator.vibrate([1000, 2000, 3000, 2000, 5000])', 'green'); | ||
}; | ||
//cancel existing vibration using w3c spec navigator.vibrate(0) | ||
var cancelWithZero = function() { | ||
// cancel existing vibration using w3c spec navigator.vibrate(0) | ||
var cancelWithZero = function () { | ||
clearLog(); | ||
navigator.vibrate(0); | ||
logMessage("navigator.vibrate(0)", "green"); | ||
logMessage('navigator.vibrate(0)', 'green'); | ||
}; | ||
//cancel existing vibration using w3c spec navigator.vibrate([]) | ||
var cancelWithEmpty = function() { | ||
// cancel existing vibration using w3c spec navigator.vibrate([]) | ||
var cancelWithEmpty = function () { | ||
clearLog(); | ||
navigator.vibrate([]); | ||
logMessage("navigator.vibrate([])", "green"); | ||
logMessage('navigator.vibrate([])', 'green'); | ||
}; | ||
//reference to the timeout variable | ||
// reference to the timeout variable | ||
var timeout; | ||
//check whether there is an ongoing vibration | ||
// check whether there is an ongoing vibration | ||
var vibrateOn = false; | ||
//special long vibrate used to test cancel | ||
var longVibrate = function() { | ||
// special long vibrate used to test cancel | ||
var longVibrate = function () { | ||
clearLog(); | ||
navigator.vibrate(60000); | ||
vibrateOn = true; | ||
logMessage("navigator.vibrate(60000)", "green"); | ||
timeout = setTimeout(resetVibrateOn, 60000); //if user doesn't cancel vibrate, reset vibrateOn var after 60 seconds | ||
logMessage('navigator.vibrate(60000)', 'green'); | ||
timeout = setTimeout(resetVibrateOn, 60000); // if user doesn't cancel vibrate, reset vibrateOn var after 60 seconds | ||
}; | ||
//special long vibrate with pattern used to test cancel | ||
var longVibrateWithPattern = function() { | ||
// special long vibrate with pattern used to test cancel | ||
var longVibrateWithPattern = function () { | ||
clearLog(); | ||
navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000]); | ||
vibrateOn = true; | ||
logMessage("navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000])", "green"); | ||
timeout = setTimeout(resetVibrateOn, 45000); //if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds | ||
logMessage('navigator.vibrate([1000, 2000, 3000, 2000, 5000, 2000, 30000])', 'green'); | ||
timeout = setTimeout(resetVibrateOn, 45000); // if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds | ||
}; | ||
//initiate two vibrations to test cancel | ||
var multipleVibrations = function() { | ||
// initiate two vibrations to test cancel | ||
var multipleVibrations = function () { | ||
clearLog(); | ||
@@ -154,11 +153,10 @@ navigator.vibrate(20000); | ||
vibrateOn = true; | ||
logMessage("navigator.vibrate(15000)\nnavigator.vibrate(45000)", "green"); | ||
timeout = setTimeout(resetVibrateOn, 45000); //if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds | ||
logMessage('navigator.vibrate(15000)\nnavigator.vibrate(45000)', 'green'); | ||
timeout = setTimeout(resetVibrateOn, 45000); // if user doesn't cancel vibrate, reset vibrateOn var after 45 seconds | ||
}; | ||
function resetVibrateOn() { | ||
function resetVibrateOn () { | ||
vibrateOn = false; | ||
} | ||
var vibrate_tests = '<h1>Vibrate Tests</h1>' + | ||
@@ -194,6 +192,5 @@ '<h3>Starred tests only work for Android and Windows. </h3>' + | ||
contentEl.innerHTML = '<div id="info"></div>' + vibrate_tests; | ||
//standard vibrate with old call | ||
// standard vibrate with old call | ||
createActionButton('Vibrate (Old)', function () { | ||
@@ -203,3 +200,3 @@ vibrateOld(); | ||
//vibrate with pattern with old call | ||
// vibrate with pattern with old call | ||
createActionButton('* Vibrate with a pattern (Old)', function () { | ||
@@ -209,3 +206,3 @@ vibrateWithPatternOld(); | ||
//vibrate with pattern with repeat with old call | ||
// vibrate with pattern with repeat with old call | ||
createActionButton('* Vibrate with a pattern with repeat (Old)', function () { | ||
@@ -215,121 +212,100 @@ vibrateWithPatternOldWithRepeat(); | ||
//cancel vibrate with old call | ||
createActionButton('* Cancel vibration (Old)', function() { | ||
// cancel vibrate with old call | ||
createActionButton('* Cancel vibration (Old)', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
longVibrate(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelOld(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancelVibrate_old'); | ||
//cancel vibrate with pattern with old call | ||
createActionButton('* Cancel vibration with pattern (Old)', function() { | ||
// cancel vibrate with pattern with old call | ||
createActionButton('* Cancel vibration with pattern (Old)', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
longVibrateWithPattern(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelOld(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancelVibrateWithPattern_old'); | ||
//standard vibrate with new call param int | ||
createActionButton('Vibrate with int', function() { | ||
// standard vibrate with new call param int | ||
createActionButton('Vibrate with int', function () { | ||
vibrateWithInt(); | ||
}, 'vibrate_int'); | ||
//standard vibrate with new call param array | ||
createActionButton('Vibrate with array', function() { | ||
// standard vibrate with new call param array | ||
createActionButton('Vibrate with array', function () { | ||
vibrateWithArray(); | ||
}, 'vibrate_array'); | ||
//vibrate with a pattern | ||
createActionButton('* Vibrate with a pattern', function() { | ||
// vibrate with a pattern | ||
createActionButton('* Vibrate with a pattern', function () { | ||
vibrateWithPattern(); | ||
}, 'vibrate_with_pattern'); | ||
//cancel any existing vibrations with param 0 | ||
createActionButton('* Cancel vibration with 0', function() { | ||
// cancel any existing vibrations with param 0 | ||
createActionButton('* Cancel vibration with 0', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
longVibrate(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelWithZero(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancel_zero'); | ||
//cancel any existing vibrations with param [] | ||
createActionButton('* Cancel vibration with []', function() { | ||
// cancel any existing vibrations with param [] | ||
createActionButton('* Cancel vibration with []', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
longVibrate(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelWithEmpty(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancel_array'); | ||
//cancel vibration with pattern with param 0 | ||
createActionButton('* Cancel vibration with pattern with 0', function() { | ||
// cancel vibration with pattern with param 0 | ||
createActionButton('* Cancel vibration with pattern with 0', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
longVibrateWithPattern(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelWithZero(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancelWithPattern_zero'); | ||
//cancel vibration with pattern with param [] | ||
createActionButton('* Cancel vibration with pattern with []', function() { | ||
// cancel vibration with pattern with param [] | ||
createActionButton('* Cancel vibration with pattern with []', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
longVibrateWithPattern(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelWithEmpty(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancelWithPattern_array'); | ||
//cancel multiple vibrations | ||
createActionButton('* Cancel multiple vibrations', function() { | ||
// cancel multiple vibrations | ||
createActionButton('* Cancel multiple vibrations', function () { | ||
if (!vibrateOn) | ||
{ | ||
if (!vibrateOn) { | ||
multipleVibrations(); | ||
} | ||
else | ||
{ | ||
} else { | ||
cancelWithZero(); | ||
resetVibrateOn(); | ||
clearTimeout(timeout); //clear the timeout since user has canceled the vibrate | ||
clearTimeout(timeout); // clear the timeout since user has canceled the vibrate | ||
} | ||
}, 'cancelMultipleVibrations'); | ||
}; |
@@ -22,3 +22,3 @@ /* | ||
var vibrate = function(duration) { | ||
var vibrate = function (duration) { | ||
navigator.vibrate(duration); | ||
@@ -25,0 +25,0 @@ }; |
@@ -53,32 +53,27 @@ /* | ||
*/ | ||
vibrate: function(param) { | ||
vibrate: function (param) { | ||
/* Aligning with w3c spec */ | ||
//vibrate | ||
if ((typeof param == 'number') && param !== 0) | ||
exec(null, null, "Vibration", "vibrate", [param]); | ||
// vibrate | ||
if ((typeof param === 'number') && param !== 0) { | ||
exec(null, null, 'Vibration', 'vibrate', [param]); | ||
//vibrate with array ( i.e. vibrate([3000]) ) | ||
else if ((typeof param == 'object') && param.length == 1) | ||
{ | ||
//cancel if vibrate([0]) | ||
if (param[0] === 0) | ||
exec(null, null, "Vibration", "cancelVibration", []); | ||
// vibrate with array ( i.e. vibrate([3000]) ) | ||
} else if ((typeof param === 'object') && param.length === 1) { | ||
// cancel if vibrate([0]) | ||
if (param[0] === 0) { | ||
exec(null, null, 'Vibration', 'cancelVibration', []); | ||
//else vibrate | ||
else | ||
exec(null, null, "Vibration", "vibrate", [param[0]]); | ||
} | ||
// else vibrate | ||
} else { | ||
exec(null, null, 'Vibration', 'vibrate', [param[0]]); | ||
} | ||
//vibrate with a pattern | ||
else if ((typeof param == 'object') && param.length > 1) | ||
{ | ||
var repeat = -1; //no repeat | ||
exec(null, null, "Vibration", "vibrateWithPattern", [param, repeat]); | ||
} | ||
// vibrate with a pattern | ||
} else if ((typeof param === 'object') && param.length > 1) { | ||
var repeat = -1; // no repeat | ||
exec(null, null, 'Vibration', 'vibrateWithPattern', [param, repeat]); | ||
//cancel vibration (param = 0 or []) | ||
else | ||
exec(null, null, "Vibration", "cancelVibration", []); | ||
// cancel vibration (param = 0 or []) | ||
} else { exec(null, null, 'Vibration', 'cancelVibration', []); } | ||
@@ -110,6 +105,6 @@ return true; | ||
*/ | ||
vibrateWithPattern: function(pattern, repeat) { | ||
repeat = (typeof repeat !== "undefined") ? repeat : -1; | ||
pattern = pattern.unshift(0); //add a 0 at beginning for backwards compatibility from w3c spec | ||
exec(null, null, "Vibration", "vibrateWithPattern", [pattern, repeat]); | ||
vibrateWithPattern: function (pattern, repeat) { | ||
repeat = (typeof repeat !== 'undefined') ? repeat : -1; | ||
pattern = pattern.unshift(0); // add a 0 at beginning for backwards compatibility from w3c spec | ||
exec(null, null, 'Vibration', 'vibrateWithPattern', [pattern, repeat]); | ||
}, | ||
@@ -120,5 +115,5 @@ | ||
*/ | ||
cancelVibration: function() { | ||
exec(null, null, "Vibration", "cancelVibration", []); | ||
cancelVibration: function () { | ||
exec(null, null, 'Vibration', 'cancelVibration', []); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
1082309
0.17%62
3.33%1
-50%2
-33.33%7
600%927
-2.63%