One of the users of our DHTMLX library, Sergei Sheinin, has created a JavaScript Library API named JS2DX. We would like to present Sergei’s overview of it and we suppose that some of you will find JS2DX useful and appropriate for your own projects:
“While developing large quantity of database interfaces with DHTMLX framework I felt weighed down by verbosity of JavaScript syntax and having to reuse multiple lines of code that instantiated interface components. Another hurdle that stood out was that the interface components were not nested inside the code. For example a page with multi-cell layout containing several interface components would get written in one indent making it difficult to review and modify. And there was a need to constantly check the documentation for specifics of a multitude of commands.
DHTMLX was the JavaScript Library of choice because of its speed and straight-forward syntax and there are similarly unfavorable shortcomings with other JavaScript Libraries. Something had to be accomplished to cut down development time, minimize and simplify code and make syntax memorization more intuitive.
The result is JS2DX – a lightweight JavaScript API integrated with DTHMLX code base. It consists of a programming language interpreter written entirely with JavaScript. With its help I was able to reduce code size and time required to write it.
JS2DX offers key-value pair syntax that is simple and with minimized verbosity. It presents a programmer with ability to instantiate GUI components in short statements. JS2DX code may be supplemented with native JavaScript Library commands and classic JavaScript wherever necessary.
For example instantiation of a Tree component with onClick event in JS2DX is accomplished using the following code:
id : 'myTree'
,url :'./xml/source.xml'
,onClick: function(id) { alert(id) }}}
JS2DX interpreter features a recursive command iterator. Thus GUI components may be nested enabling programmers to code complex pages with one JavaScript object. When loading a GUI page the interpreter refers to a map of JS2DX internal commands matched with their corresponding DHTMLX function calls. Having such command map simplifies procedure of adding support for DHTMLX functions. For example to support setting image path for the Tree component it is sufficient to add this entry to the command map:
// command in JS2DX interpreter
cmd:'setImagePath', // command native to DHTMLX
params:['imgPath'] // object key used in coding a JS2DX page
default:['./codebase/imgs/']}
JS2DX syntax for invoking DHTMLX setImagePath function becomes as follows:
id : 'myTree'
,imgPath: 'http://mydomain/images'
...}}
Commands contained in JS2DX interpreter are reused for various DHTMLX function calls. As command selection in the interpreter is expanded in ongoing JS2DX development the procedure of mapping DHTMLX functions progressively becomes more effortless.
JS2DX features automatic inclusion of JS and CSS files needed to instantiate page components. For example if a GUI page code contains Tree object then JS2DX will automatically add dhtmlxtree.js and dhtmlxtree.css to the document header. A programmer does not need to consider which JavaScript Library or CSS files are required to load a GUI page.
JS2DX is compact and fast. While the current version is integrated with DHTMLX support for various other JavaScript Libraries is planned. There are graphing component based entirely on JS/HTML and client-side database libraries in its feature pipeline. JS2DX became functional in December 2013. It is employed in a real-world project where it provides numerous database interfaces.”