In order to provide custom functionality for the end users of Plexus Suite, the system administrator can add custom JavaScript files to the application.
By default, these script files have to be stored in the ${HOME}/.chemaxon/plexus-suite/scripts-data/SCHEMA_NAME/
folder by the server administrator. Please note that before version 15.11.16, the default configuration directory was ${HOME}/.instantjchem/ijcWebServer/
. From 15.11.16, the default directory has become ${HOME}/.chemaxon/plexus-suite/
.
The same folder contains a scripts.conf
configuration file, where the administrator can assign the scripts to different table or form views. The configuration file has to contain a line for each script file - database view pair, and the following template has to be followed:
#view name;javascriptfile.js;action_name
where view name
is the name of the table or form in which you want to use the script;
javascriptfile.js
is the name of the script file;
action_name
is the name of the menu item which will appear in the context menu of every clickable object (such as grid cells, widgets, column headers) of the table or form in question. Clicking on this context menu item will make the script run.
In the example below, the find-in-pubchem.js script is assigned to the Wombat activities form, and the Find in PubChem menu item will be registered in the context menu of every widget or cell of this form. If you select this item from the context menu of any of the widgets or cells, the same find-in-pubchem.js script will be executed.
Wombat activities;find-in-pubchem.js;Find in PubChem
The script opens the PubChem database in a new browser tab and looks up the current molecule.
The details of the find-in-pubchem.js script can be found below:
/**
* The purpose is create a url like:
* http://wombat.com/drilldown?tablename=${tableName}&column=${columnName}&formula=${formula}&condition=${condition}"
*/
function main(data){
"use strict";
/* JSHint hints: */
/* global console, plexusAPI */
var schemaId = data.serverSchemaId;
var entityId = data.fieldInfo.entityId;
var rowIndex = data.selection;
// console.log("data", data);
// console.log("schema: ", schemaId, ", entity: ", entityId, ", row: ", rowIndex, ", field: ", data.fieldInfo.id);
plexusAPI.getStructure(schemaId, entityId, rowIndex, data.fieldInfo.id, "smiles", function(smiles) {
var queryUrl = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/" + encodeURIComponent(smiles) + "/cids/TXT";
console.log(smiles);
var oReq = new XMLHttpRequest();
oReq.onload = function(e) {
console.log("response from pubchem", e);
var resultUrl = "https://pubchem.ncbi.nlm.nih.gov/compound/" + e.currentTarget.responseText;
plexusAPI.openNewWindow(resultUrl);
};
oReq.open("GET", queryUrl, true);
oReq.send();
});
}
A JavaScript file can be assigned to multiple forms or tables, and a form or a table can have several script files assigned to it.
{primary} Known issue
Currently, using custom JavaScripts files in Plexus Suite is not possible with Internet Explorer 10 or older versions.
{info} See also
[Writing JavaScript Files for Custom Functionality](discontinued_plexus-suite_writing-javascript-files-for-custom-functionality.md)