I never ended up using it in a tease, but figured I'd brush the cobwebs off this old example tease that attempts to emulate setTimeout and setInterval using audio events and release it, in case anyone wants to try it out.
Note: I've not done much cross-browser testing on it, so give it a good work-out and make sure it does what you want before you write anything that relies on it. (Please let me know if it works for you or not.)
Update^^: This timer polyfill is now being used by a few teases, and seems to be working well on most devices/browsers.
To INSTALL or UPDATE the core setTimeout functions/actions/files into an existing tease:
1. Open setTimeout demo as the source in Eos Magpie:
https://codepen.io/fapnip/full/GRjwPXP?id=45319&key=5ab58de466
2. Paste your tease's private share link as the target in Eos Magpie.
3. If installing for the first time, check the box for the "setTimeout" Magpie module. If updating, flip the switch for "Apply Auto Updates from Source".
4. Click the download button that will appear.
5. In the Eos Editor for your tease, download a back-up copy of your existing tease, just in case. (Seriously. Do it. Things can go wrong.)
6. Restore the downloaded merged magpie JSON from step 4 over your existing tease.
7. Ask for help here.
After you install the module, you use setTimeout/setInterval just like you normally would in standard JavaScript, but only after the polyfill has been loaded in your start page.
Example use (example code will not work unless you install the polyfill as described above):
Code: Select all
// Do something in one second
setTimeout(function() {
console.log("You'll see me in about a second")
}, 1000)
// Do something every two seconds
var twoSecondIntervalId = setInterval(function() {
console.log("You'll see me every two seconds, until I get shut down")
}, 2000)
// Stop the 2 second interval in 20 seconds
setTimeout(function() {
console.log("Shutting down 2 second interval")
clearInterval(twoSecondIntervalId)
}, 20000)
https://milovana.com/webteases/showteas ... 5ab58de466
And here's the JSON for it:
https://milovana.com/webteases/geteossc ... 5ab58de466
For a more in-depth example of the kind of things you can do with it, see:
viewtopic.php?f=2&t=24011
and:
viewtopic.php?f=2&t=24081