From e4f04d19635b68261560606268feb0df16fdf703 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 6 Sep 2014 15:52:50 +0200 Subject: cherry-pick vibration block --- mobile.sh | 6 +++--- objects.js | 7 +++++++ threads.js | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mobile.sh b/mobile.sh index 42c015b..bfb412c 100755 --- a/mobile.sh +++ b/mobile.sh @@ -45,12 +45,12 @@ sed -i '/link rel="shortcut icon"/a\ echo "Adding cordova plugins" # add everything needed and build for $device cordova platform add "$1" > /dev/null -cordova plugin add org.apache.cordova.geolocation 2> /dev/null +cordova plugin add org.apache.cordova.geolocation \ + org.apache.cordova.vibration 2> /dev/null #org.apache.cordova.plugin.softkeyboard \ - #org.apache.cordova.vibration \ #org.apache.cordova.device-motion \ #org.apache.cordova.device-orientation \ - #de.appplant.cordova.plugin.local-notification 2> /dev/null + #de.appplant.cordova.plugin.local-notification if [[ $1 == "android" ]] then diff --git a/objects.js b/objects.js index 718d50d..5fbafc2 100644 --- a/objects.js +++ b/objects.js @@ -929,6 +929,11 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'current %dates' }, + doVibrate: { + type: 'command', + category: 'sensing', + spec: 'vibrate %n seconds' + }, // Operators reifyScript: { @@ -5297,6 +5302,8 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('doSetFastTracking')); blocks.push('-'); blocks.push(block('reportDate')); + blocks.push('-'); + blocks.push(block('doVibrate')); // for debugging: /////////////// diff --git a/threads.js b/threads.js index 804c09a..fe9e3c4 100644 --- a/threads.js +++ b/threads.js @@ -2798,6 +2798,12 @@ Process.prototype.reportDate = function (datefn) { return result; }; +Process.prototype.doVibrate = function (seconds) { + if ("vibrate" in navigator) { + window.navigator.vibrate(seconds * 1000); + } +}; + // Process code mapping /* -- cgit v1.3.1