Today I spent some time playing around with scripting in Fargo. I wanted to see what was possible in the context of the Fargo UI, but not necessarily with respect to the outlining "verbs". Rather, I wanted to see how easy it would be to extend the menubar.opml functionality to hook into stuff outside of Fargo.
So I started with a simple experiment to see how easy it would be to add some user interface elements to Fargo under menu control. Then I wanted to see how to drag in content (via AJAX) from other locations into Fargo, and also to see how I could handle async processes. I ended up creating a small scrolling text area at the bottom of the right sidebar, and then made some functions to interact with that sidebar.
Init Scratchpad - this choice should be selected first. It injects some scripts and a text area into the DOM tree of Fargo for use by the other menu choices.
Hello World - writes a simple message to the Scratchpad text area created by Init Scratchpad
Start Clock - starts a background timer that puts the current time into the Scratchpad text area once a second
Stop Clock - terminates the background process running the clock display
I think these examples might be useful to others, so please feel free to share with anyone that might be interested.
This exercise pointed out one nice-to-have feature in Fargo regarding its menubar.opml file. It would be extremely handy if there was a headline (maybe with a special name or attribute) that would be run when the menubar.opml file is loaded by Fargo. This would allow scripts that need to be initialized somehow (or external resources that need to be fetched, initialized, etc.) to be executed on "startup" before the user starts picking other menu commands.
If you have any questions, please feel free to leave a comment here!