Am 07.02.2014 20:38, schrieb Charles Harrison Shubert:
> Hi,
>
> I'm clearly not reading the documentation correctly and I'm missing
> something. I want to use the JSmol callback functionality. What am I
> doing wrong?
>
> Thanks,
>
> --Chuck
>
> My javascript:
>
> function init_jsmol(state) {
>
> // … other initialization
>
> Jmol.setXHTML(model.ids.id_jsmol);
>
> var Info = {};
> Info.script = session.modelControl.getActiveScript(state);
> Info.j2sPath = model.jsmol.j2sPath;
> Info.disableInitialConsole = true;
> Info.disableJ2SLoadMonitor = true;
>
> jmolObject = Jmol.getApplet(model.ids.id_jsmol, Info);
>
> // … other initialization
> }
>
> function myMessageCallback(one, two) {
> console.info("I'm in myMessageCallback: " + one);
> console.info("I'm in myMessageCallback: " + two);
> }
>
> function getJSmolInfo(state) { // called from another part of my code.
> try {
> console.info("getJSmolInfo entry");
>
> script(";set messageCallback 'myMessageCallback';");
> script(";define chucksel '[ALA]1:A.O or [ALA]1:A.C'; select chucksel;
> color atoms pink;");
> script("message 'hi ho';");
>
I never tried to set the message callback by using Jmol Script. What 
works for me (e.g.: 
http://jenalib.fli-leibniz.de/cgi-bin/3d_mapping-rh.pl?CODE=1deh&APPLET=html5) 
is setting it in the 'Info' object like this:

-------------------------------------------------------
        Info = {
                use: "JAVA HTML5",
                width: "600",
                height: "600",
                debug: false,
                color: "black",
                 j2sPath: 
"http://jenalib.fli-leibniz.de/ImgLibPDB/jmol/jmol-14.0.5/jsmol/j2s";,
                 jarPath: "/ImgLibPDB/jmol/jmol-14.0.5/jsmol/java",
                 jarFile: "JmolAppletSigned.jar",
                 isSigned: "true",
                 disableJ2SLoadMonitor: true,
                 disableInitialConsole: true,
                addSelectionOptions: false,
                serverURL: "/ImgLibPDB/jmol/jmol-14.0.5/jsmol/php/jsmol.php",
                script: "",
                 messagecallback: "_jmolMessageCallback",
                 allowjavascript: true
                };

        function _jmolMessageCallback(app,msg) {      /* jmol message 
callback, reverse logging into textarea */
           msg = "" + msg;    /* convert callback message into string 
(recommended by other Jmol users) */
           log_monitor.unshift(msg);
           if (document.getElementById("jmol_monitor").value.length > 
8000) {
             log_monitor.pop();
           }
           document.getElementById("jmol_monitor").value = 
log_monitor.join("\n");

           if (msg.match(/([\d,]+) atoms selected/)) {   /*  */
             var selection_count_tag = 
document.getElementById("selection_count");
 
selection_count_tag.replaceChild(document.createTextNode(RegExp.$1), 
selection_count_tag.childNodes[0]);
             document.getElementById("selection_count").innerHtml=RegExp.$1;
           }
         }
-------------------------------------------------------

So it should work if you add this to your 'Info' initialization:

   Info.messagecallback = "myMessageCallback";

Regards,
Rolf
-- 

Rolf Huehne
Postdoc

Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany

Phone:   +49 3641 65 6205
Fax:     +49 3641 65 6210
E-Mail:  rhue...@fli-leibniz.de
Website: http://www.fli-leibniz.de

           Scientific Director: Prof. Dr. K. Lenhard Rudolph
        Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein

VAT No: DE 153 925 464
Register of Associations: No. 296, Amtsgericht Jena
Tax Number: 162/141/08228


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to