summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmobile.sh1
-rw-r--r--objects.js7
-rw-r--r--threads.js6
3 files changed, 14 insertions, 0 deletions
diff --git a/mobile.sh b/mobile.sh
index 0f660d1..b1fb9de 100755
--- a/mobile.sh
+++ b/mobile.sh
@@ -13,4 +13,5 @@ git clone https://github.com/Gubolin/snap.git www
cd www
git checkout mobileapp
cordova platform add android
+cordova plugin add org.apache.cordova.vibration
cordova build android
diff --git a/objects.js b/objects.js
index fbb9e84..9dadfb3 100644
--- a/objects.js
+++ b/objects.js
@@ -878,6 +878,11 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'sensing',
spec: 'current %dates'
},
+ doVibrate: {
+ type: 'command',
+ category: 'sensing',
+ spec: 'vibrate %n seconds'
+ },
// Operators
reifyScript: {
@@ -4991,6 +4996,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 335b5d0..c796642 100644
--- a/threads.js
+++ b/threads.js
@@ -2601,6 +2601,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
/*