jsMath version 3.1 and new filter released

jsMath version 3.1 and new filter released

by Davide Cervone -
Number of replies: 3
The jsmath filter now uses the latest version of jsMath (3.1). This version includes a number of small bug fixes (in particular, it fixes a problem with alignment in Firefox 1.5). There are also a number of significant new features. The most important of these is that the main jsMath files have now been compressed so that they should download about twice as fast as the uncompressed versions (this doesn't affect how fast jsMath processes the mathematics on the page, only how soon it can start doing so).

A second important feature is the ability for jsMath to load extensions automatically as they are needed by the mathematics on the page. Several lesser-used portions of jsMath have been moved into extension files to help reduce the initial download, and font references using the \char macro will load the font automatically if it is not loaded already. Additionally, you can define macros that are linked to extension files so that the use of the macro will cause the extension to load. Similarly, LaTeX environments can be autoloaded (though no examples of this are available yet). Finally, there is a new \require{} macro that you can use to load an extensionfrom within a TeX formula itself if it is needed for a particular piece of mathematics on the page (without the need to insert JavaScript code in the page). See the change log for more details.

Finally, the configuration section of the filter's javascript.phpfile includes settings for loadFiles and loadFonts, which allow you to specify additional files and fonts to load when jsMath is needed on a particular page. This provides a means of loading your own extensions (for example, loading a file that contains special macro definitions needed at your site).

Davide

Average of ratings: -
In reply to Davide Cervone

Re: jsMath version 3.1 and new filter released

by venkatesan iyengar -
Davide,

I updated the filter with the new version. However, everything failed. Both opera and IE6 did not display the equations. In IE6 I could see the jsmath control panel. Opera does not show even that. I found javascript-mod.php load the jsmath scripts properly. In IE6 I found the following error at the status bar:

Line: 1

Char: 1

Error: Object does not support this property or method

Code: 0

URL: puchemistry.org/course/filter/jsmath/jsMath/jsMath-autoload.html

When I tried to go back to the v3.0 also gave similar error. I've added morearrows extension as follows:

jsMath.Autoload.loadFiles[jsMath.Autoload.loadFiles.length] = ["plugins/mimeTeX.js", "extensions/moreArrows.js"];


You may view a test forum at http://puchemistry.org/course/course/view.php?id=21 (login as guest)

Any suggestions

In reply to venkatesan iyengar

Re: jsMath version 3.1 and new filter released

by venkatesan iyengar -
This is the javascript console error report:

CF101: jsmath
http://localhost/moodle/mod/resource/view.php?id=2
Timeout thread: delay 1 ms
Error:
name: TypeError
message: Statement on line 1: Type mismatch (usually a non-object value used where an object is required)
Backtrace:
Line 1 of eval script
if (this.loaded[_37])
else
if (! _37.match("^([a-zA-Z]+:/)?/"))
jsMath.Script.Load(_37, _38);
Line 304 of linked script http://localhost/moodle/filter/jsmath/jsMath/plugins/autoload.js
for (i in files)
Line 1 of unknown script
jsMath.Autoload.Script.AfterLoad();
In reply to venkatesan iyengar

Re: jsMath version 3.1 and new filter released

by Davide Cervone -
I've added morearrows extension as follows:

jsMath.Autoload.loadFiles[jsMath.Autoload.loadFiles.length] = ["plugins/mimeTeX.js", "extensions/moreArrows.js"];

That is the problem. The Autoload.loadFiles field is supposed to be either a single file name or an array of files, but you have made it an array that contains an array, and so jsMath tries to used your array as a string (a file name) and fails. (Not that it is the presence of "[jsMath.Autoload.loadFiles.length]", which was not in my earlier instructions to you, that makes this an array containing an array rather than just an array.)

There is no longer any need to make changes below the "DO NOT MAKE CHANGES BELOW THIS" message. Instead, set the loadFiles field in the configuration section to

    jsMath = {
      Moodle: {
        ...
        loadFiles: ["extensions/moreArrows.js"],
        ...
      }
   };
(where the "..." represents fields that I have not shown).

The javascript error that you reported above confirms that this is the problem, as that line is where the file name is trying to be used.


When I tried to go back to the v3.0 also gave similar error.

If you made the same change to its javascript.php file, you would get the same error. Note that you will need to empty the browser cache when you change versions of jsMath in order to make sure that all the correct versions of the files are being loaded. If your server uses a page cache, you may need to reset that as well. There is no reason why switching back to the earlier filter should not work if you do that.

I think that if you make the change above, the new version will work for you.

Davide