Extending LALOLib/LALOLab with a new toolbox
This page explains how to extend LALOLab with a new toolbox.
- List of contributed toolboxes
- Create a toolbox
- Create a help file for the toolbox
- Load the toolbox in LALOLab
Contributed toolboxes
To use one of these toolboxes, download the .js file in the toolboxes/ folder of LALOLab and the -help.js file in the help/ folder. Then, run make to recompile LALOLab with these functionalities.
For use inside your own web application, you can alternatively simply load the .js file as a script after ML.js.
If you want to share your toolbox as a contributed toolbox above, include all the source code of the toolbox in a single .js file, for instance with
cat file1.js file2.js ... > toolbox.js
and submit this file with the help file to fabien.lauer (
at) loria.fr
Create a toolbox
A toolbox can be simply created by writing a set of functions in a new file
toolboxes/toolbox.js
These functions can be written either fully in standard javascript or using LALOlib functions, but should always follow the guidelines for writing efficient code.
The toolbox file should be located in the lalolab/toolboxes/ folder of LALOLab. It can also be split into multiple *.js files.
Create a help file for the toolbox
A help file for a toolbox can be created in the help/ subfolder of LALOLab as, e.g.,
lalolab/help/helptoolbox.js
Such a help file should include one line for each documented function. For a function "func" of the toolbox "Great Toolbox", this line is encoded as
HELPcontent["func"] = ["GreatToolbox", "Function full name/title","y = func( x )\n y = func( x, optarg )","Function description...",
"// some example\n y = func( 2.5, 3 )"];
The first field "GreatToolbox" is the name of the toolbox as it will appear in LALOLab (except that an upper case letter will be replaced by a space and a lower case letter).
The third field should include the different expected syntaxes of the function calls, separated by "\n".
The fourth field is the main text description which can include html tags like <br>.
The last field is an example with lines of code separated by "\n". Multiple examples can be simply provided by using an Array of strings instead of a single string:
HELPcontent["func"] = [..., [ "// some example\n y = func( 2.5, 3 )", "// another example\n y = func( -1 )" ] ];
Load the toolbox in LALOLab
If the files are located in the correct folders as detailed above, then rebuilding LALOLab by running
make
in the lalolab/ folder should provide access to the toolbox and its help on the next LALOLab reboot.