fiddle
fiddle copied to clipboard
Fancy launch page
We have a protocol handler, it would be good to make a https://fiddle.electronjs.org/launch/{gist_id} endpoint that will use any of the fancy techniques we know to detect if fiddle is running and launch it, if it isn't running we can give them a fancy download page with an explanation / overview of what fiddle is.
I can build that page itself and the logic but would need some help making it look nice on the website side of things π
fancy techniques we know to detect if fiddle is running and launch it
The only one I've ever been able to think of is having fiddle run a server on localhost and trying to ping it from the website. What are some other techniques?
@zeke I do have one! I've been using it at Slack with some success.
- Attach a
blur
event listener on the window. - Open an invisible iframe with the protocol link.
- Wait four seconds.
- Did we lose focus? If so, the app probably launched.
- If not, we're probably still in the browser and nothing happened since the app isn't installed.
Works like a breeze. Might feel a bit dirty but that's sort of the best we have today.
Very interesting. How did you arrive at four seconds
?
@zeke It's pretty much an arbitrary number βΒ pick whatever you think is enough to ensure that most machines had enough time to open the target app and that the app managed to steal focus.
We have a protocol handler, it would be good to make a https://fiddle.electronjs.org/launch/{gist_id} endpoint that will use any of the fancy techniques we know to detect if fiddle is running and launch it, if it isn't running we can give them a fancy download page with an explanation / overview of what fiddle is.
I can build that page itself and the logic but would need some help making it look nice on the website side of things +1
Webpages CAN open protocols directly without iframes. That means that once the protocol has ended the connection, itll close the tab