TurboWarp / extensions

User-contributed unsandboxed extension gallery for TurboWarp
https://extensions.turbowarp.org/
MIT License
107 stars 217 forks source link

PwLDev/vibration: Vibration pattern block #1522

Closed DNin01 closed 2 weeks ago

DNin01 commented 2 weeks ago

The navigator.vibrate() function isn't limited to just buzzing your phone once for a specific amount of time. You can actually use it to play a pattern where the device alternates between vibrating and not vibrating. You can learn more on MDN Web Docs.

I added a block to bring this functionality to the vibration extension.

Tested on Edge for Android.

LilyMakesThings commented 2 weeks ago

Given that JSON is already sort of an accepted format for TurboWarp extensions, I don't think using strings with a delimiter is the right thing to do.

CubesterYT commented 2 weeks ago

Yeah, I agree. We can easily just use a normal Array here.

GarboMuffin commented 2 weeks ago

if you do something like .replace(/[^0-9\-.]/g, " ").split(" ").filter(i => i) then people can give the comma list or a JSON list or whatever they want and it should just work

DNin01 commented 2 weeks ago

I changed .split(",") to .match(/[\w\-.]+/g), which handles inputs like this: RegEx match results of '[1, "2", -3.5 , Infinity, ,  3e4, 0x06, 6-.6.2, NaN]': 1, 2, -3.5, Infinity, 3e4, 0x06, 6-.6.2, NaN