File Scilligence.JSDraw2.Pro.js


file Scilligence.JSDraw2.Pro.js

Class Summary
 Example:
 <div id='div1'>
 <script type="text/javascript">
     scilligence.ready(function () {
     });
 </script>
 
 Example:
    var input = scilligence.Utils.createElement(document.body, "input");
    var ac = new scilligence.AutoComplete(element, "http://server/ajax.ashx?cmd=autocomplete");
 
 Example:
        scilligence.BarcodePrinter.show({barcode: "B39493243"});
 
 Example:
    var dt = scilligence.BusinessDay.addBusinessDays(new Date(), 20);
    var f = scilligence.BusinessDay.isWorkday(new Date());
    var days = scilligence.BusinessDay.getBusinessDays(new Date(2015, 5, 1), new Date(2015, 7, 12));
 
 Example:
 <div id='div1'>
 <script type="text/javascript">
     scilligence.ready(function () {
         new scilligence.Calendar("div1", { events: [{ date: "2015-5-28", time: "8:00", title: "See Doctor" },
             { date: "2015-5-28", time: "12:00", title: "See Doctor" },
             { date: "2015-5-18", time: "8:00", title: "See Doctor"}],
             ondblclick: function (date) {
                 alert(date);
             }
         });
     });
 </script>
 
 For scilligence.Page.addForm() method, please use *block* for Block display, and *table* for Table display 
 Example 1:
    <div id="div1"></div>
    <div id="div2"></div>
    <script type="text/javascript">
        scilligence.ready(function () {
            var rows = [
                { src: "img/hazard-CompressedGas.png", id: 1, molid: "SCI-32423942394", purity: "98%", project: "NVS-34234" },
                { src: "img/hazard-CompressedGas.png", id: 2, molid: "SCI-32423942394", purity: "98%" },
                { src: "img/hazard-CompressedGas.png", id: 3, molid: "SCI-32423942394", purity: "98%", project: "NVS-34234" },
                { src: "img/hazard-CompressedGas.png", id: 4, molid: "SCI-32423942394", purity: "98%", project: "NVS-34234", project2: "NVS-34234" }];



            var options = {
                imgkey: "src", imgwidth: 300, imgheight: 100, viewonly: true, columns: {
                    src: { type: "hidden" },
                    id: { label: "ID", width: 100 },
                    molid: { label: "Mol ID", width: 200 },
                    purity: { label: "Purity", width: 100 }
                }
            };
            var table = new scilligence.Table(options);
            table.render("div1", options.columns);
            table.setData(rows);

            var blocks = new scilligence.CardView(options, options.columns);
            blocks.render("div2");
            blocks.setData(rows);
        });
    </script>
 
Cart class - Cart Control
Supported chart types: pie, line, stackedline, area, stackedarea, column, clusteredcolumn, bar, clusteredbar, bubble
 Example 1:
    <script type="text/javascript">
        scilligence.ready(function () {
            new scilligence.Chart('div1', { type: "bar", width: 800, height: 300,
                ajax: { url: "service.aspx?cmd=datasource&source=bug" }
            });
        });
    </script>

 Example 2:
    <script type="text/javascript">
        scilligence.ready(function () {
            new scilligence.Chart('div1', { type: "bar", width: 800, height: 300,
                series: [
                    { label: "Series 1", data: { A: 10000, B: 9200, C: 11811, D: 12000, E: 7662, F: 13887} },
                    { label: "Series 2", data: { A: 3000, B: 12000, D: 12783} }
                ]
            });
        });
    </script>

 Example 3:
    <script type="text/javascript">
        scilligence.ready(function () {
            new scilligence.Chart('div1', { type: "bar", width: 800, height: 300,
                xlabels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
                series: [
                    { label: "Series 1", data: [10000, 9200, 11811, 12000, 7662, 13887] }
                ]
            });
        });
    </script>

 Example 4:
    <script type="text/javascript">
        new scilligence.Chart('container', { type: "bubble", width: 800, height: 300, xmin: 0, ymin: 0, xmax: 8, ymax: 20, ytitle: "Bubble",
            series: [
                    { label: "Series 1", data: [
                    { x: 1, y: 12.45, size: 1, color: 'red' },
                     { x: 2, y: 15.45, size: 2, color: "green" },
                     { x: 3, y: 2, size: 1.5 },
                     { x: 4, y: 7, size: 3.5 },
                     { x: 5, y: 12, size: 1.5 },
                     { x: 6, y: 7, size: 4.5 }
                     ]
                    }
                ]
        });
    });
    </script>
 
 Example:
    <button onclick='test()'>Choose Color</button>
    <script type="text/javascript">
        function test() {
            scilligence.ColorPicker.show(function (color) { alert(color); });
        }
    </script>
 
 Example:
    scilligence.ready(function () {
        var input = scilligence.Utils.createElement(document.body, "input");
        new scilligence.ColorPicker2(input);
    });
 
ContextMenu class
 Example:
    var callback = function (key, obj) {
        alert( key + " clicked");
    };

    var items = [{ caption: "Color", key: "x", callback: function (key) { alert("Color: " + key);  }, children: ["Red", "Blue"] },
            "Small", "Big"
        ];

    var menu = new scilligence.ContextMenu(items, callback, null);
    function test() {
        menu.show(100, 100);
    }
 
 Example:
    scilligence.ready(function () {
        var input = scilligence.Utils.createElement(document.body, "input");
        new scilligence.DatePicker(input);
    });
 
 Example:
    // Create a popup dialog
    var div = scilligence.Utils.createElement(null, "div");
    var txt = scilligence.Utils.createElement(div, "textarea", null, { width: "580px", height: "400px" });
    var btn = scilligence.Utils.createElement(
            scilligence.Utils.createElement(div, "div", null, { textAlign: "center" }), 
                "button", "OK", { width: "200px" });
 
    var dlg = new scilligence.Dialog("My Dialog", div);
    dojo.connect(btn, "onclick", function (e) { dlg.hide(); });
    dlg.show();
 
 Example:
 <div id='div' style='width: 300px'></div> 
 <script type="text/javascript">
     scilligence.onload(function () {
         var dropdown = new scilligence.Dropdown("div", function (id) { alert(id); });
         var root = dropdown.tree.add(null, { id: 1, name: "Root", icon: "img/pen.gif" });
         dropdown.tree.add(root, { id: 2, name: "Child-1", icon: "img/pen.gif", 
             children: [{ id: 4, name: "Child-1 -1", leaf: true}] });
         dropdown.tree.add(root, { id: 3, name: "Child-2", icon: "img/pen.gif", leaf: true });
     });
 </script>
 
 Example:
    <button id='d'>Select City</button>
    <script type="text/javascript">
        scilligence.ready(function () {
            new scilligence.DropdownButton('d', { items: ["Boston", "New York", "London"], 
                callback: function (city) { alert(city); } });
        });
    </script>
 
 Example:
    <input id='d' />
    <script type="text/javascript">
        scilligence.ready(function () {
            new scilligence.DropdownCheck('d', ["Boston", "New York", "London"]);
        });
    </script>
 
 Example:
    <input id='d'/>
    <script type="text/javascript">
        scilligence.ready(function () {
            new scilligence.DropdownInput('d', { items: ["Boston", "New York", "London"],
                onclickitem: function (city) { alert(city); } 
            });
        });
    </script>
 
 Example:
    var input = scilligence.Utils.createElement(document.body, "input");
    var es = new scilligence.EditableSelect(element, options);
 
EditableTable class - Editable Table Control
 Example:
    dojo.ready(function () {
        var parent = scilligence.Utils.createElement(document.body, "div");
        var columns = {
            user: { label: "User", type: "input", width: 300 },
            role: { label: "Role", type: "select", options: ["", "Member", "Manager"], width: 300 }
        };
        var editabletable = new scilligence.EditableTable(parent, columns, "User", { ajaxurl: "ajax.ashx", cmd: "editabletable" });
    });
 
FieldCheck3 class - FieldCheck3 Control
FieldCode class - FieldCode Control
FieldCurve class - FieldCurve Control
FieldFile class - FieldFile Control
FieldImage class - FieldImage Control
FieldFileLink class - FieldFileLink Control
FieldMultiText class - FieldMultiText Control
FieldNumber class - FieldNumber Control
FieldPlainText class - FieldPlainText Control
FieldRichText class - FieldTabText Control
FieldSignature class - FieldSignature Control
FieldSubform class - FieldSubform Control
FieldTabText class - FieldTabText Control
FieldTemplateText class - FieldTemplateText Control
 Example:
    <script type="text/javascript">
        function preview(fileid) {
            scilligence.FilePreviewer.show(fileid, { url: "ajax.ashx?cmd=attachment.preview", previewurl: "download.ashx?topic=preview&filename=f.png&page={page}&fileid=" + fileid });
        }
    </script>
 
FileShelf class - FileShelf Control
 Example:
        var fields = {
            category: { label: "Category" },
            sheetindex: { label: "Sheet #", type: "select", items: [1, 2, 3, 4, 5] },
            headerlines: { label: "Header Lines", type: "select", items: [1, 2] }
        };

        var data = { formid: 123 };
        scilligence.FileUploader.upload({ caption: "Upload Excel", fields: fields, data: data, url: "ajax.ashx?cmd=my.cmd", callback: function (ret) { ... }});
 
 Constructor Parameters:
 - viewonly: {bool}
 - alternativeforms: {dict}
 - usepostform: {bool}
 - hidelabel: {bool}
 - centerbuttons: {bool}
 - onselectrow: function(item)
 - onchange: function(field, this, args)
 - oncreated: function(form)

 items of .render(parent, items, options)
    Format: { key1: { label, width, render, ... }, key2: { ... }}
      - align: left|right|center
      - attibutes: {dict}
      - autosugesturl: {string}. see scilligence.AutoComplete class
      - autohiderows: {bool}
      - button: {label, icon, type, onclick}
      - colspan: {int}
      - disable: {bool},
      - formula: {string}, 
      - icon: {string}
      - height: {int}
      - hidelabel: {bool}
      - labelstyle: {dict}
      - leading: {string}
      - label: {string}
      - padding: {int}
      - render: function(v, values) { return v; }
      - required: {bool}
      - str: {string}
      - style: {dict}
      - unit: {string}
      - value: {string}
      - viewonly: {bool}
      - was: {string}, the old key
      - width: {int}
      - onenter: function(field)
      - onclick: function(field, item, form)

 Supported Item Types:
    basic types: hidden, number, text, radio, date, color
    list types: select, dropdowninput, editableselect, dropdowncheck, multiselect
    table and text: table, tabtext, multitext, richtext, html, plaintext, multitext
    chemistry and biology: jsdraw, jdraw.fm, jsdraw.se, jsdraw.table, plate, sketches, plates
    file: file, filepath, filelink, filedblink, image, rawfile
    form: subform, checklist

 Example 1:
    <script type="text/javascript">
        dojo.ready(function () {
            var parent = scilligence.Utils.createElement(document.body, "div");
            var columns = {
                mass: { label: "Mass", type: "number", width: 200, unit: "g" },
                name: { label: "Compound Name", type: "input", width: 600, button: { label: "Test", onclick: function () { alert(99); } } },
                vendor: { label: "Vendor", type: "select", options: ["Company A", "Company B"], width: 700 }
            };
            var form = new scilligence.Form({ viewonly: false });
            form.render(parent, columns, { immediately: true });
        });
    </script>

 Example 2. File Upload Dialog:
    <script type="text/javascript">
        var fields = {
            projectcode: { label: "Project Code", required: true, width: 300 },
            file: { label: "Word File", type: "postfile", attributes: { name: "file"} }
        };
        var dlg;
        dlg = scilligence.Form.createDlgForm("Import Word", fields, { label: "Import", onclick: function () { dlg.form.post('ajax.ashx?cmd=abc.import', null, function(ret) { } } }, { usepostform: true });
    </script>

 Example 3. Form Forumla:
    <script type="text/javascript">
        var table;
        scilligence.ready(function () {
            var parent = scilligence.Utils.createElement(document.body, "div");
            var columns = {
                a: { label: "A", type: "number" },
                b: { label: "B", value: 5, viewonly: true },
                ab: { label: "A+B", formula: "{a}+{b}", viewonly: true },
                table: { label: "Table", formula: "cny=scilligence.Math.round({.usd}/{a},2)", type: "jsdraw.table", columns: [{ key: "usd", type: "float" }, { key: "cny", type: "float" }] },
                sum: { label: "Sum(USD)", formula: "{table}.getColSum('usd')", viewonly: true },
                sum2: { label: "Sum(CNY)", formula: "{table}.getColSum('cny')", viewonly: true }
            };
            table = new scilligence.Form({ viewonly: false });
            table.render(parent, columns);
        });
    </script>
 
Help class - Help Control
 Example:
        var args = {
            ajaxurl: "ajax.aspx?cmd=user.home",
            search: { label: "Search", autosuggesturl: "ajax?cmd=search.suggest", hints: "Use Product #, Lot #, Package #, Location #.", url: "Search.aspx?text=" },
            columns: [
                { section: "projects", caption: "My Projects", text: "projectcode", link: "Project.aspx?projectid=", id: "projectid" }
            ]
        };
        scilligence.HomePage.init(div, args);
 
Arrow class - Reaction Arrow
AssayCurve class - Curve
Predefined Bond Types:
JSDraw2.BONDTYPES = {
    UNKNOWN: 0,
    SINGLE: 1,
    DOUBLE: 2,
    TRIPLE: 3,
    DELOCALIZED: 4,
    WEDGE: 5,
    HASH: 6,
    WIGGLY: 7,
    EITHER: 8,
    SINGLEORDOUBLE: 9,
    SINGLEORAROMATIC: 10,
    DOUBLEORAROMATIC: 11,
    QUADRUPLE: 12,
    DUMMY: 13,
    PEPTIDE: 21,
    NUCLEOTIDE: 22,
    DISULFIDE: 23,
    AMIDE: 24
}
Base64 class provide base64 encode/decode functions
Curve class - Curve
CurvePath class - CurvePath
Drawer class - draw graphics
 Example:
    <div id="div1" style="border:solid 1px gray;"></div>
    <script type="text/javascript">
        scilligence.ready(function () {
            var jsd = new JSDraw2.Editor("div1", { width: 900, height: 500, viewonly: true });
            // draw arrow
            JSDraw2.Drawer.drawArrow(jsd.surface, new JSDraw2.Point(100, 100), new JSDraw2.Point(200, 100), "red", 5);
        });
    </script>
 
Editor class - define an Editor object.
 Example:
    <div id='formulation'></div>

    <script type="text/javascript">
        var formulation = null;
        dojo.ready(function () {
            formulation = new JSDraw2.Formulation("formulation", { viewonly: false, compoundlookup: 'ajax.ashx?cmd=compound.lookup' });
        });
    </script>
 
 Example:
    <div id='formulation'></div>

    <script type="text/javascript">
        var formulation = null;
        dojo.ready(function () {
            formulation = new JSDraw2.FormulationTable("formulation");
        });
    </script>
 
Group class - defines Object groups
Matrix class - Matrix class
Mol class - define a Molecule object
 Example:
    var molfile = "\n";
    molfile += "MolEngine02021312372D\n";
    molfile += "\n";
    molfile += "  2  1  0  0  0  0  0  0  0  0999 V2000\n";
    molfile += "    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n";
    molfile += "    1.3510    0.7800    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n";
    molfile += "  1  2  1  0  0  0  0\n";
    molfile += "M  END\n";

    var m = new JSDraw3.Mol();
    m.setMolfile(molfile);

    var smiles = m.getSmiles();
 
Picture class - Picture
 Example:
    <div id='plate'></div>

    <script type="text/javascript">
        var plate = null;
        dojo.ready(function () {
            plate = new JSDraw2.Plate("plate", { viewonly: false, showtable: true, size: "96", compoundlookup: 'ajax.ashx?cmd=compound.lookup' });
        });
    </script>
 
Plus class - Reaction Plus
Point class - define a position on the screen
Rect class - define a Rectangle on the screen
SequenceEditor class - define a Sequence Editor
 Example:
   <html>
   <head>
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.3/dojo/dojo.js"></script>
   <script type="text/javascript" src='http://[PATH]/Scilligence.JSDraw2.js'></script>
   </head>
   <body>
   <div id='ed'></div>
   <script type='text/javascript'>
     dojo.ready(function() {
       // create a JSDraw SequenceEditor
       var se = new JSDraw2.SequenceEditor("ed", { width: 800, height: 400 });
       se.setFasta('>Protein\nAKDSKFKDFKDJFKJDFKJDKFJDKJFKDJFKDJFKJDF');
       var fasta = se.getFasta();
       var xml = se.getXml();
     });
   </script>
   </body>
   </html>
 
Shape class - Shape
Spectrum class - Spectrum
 Example:
    var stack = JSDraw2.Stack(50);
    stack.push("Hydrogen");
    stack.push("Exygen");

    var item = stack.pop();
 
//*
//* Example:
//*    <div id="test2" style="width: 720px; height: 300px; border: 1px solid gray" ></div>
//*    <button onclick='stoichiometry.populate(JSDraw.get("test2").m.parseRxn())'>Popuplate</button>
//*    <br />
//*    <div id='stoichiomety'></div>
//*    <br />
//*
//*    <script type="text/javascript">
//*        var stoichiometry = null;
//*        dojo.ready(function () {
//*            new JSDraw2.Editor("test2");
//*            stoichiometry = new JSDraw2.StoichiometryGrid("stoichiomety");
//*        });
//*    </script>
//* 
//
Table class - define a Table object
 Example 1.    
 Example:
    var parent = scilligence.Utils.createElement(document.body, "div");
    dojo.ready(function () {
        var xdraw = new scilligence.XDraw(parent, { width: 800, height: 400 });
    });
 
 Example 1. Basic Authentication
        var data = { name: "Tony", dept: "R&D" };
        //var data = '{ name: "Tony", dept: "R&D" }';
        scilligence.Json.ajax("https://server/reg/ajax.ashx?cmd=test",
            function (ret) {
                // callback
            },
            data,
            {
                headers: { Authorization: scilligence.Json.basicAuth("ServiceAccount", "Password") }
            }
        );

 Example 2. Using API Key
        var data = { name: "Tony", dept: "R&D" };
        scilligence.Json.ajax("https://server/reg/ajax.ashx?cmd=test",
            function (ret) {
                // callback
            },
            data,
            {
                headers: { "APIKeyName" : "LDfkasdlfasdfiasdwerlqwr99ikdsfasdf" }
            }
        );

 Example 3. Call Third Part RESTful API
        var data = { name: "Tony", dept: "R&D" };
        scilligence.Json.call("https://server/reg/ajax.ashx?cmd=test",
            function (ret) {
                // callback
            },
            data,
            {
                headers: { "APIKeyName" : "LDfkasdlfasdfiasdwerlqwr99ikdsfasdf" }
            }
        );
 
 Example:
    scilligence.Lang.use('cn');
    var s = scilligence.Lang.res("Print");
 
 Example:
    // Use Chinese
    JSDraw2.Language.use("cn");
 
Json class - provides variety of tool functions
Menu class - Menu Control
 Example:
    scilligence.Message.show("File uploaded", "succeed");

    scilligence.Message.show("File is too big", "warning");

    scilligence.Message.show("File format is not supported", "error");

    scilligence.Message.show("Custom message ...", "blue", 10000, "Blue", true);
 
 Example:
    <div id="placeholder"></div>

    <script type="text/javascript">
    scilligence.ready(function () { init(); });

    function init() {
        var tree = {
            caption: "Analytical Category",
            key: "category",
            name: "category",
            //object: "instrument",
            root: { name: "Categories", icon: "img/ext/bmp.gif", children: [
                { name: "Cambridge", icon: "img/ext/pdf.gif", isleaf: true },
                { name: "Boston", icon: "img/ext/doc.gif", isleaf: true }
            ]
            }
        };
        this.page = new scilligence.Page(scilligence.byId("placeholder"), tree, { resizable: true, leftwidth: 300 });

        var width = 300;
        var instruments = this.page.addForm({
            caption: "Analyticals",
            key: "analyticalid",
            name: "name",
            object: "analytical",
            columns: {
                analyticalid: { type: "hidden", iskey: true },
                name: { label: "Analytical Name", width: 200 },
                category: { label: "Category", width: 200 },
                version: { label: "Version", width: 100 }
            },
            formcaption: "Analytical",
            fields: {
                analyticalid: { type: "hidden", iskey: true },
                name: { label: "Analytical Name", width: 800 },
                category: { label: "Category", width: 800 },
                version: { label: "Version", width: 100 },
                requestform: { label: "Request Form", type: "textarea", height: 200, width: 800 },
                resultform: { label: "Request Form", type: "textarea", height: 200, width: 800 }
            }
        }, this.page.tree);

    }
    </script>
 
 Example:
 <span id='k'>Test</span> More words
 <span id='Span1'>Test2</span>
 <script type="text/javascript">
     scilligence.onload(function () {
         new scilligence.Popup('k', { html: "Hello, World!", caption: "Hellow" });
         new scilligence.Popup('Span1', { html: "<img src='face.gif'>", caption: "Picture" });
     });
 </script>
 
 Example:
    scilligence.Progress.show("Running", function() { alert("cancelled"); });
    var count = 0;
    setInterval(function() { scilligence.Progress.update(++count, "Value " + count); }, 500);
 
QuickSearch class - QuickSearch Control
 Example - Tracking Changes with ICE plugin:
    <script type="text/javascript">
        var table;
        scilligence.User.getAuthorID = function () { return 1234; };
        scilligence.User.getAuthorName = function () { return "Tony Yuan"; };
        scilligence.ready(function () {
            var parent = scilligence.Utils.createElement(document.body, "div");
            var columns = {
                text: { label: "Richtext", type: "htmltext", ice: true, trackingbuttons: true, value: "<p>This is a test</p>" }
            };
            table = new scilligence.Form({ viewonly: false });
            table.render(parent, columns);
        });
    </script>
 
 Example:
    dojo.ready(function () {
        var parent = scilligence.Utils.createElement(document.body, "div");
            var options = { tabs: {
                a: { caption: "Tab A", fields: { field1: { label: "Field1"}} },
                b: { caption: "Tab B", fields: { field2: { label: "Field2" }, field3: { label: "Field3"}} }
            }, buttons: { label: "Test", onclick: function() { alert(999); } }, border: true
            };
        var form = new scilligence.TabbedForm(options).render(parent);
    });
 
 Constructor Parameters:
 - canadd: {bool}, allow to add rows, used to be *addrow*
 - columns: {key1: {labe, width, type}, key2: { ... } }
    = label: {string}
    = width: {int}
    = maxwidth: {int}
    = type: {string}, any field type defined in scilligence.Form
    = render: function(v, values) { return v; }
 - draggable: {bool}, be able to drag rows
 - candel: {bool},  be able to delete rows, used to be *delrow*
 - grouplinestyle: {string}
 - header: {bool}, indicate if showing headers
 - header0: [{label, colspan}]
 - hidecolumncookiekey: {string}
 - grouping: {bool}, group rows
 - pushleft: {bool}, push columns to the left side
 - rowcheck: {bool}, show row check
 - selectrow: {bool}, be able to select rows
 - viewonly: {bool}
 - ondrop: function(src, dest, this)
 - onAdd: function(this)
 - onselectrow: function(row, old)
 - onchange: function(this, e, item)
 - onBeforeAddRow: function(values)
 - onrowcheck: function(r, checked)
 - oncheckall: function(key, table)
 - oncheck: function(check, table)
 - onAddRow: function(r, values)

 Example 1:
    dojo.ready(function () {
        var parent = scilligence.Utils.createElement(document.body, "div");
        var columns = {
            user: { label: "User", type: "input", width: 300 },
            role: { label: "Role", type: "select", options: ["", "Member", "Manager"], width: 300 }
        };
        var table = new scilligence.Table({viewonly: false, header: true});
        table.render(parent, columns);

        table.setData([{ user: "Tony", role: "Member" }, { user: "Jack", role: "Manager"}]);
    });

 Example 2 (Double Header Table):
    <script type="text/javascript">
        var table;
        dojo.ready(function () {
            var parent = scilligence.Utils.createElement(document.body, "div");
            var columns = {
                mass: { label: "Mass", type: "number", align: "center", width: 200, unit: "g" },
                file: { label: "NMR", type: "file", options: { uploadurl: "service.aspx?cmd=upload"} },
                name: { label: "Compound Name", type: "input", width: 200 },
                vendor: { label: "Vendor", type: "editableselect", options: ["Company A", "Company B"], width: 200 }
            };
            table = new scilligence.Table({ viewonly: true, header0: [null, { label: "Scilli", colspan: 2 }, { label: "Kinase"}] });
            table.render(parent, columns);
            table.addRow({ mass: 160, name: "Compound 123", vendor: "Sigma" });
        });
  </script>
 
 Example:
        <div id="div1"></div>
        <script type="text/javascript">
            scilligence.ready(function () {
                var options = {
                    tabs: {
                        a: { caption: "Tab A" },
                        b: { caption: "Tab B", closable: true }
                    },
                    onRemoveTab: function (td, tabs) { alert("remove tab"); },
                    onBeforeShowTab: function (td, old, tabs) { },
                    onShowTab: function (td, old, tabs) { },
                    onCreateTab: function(td, clientarea, tabs) { },
                    border: true
                };

                var tabs = new scilligence.Tabs("div1", options);
            });
        </script>
 
 Example:
 </script>
 
 Example:
    var parent = scilligence.Utils.createElement(document.body, "div");
    var ac = scilligence.Tree(parent, { url: "/path/ajax.ashx?cmd=loadtree" });
 
Utils class - provides variety of tool functions
 Example 1 - Scatterplot:
    <script type="text/javascript">
        scilligence.ready(function () {
            var data = [
                { x: 5, y: 3, r: 12, c: "purple", f: true, s: "circle" },
                { x: 10, y: 17 },
                { x: 15, y: 4 }, 
                { x: 2, y: 8 }
            ];
            scilligence.Viz.scatterplot("div1", data, { highlightcolor: "green", color: "red", radius: 5, shape: "star5", selectable: true, onselect: function() {}, onclick: function(d) {} });
        });
    </script>

 Example 2 - Single Barchart:
    <script type="text/javascript">
        scilligence.ready(function () {
            var data = [
              { x: 0, y: 5 },
              { x: 1, y: 8 },
              { x: 2, y: 13 },
              { x: 3, y: 12 },
              { x: 4, y: 16 },
              { x: 5, y: 21 },
              { x: 6, y: 18 },
              { x: 7, y: 23 },
              { x: 8, y: 24 },
              { x: 9, y: 28 },
              { x: 10, y: 35 }
            ];
            scilligence.Viz.bar("div1", data, { title: "My Nice Chart", xlabel: "Month", ylabel: "Revenue", ontooltip: function (d) { return d.y; } });
        });
    </script>

 Example 3 - Series Barchart:
    <script type="text/javascript">
        scilligence.ready(function () {
            var data = [
              { x: 0, y: 5, y1: 5, y2: 5 },
              { x: 1, y: 8, y1: 8, y2: 8 },
              { x: 2, y: 1, y1: 133, y2: 13 },
              { x: 3, y: 1, y1: 6, y2: 12 },
              { x: 4, y: 1, y1: 166, y2: 16 },
              { x: 5, y: 9, y1: 211, y2: 21 },
              { x: 6, y: 1, y1: 45, y2: 23 },
              { x: 7, y: 2, y1: 233, y2: 23 },
              { x: 8, y: 20, y1: 244, y2: 24 },
              { x: 9, y: 2, y1: 288, y2: 28 }
            ];

            scilligence.Viz.bar("div1", data, { title: "My Nice Chart", xlabel: "Month", ylabel: "Revenue", barwidth: 20, stack: true,
                series: [{ key: "y", color: "cyan" }, { key: "y1", color: "purple" }, { key: "y2", color: "orange"}], 
                ontooltip: function (d, ser) { return ser.key + ": " + d[ser.key]; } });
        });
    </script>

 Example 4 - Pie Chart:
    <script type="text/javascript">
        scilligence.ready(function () {
            var data = [
	            { label: "Chengdu", color: "#3366CC", value: 123 },
	            { label: "Cambridge", color: "#DC3912", value: 627 },
	            { label: "Shanghai", color: "#FF9900", value: 329 },
	            { label: "San Diego", color: "#109618", value: 99 },
	            { label: "Beijing", color: "#990099", value: 902 }
            ];
	        scilligence.Viz.pie("div1", data, { onclick: function (d) { alert(d.data.label); } });
        });
    </script>
 
WeighRecords class
WeighStation class
HELM Editor class
ExtinctionCoefficient class
Formula class
Interface class
MolViewer class
MonomerColors class
MonomerExplorer class
Recommended database schema:

 create table HELMMonomers
 (
 id bigint not null identity(1, 1) primary key,
 Symbol varchar(256) not null,
 Name varchar(256) not null,
 NaturalAnalog varchar(256),
 SMILES varchar(max),
 PolymerType varchar(256) not null,
 MonomerType varchar(256),
 Molfile varchar(max),
 Hashcode varchar(128),
 R1 varchar(256),
 R2 varchar(256),
 R3 varchar(256),
 R4 varchar(256),
 R5 varchar(256),
 R6 varchar(256),
 R7 varchar(256),
 R8 varchar(256),
 R9 varchar(256),
 R10 varchar(256),
 Author nvarchar(256),
 CreatedDate DateTime default getdate()
 );

 
JSON Schema
 {
     id: 69,                     // monomer internal ID
     symbol: 'Alexa',            // monomer symbol
     name: 'Alexa Fluor 488',    // monomer long name
     naturalanalog: null,        // natural analog
     smiles: null,               // smiles
     polymertype: 'CHEM',        // polymer type: CHEM, SUGAR, LINKER, BASE, AA
     monomertype: null,          // momer type: Backbone, Branch, null
     molfile: null,              // molfile of monomer, plain text, not BASE64 encoded or compressed
     r1: 'X',                    // cap for R1
     r2: null,                   // cap for R2
     r3: null,                   // cap for R3
     r4: null,                   // cap for R4
     r5: null,                   // cap for R5
     r6: null,                   // cap for R6
     r7: null,                   // cap for R7
     r8: null,                   // cap for R8
     r9: null,                   // cap for R9
     r10: null,                  // cap for R10
     author: null,               // monomer author
     createddate: null           // monomer created date
 }
 
Monomers class
HELM Editor Plugin class
Recommended database schema:

 create table HELMRules
 (
 id bigint not null identity(1, 1) primary key,
 Category nvarchar(256),
 Name nvarchar(512) not null,
 Script nvarchar(max),
 Description nvarchar(max),
 Author nvarchar(256),
 CreatedDate DateTime default getdate()
 );

 
JSON Schema
 {
     id: 3,                                          // rule internal ID
     name: 'Replace base A with U',                  // rule long name
     script: '	\nfunction(plugin) {\n // ... \n}',   // rule script
     description: null,                              // rule full description
     author: null,                                   // rule author
     createddate: null,                              // rule created date
     category: null                                  // rule category
 }
 
RuleSet class

Property Summary
JSDraw2.Editor canvas
- Drawing Canvas
MonomerExplorer mex
- Monomer Explorer
DIV notation
- HELM Notation
- HELM Property Table
HELM Version
DIV sequence
- Biological Sequence
JSDraw2.Editor structureview
- Structure Viewer

Constructor Summary
App (DOM parent, dict options)
Graph (string or DOM element, dict options)
XDraw (string or DOM parent, dictionary options)

Function Summary
Calaulte helm structure properties (internal use)
Calculate layout sizes (internal use)
clear()
Clear contents
create drawing canvas (internal use)
create notation view (internal use)
create monomer explorer (internal use)
Create property window (internal use)
Create sequence view (internal use)
Create structure view (internal use)
Get Molfile
Get selection as a molfile (internal use)
Get SMILES
Tool function to get item by using its key (internal use)
getXml()
Get JSDraw Xml data
init()
Intialize the App (internal use)
Event handler when change window size (internal use)
Event handler when selecting an object (internal use)
Event handler when selection is changed (internal use)
render()
resize()
Resize Window (internal use)
Resize Window (internal use)
function apply()
scilligence.apply is a tool function to append new properties to a dictionary object
 Example:
    var person = { firstname: "Tony", lastname: "Yuan" };
    scilligence.apply(person, { company: "Scilligence" });
 
function extend()
scilligence.extend is a tool function to do OO programming in Javascript
 Example:
    // parent class, here scilligence._base is empty class
    Person = scilligence.extend(scilligence._base, {
        constructor: function(firstname, lastname) {
            this.firstname = firstname;
            this.lastname = lastname;
        },

        getFullname: function() {
            return this.lastname + ", " + this.firstname;
        }
    });

    // sub class
    Employee = scilligence.extend(Person, {
        constructor: function (firstname, lastname, employeeid) {
            this.superclass().constructor(firstname, lastname);
            this.employeeid = employeeid;
        },

        getEmployeeID: function () {
            return this.employeeid;
        }
    });
    
    // define static method
    scilligence.apply(Employee, {
        kCompany: "Scilligence", // static property

        getEmployNo: function (id) { // static method
            return "SCI-" + id;
        }
    }

    // create an Employee object
    var e = new Employee("Tony", "Yuan", 192);
    var s = e.getFullname();
 
about()
Show about box
Test if a node is HELM monomer
List HELM Monomer Types
Tool function to select bonds of all selected atoms (internal use)
setMolfile (string molfile)
Set Molfile
setXml (string xml)
Set JSDraw Xml data
Swap canvas and sequence view (internal use)
Update Canvas from sequence/notation view (internal use)
update helm properties (internal use)
Update structure view from Canvas (internal use)

Property Details

property JSDraw2.Editor canvas

- Drawing Canvas

property MonomerExplorer mex

- Monomer Explorer

property DIV notation

- HELM Notation

property scilligence.Form properties

- HELM Property Table

property version

HELM Version

property DIV sequence

- Biological Sequence

property JSDraw2.Editor structureview

- Structure Viewer

Constructor Details

constructor App

App(DOM parent, dict options)
Parameters:
parent - The parent element to host the Editor App
options - options on how to render the App
 mexfontsize: {string} Monomer Explorer font size, e.g. "90%"
 mexrnapinontab: {bool} show RNA pin icon on its tab on Monomer Explorer
 mexmonomerstab: {bool} show Monomers tab on Monomer Explorer
 mexfavoritefirst: {bool} display favorite items first on Monomer Explorer
 mexfilter: {bool} display Filter box on Monomer Explorer
 sequenceviewonly: {bool} show Sequence View in viewonly mode
 showabout: {bool} show about button
 topmargin: {number} top margin
 calculatorurl: {string} ajax web service url to calculate properties
 cleanupurl: {string} ajax web service url to clean up structures
 monomersurl: {string} ajax web service url to load all monomers
 rulesurl: {string} ajax web service url to load all rules

 Example:
    <div id="div1" style="margin: 5px; margin-top: 15px"></div>
    <script type="text/javascript">
     scilligence.ready(function () {
         var app = new scilligence.helm.App("div1", { showabout: false, mexfontsize: "90%", mexrnapinontab: true, 
             topmargin: 20, mexmonomerstab: true, sequenceviewonly: false, mexfavoritefirst: true, mexfilter: true });
     });
    </script>
 

constructor Graph

Graph(string or DOM element, dict options)
Parameters:
element - the parent Element
options - { layout, nodes, edges, animate, bordercolor, edgecolor } - layout: random, preset, grid, circle, concentric, breadthfirst, cose

constructor XDraw

XDraw(string or DOM parent, dictionary options)
Parameters:
parent - Parent HTML element
options creating options: { width, height }

Function Details

function calculateProperties

calculateProperties()
Calaulte helm structure properties (internal use)

function calculateSizes

calculateSizes()
Calculate layout sizes (internal use)

function clear

clear()
Clear contents
Returns:
null

function createCanvas

createCanvas()
create drawing canvas (internal use)

function createNotation

createNotation()
create notation view (internal use)

function createPalette

createPalette()
create monomer explorer (internal use)

function createProperties

createProperties()
Create property window (internal use)

function createSequence

createSequence()
Create sequence view (internal use)

function createStructureView

createStructureView()
Create structure view (internal use)

function getMolfile

getMolfile()
Get Molfile
Returns:
a string

function getSelectedAsMol

getSelectedAsMol()
Get selection as a molfile (internal use)

function getSmiles

getSmiles()
Get SMILES
Returns:
a string

function getValueByKey

getValueByKey()
Tool function to get item by using its key (internal use)

function getXml

getXml()
Get JSDraw Xml data
Returns:
a string

function init

init()
Intialize the App (internal use)

function onresize

onresize()
Event handler when change window size (internal use)

function onselectcurrent

onselectcurrent()
Event handler when selecting an object (internal use)

function onselectionchanged

onselectionchanged()
Event handler when selection is changed (internal use)

function render

render()

function resize

resize()
Resize Window (internal use)

function resizeWindow

resizeWindow()
Resize Window (internal use)

function apply

function apply()
scilligence.apply is a tool function to append new properties to a dictionary object
 Example:
    var person = { firstname: "Tony", lastname: "Yuan" };
    scilligence.apply(person, { company: "Scilligence" });
 

function extend

function extend()
scilligence.extend is a tool function to do OO programming in Javascript
 Example:
    // parent class, here scilligence._base is empty class
    Person = scilligence.extend(scilligence._base, {
        constructor: function(firstname, lastname) {
            this.firstname = firstname;
            this.lastname = lastname;
        },

        getFullname: function() {
            return this.lastname + ", " + this.firstname;
        }
    });

    // sub class
    Employee = scilligence.extend(Person, {
        constructor: function (firstname, lastname, employeeid) {
            this.superclass().constructor(firstname, lastname);
            this.employeeid = employeeid;
        },

        getEmployeeID: function () {
            return this.employeeid;
        }
    });
    
    // define static method
    scilligence.apply(Employee, {
        kCompany: "Scilligence", // static property

        getEmployNo: function (id) { // static method
            return "SCI-" + id;
        }
    }

    // create an Employee object
    var e = new Employee("Tony", "Yuan", 192);
    var s = e.getFullname();
 

function about

about()
Show about box

function isHelmNode

isHelmNode()
Test if a node is HELM monomer

function monomerTypeList

monomerTypeList()
List HELM Monomer Types

function selectBondsOfSelectedAtoms

selectBondsOfSelectedAtoms()
Tool function to select bonds of all selected atoms (internal use)

function setMolfile

setMolfile(string molfile)
Set Molfile
Parameters:
molfile - input molfile
Returns:
null

function setXml

setXml(string xml)
Set JSDraw Xml data
Parameters:
xml - JSDraw HTML data
Returns:
null

function swapCanvasSequence

swapCanvasSequence()
Swap canvas and sequence view (internal use)

function updateCanvas

updateCanvas()
Update Canvas from sequence/notation view (internal use)

function updateProperties

updateProperties()
update helm properties (internal use)

function updateStructureView

updateStructureView()
Update structure view from Canvas (internal use)