Spaces:
Runtime error
Runtime error
| var vibrateInterval; | |
| function vibrate(flutter_value) { | |
| clearInterval(vibrateInterval); | |
| if ("vibrate" in navigator){ | |
| // alert("supported"); | |
| navigator.vibrate(flutter_value); | |
| } | |
| } | |
| function sum(arr1){ | |
| if(arr1.constructor !== Array) return arr1 | |
| function add(accumulator, a) { | |
| return accumulator + a; | |
| } | |
| sumvalue = arr1.reduce(add, 0); | |
| return sumvalue; | |
| } | |
| function setIntervalAndExecute(fn, t) { | |
| fn(); | |
| return(setInterval(fn, t)); | |
| } | |
| function peristentVibrate(pattern) { | |
| // alert("supported"); | |
| // vibrateInterval = setInterval(() => { | |
| vibrateInterval = setIntervalAndExecute(() => { | |
| if ("vibrate" in navigator){ | |
| navigator.vibrate(pattern); | |
| } | |
| }, sum(pattern)); | |
| } |