Liquid UI - Documentation - 7.19 usejs()

7.19 usejs()


Purpose

To include a JavaScript or a file within a script in Web Server.

The usejs() command functions similar to the usecss() command and is placed in the same config.sjs configuration file.


Options

The usejs command does not take any options.


Including a script

The string in the command could include a number of parameters or possibly a short script that would incorporate into the WS script. For instance, if a user wants to include code to print 'Hello World', then add the following in the config.sjs configuration file in the C:\Program Files\Liquid UI\LUI WebServer directory.

usejs("println('Hello, World')");

The body of the action to be performed should be included within the double quotes. In this case, the included line is for a simple 'println' operation. However, this string could be more complex as well.


Including a file

You can also call a separate Webscript function or even a complete script from an external file:

usejs("filename");

For instance, if the file is present in a different directory, then it is necessary to include the full path to the file, as shown below in the config.sjs configuration file:

usejs("C:\ScriptFiles\TestFunction.js");

For files present in the same directory as the scripts, you do not need to include the true or absolute path - the code can find the relevant file as long as it is in the same directory, as shown below:

usejs("TestFunction.js");

This file can contain any content from a single function to a complete script. Once called, the file will run, and then the remainder of the original code will continue from the point where the file left off.


Can't find the answers you're looking for?