> > Although jsMath itself contains workarounds for the tighter same-
> <snip>
>
> What is the structure of the workaround? I could probably patch it
> into thejsMathplugin for testing, even if I don't do a very neat
> job.
It is more complicated than I wish that it were, and is based on the
window.postMessage() mechanism that is new in Firefox3. (See
http://developer.mozilla.org/en/docs/DOM:window.postMessage) This
apparentl comes from a WHATWG specification that is part of HTML5.
JsMath uses a hidden IFRAME to access a file in the jsMath directory,
and that file loads the required javascript (using XMLHttpRequest,
which now works since the javascript file is in the same directory as
the loading file). The loader passes the javascript back to the
original window via postMessage(), where it is executed using eval().
Ugly, but works.
You need to set up an event listener in the main window to receive the
postMessage event(). Unfortunately, such a listener receives EVERY
message posted to the window, regardless of origin, so you need to be
sure to mark your messages, so that you can identify them from other
messages that may be sent to the window, and act only on the ones you
actually sent, ignoring anything else. I have marked jsMath's
messages by staring them all with "jsM" followed by a two letter code
(one of "LD", "AL" or "CP" identifying the loader, autoloader and
control panel loader) followed by a colon followed by a three letter
command followed by another colon followed by the actual contents of
the message.
You can see the listener in jsMath/uncompressed/jsMath.js (look for
"jsMath.Post =" and see the listener that it contains). The
corresponding poster is in jsMath/jsMath-loader-post.html, but there
is more in that file than you need, since it is used for several
purposes. On the other hand, you could probably use this loader to
load jsMath.js itself if you mimicked the listener as part of the
TiddlyWiki plugin. There is some handshaking going on between the
poster and listener that you probably wouldn't need if you were
writing your own loader for jsMath, but they shouldn't really get in
the way.
I suspect that other TiddlyWiki plugins are going to have to deal with
similar issues, and that a common solution would be possible.
> Thank you for your efforts Davide - I find jsMath to be a
> fantastically useful tool.
I appreciate your kind words. Thanks.
Davide